diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index d2cf4b92..2114adfa 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -22,14 +22,26 @@ jobs: - name: Install Rust toolchain uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable + # Rust is analyzed without a build, so there is no build step. The extractor + # runs its own cargo commands (build scripts, proc macros) in a scratch + # target dir that is empty on every run unless we point it somewhere + # persistent, so cache that dir along with the registry. + - name: Cache extractor cargo output + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + ${{ runner.temp }}/codeql-rust-target + key: ${{ runner.os }}-codeql-cargo-${{ hashFiles('rust/Cargo.lock') }} + restore-keys: ${{ runner.os }}-codeql-cargo- + - name: Initialize CodeQL uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2 with: languages: rust - - name: Build - run: cargo build - working-directory: rust - - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2 + env: + CODEQL_ACTION_EXTRA_OPTIONS: '{"database":{"trace-command":["--extractor-option","rust.cargo_target_dir=${{ runner.temp }}/codeql-rust-target"]}}'