Conformance tests #215
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Rust | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
env: | |
CARGO_TERM_COLOR: always | |
permissions: | |
pull-requests: write | |
jobs: | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: Swatinem/rust-cache@v2 | |
- name: Format | |
run: cargo fmt --all -- --check | |
- name: Build | |
run: cargo build --verbose | |
- name: Clippy | |
run: cargo clippy --all-features --all-targets -- -D warnings | |
- name: Run tests | |
run: cargo test --verbose | |
conformance: | |
name: Conformance Tests | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: Swatinem/rust-cache@v2 | |
- name: Run conformance tests | |
run: cargo test --test conformance 2>&1 | tee conformance.log | |
continue-on-error: true | |
- id: conformance | |
name: Conformance results | |
run: | | |
read -r passed skipped failed <<< $(cat conformance.log | perl -n -e'/steps \((\d+) passed, (\d+) skipped, (\d+) failed\)/ && print "$1 $2 $3"') | |
echo "passed=$passed" | |
echo "skipped=$skipped" | |
echo "failed=$failed" | |
# Calculate the conformance score as a percentage (passed / (passed + skipped + failed)) | |
score=$(echo "scale=2; $passed / ($passed + $skipped + $failed) * 100" | bc) | |
# Set the output | |
echo "score=$score" >> "$GITHUB_OUTPUT" | |
echo "passed=$passed" >> "$GITHUB_OUTPUT" | |
echo "skipped=$skipped" >> "$GITHUB_OUTPUT" | |
echo "failed=$failed" >> "$GITHUB_OUTPUT" | |
- name: Comment PR | |
uses: thollander/actions-comment-pull-request@v2 | |
with: | |
message: | | |
**Conformance score**: ${{ steps.conformance.outputs.score }}% | |
**Passed**: ${{ steps.conformance.outputs.passed }} | |
**Skipped**: ${{ steps.conformance.outputs.skipped }} | |
**Failed**: ${{ steps.conformance.outputs.failed }} | |