diff --git a/.github/workflows/ruby-build.yml b/.github/workflows/ruby-build.yml index 2c4ddb8a582..784a7db3dc9 100644 --- a/.github/workflows/ruby-build.yml +++ b/.github/workflows/ruby-build.yml @@ -86,20 +86,23 @@ jobs: ruby/target/release/ruby-extractor.exe retention-days: 1 compile-queries: - runs-on: ubuntu-latest - env: - CODEQL_THREADS: 4 # TODO: remove this once it's set by the CLI + runs-on: ubuntu-latest-xl steps: - uses: actions/checkout@v3 - name: Fetch CodeQL uses: ./.github/actions/fetch-codeql + - name: Cache compilation cache + id: query-cache + uses: ./.github/actions/cache-query-compilation + with: + key: ruby-build - name: Build Query Pack run: | codeql pack create ../shared/ssa --output target/packs codeql pack create ../misc/suite-helpers --output target/packs codeql pack create ../shared/regex --output target/packs codeql pack create ql/lib --output target/packs - codeql pack create ql/src --output target/packs + codeql pack create -j0 ql/src --output target/packs --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}" PACK_FOLDER=$(readlink -f target/packs/codeql/ruby-queries/*) codeql generate query-help --format=sarifv2.1.0 --output="${PACK_FOLDER}/rules.sarif" ql/src (cd ql/src; find queries \( -name '*.qhelp' -o -name '*.rb' -o -name '*.erb' \) -exec bash -c 'mkdir -p "'"${PACK_FOLDER}"'/$(dirname "{}")"' \; -exec cp "{}" "${PACK_FOLDER}/{}" \;) diff --git a/.github/workflows/ruby-qltest.yml b/.github/workflows/ruby-qltest.yml index abb6d2bf0eb..d8af552c8c6 100644 --- a/.github/workflows/ruby-qltest.yml +++ b/.github/workflows/ruby-qltest.yml @@ -2,7 +2,11 @@ name: "Ruby: Run QL Tests" on: push: - # no path requirement on branch pushes, so the cache is more effective. + paths: + - "ruby/**" + - .github/workflows/ruby-build.yml + - .github/actions/fetch-codeql/action.yml + - codeql-workspace.yml branches: - main - "rc/*" diff --git a/ruby/actions/create-extractor-pack/action.yml b/ruby/actions/create-extractor-pack/action.yml index b0907eff834..667158c264c 100644 --- a/ruby/actions/create-extractor-pack/action.yml +++ b/ruby/actions/create-extractor-pack/action.yml @@ -3,7 +3,15 @@ description: Builds the Ruby CodeQL pack runs: using: composite steps: - - uses: actions/cache@v3 + - name: Cache entire extractor + id: cache-extractor + uses: actions/cache@v3 + with: + path: ruby/extractor-pack + key: ${{ runner.os }}-extractor-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }}-${{ hashFiles('ruby/**/*.rs') }}-${{ hashFiles('ruby/codeql-extractor.yml', 'ruby/downgrades', 'ruby/tools', 'ruby/ql/lib/ruby.dbscheme', 'ruby/ql/lib/ruby.dbscheme.stats') }} + - name: Cache cargo + uses: actions/cache@v3 + if: steps.cache-extractor.outputs.cache-hit != 'true' with: path: | ~/.cargo/registry @@ -11,6 +19,7 @@ runs: ruby/target key: ${{ runner.os }}-ruby-qltest-cargo-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }} - name: Build Extractor + if: steps.cache-extractor.outputs.cache-hit != 'true' shell: bash run: scripts/create-extractor-pack.sh working-directory: ruby