name: Shared CRW on: push: branches: [main] paths: ["crates/crw/**", "scripts/fetch-crw-samples.py", "Cargo.toml", "Cargo.lock", ".github/workflows/crw.yml"] pull_request: paths: ["crates/crw/**", "scripts/fetch-crw-samples.py", "Cargo.toml", "Cargo.lock", ".github/workflows/crw.yml"] workflow_dispatch: permissions: contents: read concurrency: # Pull requests share one group per branch, so a newer push cancels the older run. Every other # run (main, manual) gets its own group: it is never cancelled or replaced while queued, so it # always gets to save the cache. group: shared-crw-${{ github.event_name == 'pull_request' && github.ref || github.run_id }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: native: timeout-minutes: 20 name: CRW lint and tests (${{ matrix.os }}) strategy: fail-fast: false matrix: os: [ubuntu-latest, windows-latest] runs-on: ${{ matrix.os }} steps: - name: Harden runner uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 with: egress-policy: audit - uses: actions/checkout@v7 with: persist-credentials: false - uses: step-security/dtolnay-rust-toolchain@8dd607977d06adf4ed49b190381e74c17a9dd25f # v1.0.0 with: toolchain: stable components: rustfmt, clippy - uses: step-security/rust-cache@8871c8ba063416da7c32246932ea6ae08700453e # v2.9.2 with: key: craft-crw-${{ matrix.os }} save-if: ${{ github.ref == 'refs/heads/main' }} - run: cargo fmt -p craft-crw --check - run: cargo clippy -p craft-crw --all-targets --locked -- -D warnings - run: cargo test -p craft-crw --locked wasm: timeout-minutes: 10 name: CRW WASM runs-on: ubuntu-latest steps: - name: Harden runner uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 with: egress-policy: audit - uses: actions/checkout@v7 with: persist-credentials: false - uses: step-security/dtolnay-rust-toolchain@8dd607977d06adf4ed49b190381e74c17a9dd25f # v1.0.0 with: toolchain: stable targets: wasm32-unknown-unknown - uses: step-security/rust-cache@8871c8ba063416da7c32246932ea6ae08700453e # v2.9.2 with: key: craft-crw-wasm save-if: ${{ github.ref == 'refs/heads/main' }} - run: cargo check -p craft-crw --locked --target wasm32-unknown-unknown samples: timeout-minutes: 20 name: CRW sample files decode exactly runs-on: ubuntu-latest steps: - name: Harden runner uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 with: egress-policy: audit - uses: actions/checkout@v7 with: persist-credentials: false - uses: step-security/dtolnay-rust-toolchain@8dd607977d06adf4ed49b190381e74c17a9dd25f # v1.0.0 with: toolchain: stable - uses: step-security/rust-cache@8871c8ba063416da7c32246932ea6ae08700453e # v2.9.2 with: key: craft-crw-samples save-if: ${{ github.ref == 'refs/heads/main' }} - name: Cache the CC0 sample files uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: ${{ runner.temp }}/crw-samples key: crw-samples-${{ hashFiles('crates/crw/tests/samples.json') }} - name: Fetch the pinned CC0 sample files (raw.pixls.us) run: python scripts/fetch-crw-samples.py "$RUNNER_TEMP/crw-samples" - run: cargo test -p craft-crw --release --locked --test samples -- --nocapture env: CRAFT_CRW_SAMPLES: ${{ runner.temp }}/crw-samples CRAFT_CRW_REQUIRE_SAMPLES: "1"