name: Shared CRW on: push: branches: [main, next] 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: ${{ github.ref == 'refs/heads/next' && fromJSON('["ubuntu-latest"]') || fromJSON('["ubuntu-latest","windows-latest"]') }} runs-on: ${{ matrix.os }} steps: - name: Harden runner uses: step-security/harden-runner@v2.22.4 with: egress-policy: audit - uses: actions/checkout@v7.0.1 with: persist-credentials: false - uses: step-security/dtolnay-rust-toolchain@v1.0.0 with: toolchain: stable components: rustfmt, clippy - uses: step-security/rust-cache@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 - name: Docs (links and missing docs) if: runner.os == 'Linux' run: cargo doc -p craft-crw --no-deps --locked env: RUSTDOCFLAGS: -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@v2.22.4 with: egress-policy: audit - uses: actions/checkout@v7.0.1 with: persist-credentials: false - uses: step-security/dtolnay-rust-toolchain@v1.0.0 with: toolchain: stable targets: wasm32-unknown-unknown - uses: step-security/rust-cache@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@v2.22.4 with: egress-policy: audit - uses: actions/checkout@v7.0.1 with: persist-credentials: false - uses: step-security/dtolnay-rust-toolchain@v1.0.0 with: toolchain: stable - uses: step-security/rust-cache@v2.9.2 with: key: craft-crw-samples save-if: ${{ github.ref == 'refs/heads/main' }} - name: Cache the CC0 sample files uses: actions/cache@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 --lib -- integration::samples --nocapture env: CRAFT_CRW_SAMPLES: ${{ runner.temp }}/crw-samples CRAFT_CRW_REQUIRE_SAMPLES: "1"