Always report cargo clippy as a required check #51320
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
| name: cargo test | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: 0 * * * * # hourly | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| jobs: | |
| build-test-artifacts: | |
| name: Build test artifacts | |
| # Keep host-user Cargo outputs separate from the root-run MUSL build. | |
| runs-on: namespace-profile-ubuntu-8-cores;overrides.cache-tag=modeling-app-rust-host-v2 | |
| steps: | |
| - uses: runs-on/action@v2.3.0 | |
| - uses: actions/create-github-app-token@v3.2.0 | |
| id: app-token | |
| with: | |
| app-id: ${{ secrets.MODELING_APP_GH_APP_ID }} | |
| private-key: ${{ secrets.MODELING_APP_GH_APP_PRIVATE_KEY }} | |
| owner: ${{ github.repository_owner }} | |
| - uses: actions/checkout@v7.0.1 | |
| with: | |
| token: ${{ steps.app-token.outputs.token }} | |
| - name: Track setup | |
| run: .github/ci-cd-scripts/track-step.sh | |
| env: | |
| TAB_API_URL: ${{ vars.TAB_API_URL }} | |
| TAB_API_KEY: ${{ secrets.TAB_API_KEY }} | |
| CI_COMMIT_SHA: ${{ github.event.pull_request.head.sha }} | |
| CI_PR_NUMBER: ${{ github.event.pull_request.number }} | |
| CI_SUITE: e2e:kcl | |
| CI_STEP: setup | |
| - name: Use correct Rust toolchain | |
| shell: bash | |
| run: | | |
| [ -e rust-toolchain.toml ] || cp rust/rust-toolchain.toml ./ | |
| - name: Install rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1.17.0 | |
| with: | |
| cache: false # Configured below. | |
| rustflags: '' # Use .cargo/config.toml | |
| - name: Start Vector | |
| run: .github/ci-cd-scripts/start-vector-ubuntu.sh | |
| env: | |
| GH_ACTIONS_AXIOM_TOKEN: ${{ secrets.GH_ACTIONS_AXIOM_TOKEN }} | |
| OS_NAME: ${{ env.OS_NAME }} | |
| - uses: taiki-e/install-action@nextest | |
| - name: Install just | |
| uses: taiki-e/install-action@just | |
| - name: Rust cache on the Namespace volume | |
| uses: namespacelabs/nscloud-cache-action@v1 | |
| with: | |
| path: | | |
| rust/target | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| - name: Verify Rust cache is writable | |
| run: .github/ci-cd-scripts/verify-rust-cache-writable.sh | |
| - name: Fetch the base branch | |
| if: ${{ github.event_name == 'pull_request' }} | |
| env: | |
| BASE_REF: ${{ github.base_ref }} | |
| run: git fetch origin "${BASE_REF}" --depth=1 | |
| - name: Check for path changes | |
| id: path-changes | |
| shell: bash | |
| env: | |
| BASE_REF: ${{ github.base_ref }} | |
| EVENT_NAME: ${{ github.event_name }} | |
| run: | | |
| set -euo pipefail | |
| # Manual runs or push should run all tests. | |
| if [[ "${EVENT_NAME}" != 'pull_request' ]]; then | |
| echo "outside-kcl-samples=true" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| changed_files=$(git diff --name-only origin/${BASE_REF}) | |
| echo "$changed_files" | |
| if grep -Evq '^public/kcl-samples/|^rust/kcl-lib/tests/kcl_samples/' <<< "$changed_files" ; then | |
| echo "outside-kcl-samples=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "outside-kcl-samples=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: cargo test only kcl-samples | |
| id: cargo-test-kcl-samples | |
| if: steps.path-changes.outputs.outside-kcl-samples == 'false' | |
| continue-on-error: true | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| cd rust | |
| cargo nextest run \ | |
| --workspace --features=artifact-graph --retries=10 --no-fail-fast --profile=ci \ | |
| simulation_tests::kcl_samples \ | |
| 2>&1 | tee /tmp/github-actions.log | |
| env: | |
| ZOO_API_TOKEN: ${{secrets.ZOO_API_TOKEN}} | |
| ZOO_HOST: https://api.dev.zoo.dev | |
| RUST_BACKTRACE: full | |
| RUST_MIN_STACK: 10485760000 | |
| - name: Install cargo-insta | |
| # Only the "Commit differences" step below runs cargo insta, through | |
| # `just overwrite-sim-test`, and that step runs only when the | |
| # kcl-samples tests fail. This step carries the same condition so the | |
| # tool is installed on the runs that use it. | |
| if: steps.path-changes.outputs.outside-kcl-samples == 'false' && steps.cargo-test-kcl-samples.outcome == 'failure' | |
| uses: taiki-e/install-action@cargo-insta | |
| - name: Commit differences | |
| if: steps.path-changes.outputs.outside-kcl-samples == 'false' && steps.cargo-test-kcl-samples.outcome == 'failure' | |
| shell: bash | |
| env: | |
| GITHUB_ACTOR: ${{ github.actor }} | |
| GITHUB_HEAD_REF: ${{ github.head_ref }} | |
| GITHUB_REPOSITORY: ${{ github.repository }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| INSTA_UPDATE: always | |
| NEXTEST_PROFILE: ci | |
| RUST_BACKTRACE: full | |
| RUST_MIN_STACK: 10485760000 | |
| ZOO_API_TOKEN: ${{ secrets.ZOO_API_TOKEN }} | |
| ZOO_HOST: https://api.dev.zoo.dev | |
| run: | | |
| set -euo pipefail | |
| pushd rust | |
| just overwrite-sim-test kcl_samples | |
| popd | |
| git add \ | |
| rust/kcl-lib/tests \ | |
| public/kcl-samples | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git remote set-url origin https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git | |
| git fetch origin | |
| echo "${GITHUB_HEAD_REF}" | |
| git checkout "${GITHUB_HEAD_REF}" | |
| if ! git commit -m "Update kcl-samples simulation test output" ; then | |
| echo "No changes to commit" | |
| # This only runs if tests failed, so we should fail the step. | |
| exit 1 | |
| fi | |
| git push origin "${GITHUB_HEAD_REF}" | |
| - name: Build and archive tests | |
| run: | | |
| cd rust | |
| cargo nextest archive --workspace --features artifact-graph --archive-file nextest-archive.tar.zst | |
| - name: Check TypeScript-facing bindings against expected | |
| shell: bash | |
| run: | | |
| ./scripts/generate-bindings.sh | |
| ./scripts/update-expected-bindings.sh | |
| git add -A -- rust/kcl-lib/expected-bindings/ | |
| git diff --cached --exit-code -- rust/kcl-lib/expected-bindings/ \ | |
| || (echo 'Generated bindings differ from rust/kcl-lib/expected-bindings/.' \ | |
| 'If this API change is intentional, run `npm run bindings:update` and commit the result.' >&2; exit 1) | |
| - name: Upload archive to workflow | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: nextest-archive | |
| path: rust/nextest-archive.tar.zst | |
| run-test-artifacts: | |
| name: cargo test (${{ matrix.executor }}, shard ${{ matrix.partitionIndex}}) | |
| runs-on: namespace-profile-ubuntu-8-cores;overrides.cache-tag=modeling-app-general-v2 | |
| needs: build-test-artifacts | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| partitionIndex: [1, 2, 3] | |
| partitionTotal: [3] | |
| # Differential testing: the whole suite runs under both the recursive | |
| # executor and the CEK machine executor, and must produce identical | |
| # snapshots. See rust/kcl-lib/src/execution/machine.rs. | |
| executor: [recursive, machine] | |
| steps: | |
| - uses: runs-on/action@v2.3.0 | |
| - uses: actions/create-github-app-token@v3.2.0 | |
| id: app-token | |
| with: | |
| app-id: ${{ secrets.MODELING_APP_GH_APP_ID }} | |
| private-key: ${{ secrets.MODELING_APP_GH_APP_PRIVATE_KEY }} | |
| owner: ${{ github.repository_owner }} | |
| - uses: actions/checkout@v7.0.1 | |
| with: | |
| token: ${{ steps.app-token.outputs.token }} | |
| - name: Use correct Rust toolchain | |
| shell: bash | |
| run: | | |
| [ -e rust-toolchain.toml ] || cp rust/rust-toolchain.toml ./ | |
| - name: Install Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1.17.0 | |
| with: | |
| cache: false # Configured below. | |
| rustflags: '' # Use .cargo/config.toml | |
| - name: Start Vector | |
| run: .github/ci-cd-scripts/start-vector-ubuntu.sh | |
| env: | |
| GH_ACTIONS_AXIOM_TOKEN: ${{ secrets.GH_ACTIONS_AXIOM_TOKEN }} | |
| OS_NAME: ${{ env.OS_NAME }} | |
| - uses: taiki-e/install-action@nextest | |
| - name: Download archive | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: nextest-archive | |
| - name: Track start | |
| run: .github/ci-cd-scripts/track-step.sh | |
| env: | |
| TAB_API_URL: ${{ vars.TAB_API_URL }} | |
| TAB_API_KEY: ${{ secrets.TAB_API_KEY }} | |
| CI_COMMIT_SHA: ${{ github.event.pull_request.head.sha }} | |
| CI_PR_NUMBER: ${{ github.event.pull_request.number }} | |
| CI_SUITE: e2e:kcl | |
| CI_STEP: start | |
| - name: Run tests | |
| shell: bash | |
| run: |- | |
| cp nextest-archive.tar.zst rust/nextest-archive.tar.zst | |
| pushd rust | |
| # The recursive leg runs the full suite. The machine leg reruns | |
| # only executor-sensitive tests: packages and modules that never | |
| # construct an ExecutorContext (parsers, printers, ts-rs bindings | |
| # codegen, ...) behave identically under both executors, so they | |
| # run once. Exclusion-based so that a new execution test is | |
| # machine-covered by default. | |
| executor_filter=() | |
| if [ "${{ matrix.executor }}" = "machine" ]; then | |
| executor_filter=(-E "package(kcl-lib) and not (test(/^parsing::/) or test(/^unparser::/) or test(/^walk::/) or test(/^settings::/) or test(/^fs::/) or test(/^fmt::/) or test(/^tooling::/) or test(/^errors::/) or test(/export_bindings/))") | |
| fi | |
| cargo nextest run \ | |
| --retries=10 --no-fail-fast --profile=ci --archive-file nextest-archive.tar.zst \ | |
| --partition count:${{ matrix.partitionIndex}}/${{ matrix.partitionTotal }} \ | |
| "${executor_filter[@]}" \ | |
| 2>&1 | tee /tmp/github-actions.log || true # let TAB determine failure | |
| popd | |
| .github/ci-cd-scripts/upload-results.sh | |
| env: | |
| ZOO_API_TOKEN: ${{secrets.ZOO_API_TOKEN}} | |
| ZOO_HOST: https://api.dev.zoo.dev | |
| RUST_MIN_STACK: 10485760000 | |
| KCL_EXECUTOR: ${{ matrix.executor }} | |
| TAB_API_URL: ${{ vars.TAB_API_URL }} | |
| TAB_API_KEY: ${{ secrets.TAB_API_KEY }} | |
| CI_COMMIT_SHA: ${{ github.event.pull_request.head.sha }} | |
| CI_PR_NUMBER: ${{ github.event.pull_request.number }} | |
| CI_SUITE: e2e:kcl | |
| - name: Track teardown | |
| if: always() | |
| run: .github/ci-cd-scripts/track-step.sh | |
| env: | |
| TAB_API_URL: ${{ vars.TAB_API_URL }} | |
| TAB_API_KEY: ${{ secrets.TAB_API_KEY }} | |
| CI_COMMIT_SHA: ${{ github.event.pull_request.head.sha }} | |
| CI_PR_NUMBER: ${{ github.event.pull_request.number }} | |
| CI_SUITE: e2e:kcl | |
| CI_STEP: teardown |