Skip to content

Commit

Permalink
Merge pull request #1944 from github/henrymercer/sublanguage-file-cov…
Browse files Browse the repository at this point in the history
…erage-fixes

Enable sub-language file coverage during interpretation and update PR check
  • Loading branch information
henrymercer authored Oct 12, 2023
2 parents b584cf8 + 346d5c4 commit 34f97d7
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 13 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/__export-file-baseline-information.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions lib/codeql.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/codeql.js.map

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions pr-checks/checks/export-file-baseline-information.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: "Export file baseline information"
description: "Tests that file baseline information is exported when the feature is enabled"
versions: ["nightly-latest"]
env:
CODEQL_ACTION_SUBLANGUAGE_FILE_COVERAGE: true
steps:
- uses: ./../action/init
id: init
with:
languages: javascript
tools: ${{ steps.prepare-test.outputs.tools-url }}
env:
CODEQL_FILE_BASELINE_INFORMATION: true
- uses: ./../action/.github/actions/setup-swift
with:
codeql-path: ${{ steps.init.outputs.codeql-path }}
Expand All @@ -18,8 +18,6 @@ steps:
- uses: ./../action/analyze
with:
output: "${{ runner.temp }}/results"
env:
CODEQL_FILE_BASELINE_INFORMATION: true
- name: Upload SARIF
uses: actions/upload-artifact@v3
with:
Expand All @@ -30,13 +28,13 @@ steps:
shell: bash
run: |
cd "$RUNNER_TEMP/results"
expected_baseline_languages="cpp cs go java js py rb"
expected_baseline_languages="c csharp go java kotlin javascript python ruby"
if [[ $RUNNER_OS != "Windows" ]]; then
expected_baseline_languages+=" swift"
fi
for lang in ${expected_baseline_languages}; do
rule_name="${lang}/baseline/expected-extracted-files"
rule_name="cli/expected-extracted-files/${lang}"
found_notification=$(jq --arg rule_name "${rule_name}" '[.runs[0].tool.driver.notifications |
select(. != null) | flatten | .[].id] | any(. == $rule_name)' javascript.sarif)
if [[ "${found_notification}" != "true" ]]; then
Expand Down
12 changes: 12 additions & 0 deletions src/codeql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,18 @@ export async function getCodeQLForCmd(
) {
codeqlArgs.push("--sarif-add-baseline-file-info");
}
if (
await features.getValue(Feature.SublanguageFileCoverageEnabled, this)
) {
codeqlArgs.push("--sublanguage-file-coverage");
} else if (
await util.codeQlVersionAbove(
this,
CODEQL_VERSION_SUBLANGUAGE_FILE_COVERAGE,
)
) {
codeqlArgs.push("--no-sublanguage-file-coverage");
}
if (shouldExportDiagnostics) {
codeqlArgs.push("--sarif-include-diagnostics");
} else if (await util.codeQlVersionAbove(this, "2.12.4")) {
Expand Down

0 comments on commit 34f97d7

Please sign in to comment.