diff --git a/.github/workflows/__export-file-baseline-information.yml b/.github/workflows/__export-file-baseline-information.yml index 597c7ce9b..7badf827f 100644 --- a/.github/workflows/__export-file-baseline-information.yml +++ b/.github/workflows/__export-file-baseline-information.yml @@ -91,6 +91,11 @@ jobs: with: languages: javascript tools: ${{ steps.prepare-test.outputs.tools-url }} + # To balance speed and coverage, analyze only JavaScript but use the combined bundle so + # baseline information is reported for every language in the multi-language repository. A + # no-op custom configuration selects that conservative path for custom configurations. + config: | + paths-ignore: [] - name: Build code run: ./build.sh - uses: ./../action/analyze @@ -124,5 +129,5 @@ jobs: env: CODEQL_ACTION_SKIP_FILE_COVERAGE_ON_PRS: false CODEQL_ACTION_SUBLANGUAGE_FILE_COVERAGE: true - CODEQL_ACTION_PER_LANGUAGE_BUNDLES: false + CODEQL_ACTION_PER_LANGUAGE_BUNDLES: true CODEQL_ACTION_TEST_MODE: true diff --git a/.github/workflows/__per-language-bundle-validation.yml b/.github/workflows/__per-language-bundle-validation.yml index ea900a9e0..07930b35a 100644 --- a/.github/workflows/__per-language-bundle-validation.yml +++ b/.github/workflows/__per-language-bundle-validation.yml @@ -36,40 +36,40 @@ jobs: include: - language: actions os: ubuntu-latest - version: nightly-latest + version: linked expected-extractors: actions javascript - language: cpp os: ubuntu-latest - version: nightly-latest + version: linked build-mode: manual build-command: gcc -o main main.c - language: csharp os: ubuntu-latest - version: nightly-latest + version: linked build-mode: none - language: go os: ubuntu-latest - version: nightly-latest + version: linked build-mode: autobuild - language: java os: ubuntu-latest - version: nightly-latest + version: linked build-mode: none - language: javascript os: ubuntu-latest - version: nightly-latest + version: linked - language: python os: ubuntu-latest - version: nightly-latest + version: linked - language: ruby os: ubuntu-latest - version: nightly-latest + version: linked - language: rust os: ubuntu-latest - version: nightly-latest + version: linked - language: swift os: macos-latest-xlarge - version: nightly-latest + version: linked build-mode: autobuild name: Per-language bundles if: github.triggering_actor != 'dependabot[bot]' @@ -88,6 +88,14 @@ jobs: version: ${{ matrix.version }} use-all-platform-bundle: 'false' setup-kotlin: 'true' + - name: Remove CodeQL from toolcache + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + with: + script: | + const fs = require('fs'); + const path = require('path'); + const codeqlPath = path.join(process.env['RUNNER_TOOL_CACHE'], 'CodeQL'); + fs.rmdirSync(codeqlPath, { recursive: true }); - uses: ./../action/init id: init with: @@ -128,9 +136,8 @@ jobs: CODEQL_PATH: ${{ steps.init.outputs.codeql-path }} run: | # A bundle that is missing most of its extractors must never be left in the toolcache, - # where a later job analyzing a different language could pick it up. The runner image - # ships with its own CodeQL in the toolcache, so check where this bundle was extracted to - # rather than whether the toolcache contains CodeQL at all. + # where a later job analyzing a different language could pick it up. Per-language bundles + # must instead be extracted under the runner's temporary directory. echo "CodeQL is at $CODEQL_PATH" if [[ "$CODEQL_PATH" == "$RUNNER_TOOL_CACHE"/* ]]; then echo "::error::The per-language bundle was added to the toolcache at $CODEQL_PATH." diff --git a/pr-checks/checks/export-file-baseline-information.yml b/pr-checks/checks/export-file-baseline-information.yml index da3237238..87c4b7609 100644 --- a/pr-checks/checks/export-file-baseline-information.yml +++ b/pr-checks/checks/export-file-baseline-information.yml @@ -11,16 +11,18 @@ installDotNet: true env: CODEQL_ACTION_SKIP_FILE_COVERAGE_ON_PRS: false CODEQL_ACTION_SUBLANGUAGE_FILE_COVERAGE: true - # To balance speed and coverage, we analyze only a single language (JavaScript), but use the - # combined bundle so we can test that baseline information is reported for each language in the - # multi-language source directory. - CODEQL_ACTION_PER_LANGUAGE_BUNDLES: false + CODEQL_ACTION_PER_LANGUAGE_BUNDLES: true steps: - uses: ./../action/init id: init with: languages: javascript tools: ${{ steps.prepare-test.outputs.tools-url }} + # To balance speed and coverage, analyze only JavaScript but use the combined bundle so + # baseline information is reported for every language in the multi-language repository. A + # no-op custom configuration selects that conservative path for custom configurations. + config: | + paths-ignore: [] - name: Build code run: ./build.sh - uses: ./../action/analyze diff --git a/pr-checks/checks/per-language-bundle-validation.yml b/pr-checks/checks/per-language-bundle-validation.yml index 21fe33e75..ac22f67f5 100644 --- a/pr-checks/checks/per-language-bundle-validation.yml +++ b/pr-checks/checks/per-language-bundle-validation.yml @@ -1,49 +1,56 @@ name: Per-language bundles description: Validates extraction and analysis using each per-language CodeQL bundle. -# TODO: Use a released bundle once releases include per-language bundles. matrix: include: - language: actions os: ubuntu-latest - version: nightly-latest + version: linked # Actions also needs the JavaScript extractor. expected-extractors: actions javascript - language: cpp os: ubuntu-latest - version: nightly-latest + version: linked build-mode: manual build-command: gcc -o main main.c - language: csharp os: ubuntu-latest - version: nightly-latest + version: linked build-mode: none - language: go os: ubuntu-latest - version: nightly-latest + version: linked build-mode: autobuild - language: java os: ubuntu-latest - version: nightly-latest + version: linked build-mode: none - language: javascript os: ubuntu-latest - version: nightly-latest + version: linked - language: python os: ubuntu-latest - version: nightly-latest + version: linked - language: ruby os: ubuntu-latest - version: nightly-latest + version: linked - language: rust os: ubuntu-latest - version: nightly-latest + version: linked - language: swift os: macos-latest-xlarge - version: nightly-latest + version: linked build-mode: autobuild env: CODEQL_ACTION_PER_LANGUAGE_BUNDLES: true steps: + - name: Remove CodeQL from toolcache + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + with: + script: | + const fs = require('fs'); + const path = require('path'); + const codeqlPath = path.join(process.env['RUNNER_TOOL_CACHE'], 'CodeQL'); + fs.rmdirSync(codeqlPath, { recursive: true }); - uses: ./../action/init id: init with: @@ -84,9 +91,8 @@ steps: CODEQL_PATH: ${{ steps.init.outputs.codeql-path }} run: | # A bundle that is missing most of its extractors must never be left in the toolcache, - # where a later job analyzing a different language could pick it up. The runner image - # ships with its own CodeQL in the toolcache, so check where this bundle was extracted to - # rather than whether the toolcache contains CodeQL at all. + # where a later job analyzing a different language could pick it up. Per-language bundles + # must instead be extracted under the runner's temporary directory. echo "CodeQL is at $CODEQL_PATH" if [[ "$CODEQL_PATH" == "$RUNNER_TOOL_CACHE"/* ]]; then echo "::error::The per-language bundle was added to the toolcache at $CODEQL_PATH."