Improve overloading diagnostics #57
Workflow file for this run
This file contains hidden or 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
| # This workflow checks each crate builds and runs, and for lints. | |
| name: Check | |
| # Runs this workflow | |
| on: | |
| # On all pull requests, regardless of target branch | |
| pull_request: | |
| # On PRs in the merge queue | |
| merge_group: | |
| # After merges to main | |
| push: | |
| branches: | |
| - main | |
| # When a developer asks for a manual workflow run | |
| workflow_dispatch: | |
| jobs: | |
| build-rust: | |
| name: 1. Build Rust crates | |
| runs-on: ubuntu-latest | |
| # Actions are pinned to a commit to prevent supply-chain attacks | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 | |
| with: | |
| toolchain: nightly | |
| # Use the same components in every step for caching | |
| components: cargo,clippy,rustfmt | |
| - name: Build each Rust crate | |
| run: cargo build --all-targets --all-features | |
| test-rust: | |
| name: 2. Test Rust crates | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 | |
| with: | |
| toolchain: nightly | |
| components: cargo,clippy,rustfmt | |
| - name: Test each Rust crate | |
| run: | | |
| cargo test --all-targets --all-features | |
| cargo test --doc --all-features | |
| run: | |
| name: 3. Run Rust example binaries | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 | |
| with: | |
| toolchain: nightly | |
| components: cargo,clippy,rustfmt | |
| - name: Run Rust example binaries | |
| # Find all test crate binaries, extract the basename (no directories or extensions), | |
| # then run them one at a time with cargo. | |
| # There is no default-run binary set in Cargo.toml. | |
| run: | | |
| find splat-overload-test/src/bin -name "*.rs" | \ | |
| sed 's|.*/\([^/]*\).rs|\1|g' | \ | |
| xargs --max-args=1 cargo run --all-features --bin | |
| clippy-rust: | |
| name: 4. Clippy lints on Rust crates | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 | |
| with: | |
| toolchain: nightly | |
| components: cargo,clippy,rustfmt | |
| - name: Run clippy on Rust crates | |
| run: cargo clippy --all-targets --all-features -- --deny warnings | |
| doc-rust: | |
| name: 5. Doc lints on Rust crates | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 | |
| with: | |
| toolchain: nightly | |
| components: cargo,clippy,rustfmt | |
| - name: Run doc checks on Rust crates | |
| run: cargo doc --all-features | |
| fmt-rust: | |
| name: 6. Code format on Rust crates | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 | |
| with: | |
| toolchain: nightly | |
| components: cargo,clippy,rustfmt | |
| - name: Run rustfmt checks on crates | |
| run: cargo fmt --all -- --check | |
| publish-dry-run: | |
| name: 7. Dry run publishing | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 | |
| with: | |
| toolchain: nightly | |
| components: cargo,clippy,rustfmt | |
| - name: Dry run publishing | |
| run: cargo publish --dry-run | |
| diagnostics-rust: | |
| name: 8. Diagnostics tests on Rust crates | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 | |
| with: | |
| toolchain: nightly | |
| # Use the same components in every step for caching | |
| components: cargo,clippy,rustfmt | |
| - name: Build each Rust crate | |
| # To bless (update the expected diagnostics), change '/tmp' to 'splat-overload-diagnostics/src/bin', | |
| # and disable color output. | |
| run: | | |
| export CARGO_TERM_COLOR=never | |
| set -o pipefail | |
| TEST_NAMES=$(find splat-overload-diagnostics/src/bin -name "*.rs" | \ | |
| sed 's|.*/\([^/]*\).rs|\1|g' ) | |
| echo "testing: $TEST_NAMES" | |
| for test_name in $TEST_NAMES; do | |
| echo "testing: $test_name" | |
| # We expect cargo to fail, so don't exit the shell when it does | |
| set +e | |
| # Ignore build progress, if it's cached then the built crates change | |
| cargo build --all-features --package splat-overload-diagnostics --bin "$test_name" 2>&1 | \ | |
| grep --invert-match -e 'Updating .* index' -e 'Compiling [^ ]* .*' \ | |
| > "/tmp/$test_name.stderr" | |
| CARGO_EXIT_CODE=$? | |
| set -e | |
| if [[ $CARGO_EXIT_CODE -ne 101 ]]; then | |
| echo "error: $test_name compilation unexpectedly returned exit code $CARGO_EXIT_CODE rather than 101" | |
| exit 1 | |
| fi | |
| echo "comparing diagnostics for: $test_name" | |
| diff --unified=5 "splat-overload-diagnostics/src/bin/$test_name.stderr" /tmp/"$test_name.stderr" | |
| done | |
| all: | |
| name: All checks | |
| # Always run this job, even if earlier steps were skipped (or failed): | |
| # <https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks> | |
| if: ${{ always() }} | |
| runs-on: ubuntu-latest | |
| needs: | |
| - build-rust | |
| - test-rust | |
| - run | |
| - clippy-rust | |
| - doc-rust | |
| - fmt-rust | |
| - publish-dry-run | |
| - diagnostics-rust | |
| steps: | |
| - name: Fail if any other job failed | |
| # Every job status needs to be checked here, because `always()` stops failures from propagating automatically | |
| run: | | |
| echo "Checking other jobs..." | |
| [[ "${{ needs.build-rust.result }}" == "success" ]] || exit 1 | |
| [[ "${{ needs.test-rust.result }}" == "success" ]] || exit 1 | |
| [[ "${{ needs.run.result }}" == "success" ]] || exit 1 | |
| [[ "${{ needs.clippy-rust.result }}" == "success" ]] || exit 1 | |
| [[ "${{ needs.doc-rust.result }}" == "success" ]] || exit 1 | |
| [[ "${{ needs.fmt-rust.result }}" == "success" ]] || exit 1 | |
| [[ "${{ needs.publish-dry-run.result }}" == "success" ]] || exit 1 | |
| [[ "${{ needs.diagnostics-rust.result }}" == "success" ]] || exit 1 |