diff --git a/.github/workflows/__export-file-baseline-information.yml b/.github/workflows/__export-file-baseline-information.yml index 240481b9a..77ac89088 100644 --- a/.github/workflows/__export-file-baseline-information.yml +++ b/.github/workflows/__export-file-baseline-information.yml @@ -44,6 +44,7 @@ jobs: version: ${{ matrix.version }} - uses: ./../action/init with: + languages: javascript tools: ${{ steps.prepare-test.outputs.tools-url }} env: CODEQL_FILE_BASELINE_INFORMATION: true @@ -63,5 +64,22 @@ jobs: name: with-baseline-information-${{ matrix.os }}-${{ matrix.version }}.sarif.json path: ${{ runner.temp }}/results/javascript.sarif retention-days: 7 + - name: Check results + shell: bash + run: | + cd "$RUNNER_TEMP/results" + expected_baseline_languages="cpp csharp go java js python ruby" + + for lang in ${expected_baseline_languages}; do + rule_name="${lang}/baseline/expected-extracted-files" + 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 + echo "Expected SARIF output to contain notification '${rule_name}', but found no such notification." + exit 1 + else + echo "Found notification '${rule_name}'." + fi + done env: INTERNAL_CODEQL_ACTION_DEBUG_LOC: true diff --git a/pr-checks/checks/export-file-baseline-information.yml b/pr-checks/checks/export-file-baseline-information.yml index b4e87e126..eecbbdafc 100644 --- a/pr-checks/checks/export-file-baseline-information.yml +++ b/pr-checks/checks/export-file-baseline-information.yml @@ -1,9 +1,10 @@ name: "Export file baseline information" -description: "Tests that exporting file baseline information works" +description: "Tests that file baseline information is exported when the feature is enabled" versions: ["nightly-latest"] steps: - uses: ./../action/init with: + languages: javascript tools: ${{ steps.prepare-test.outputs.tools-url }} env: CODEQL_FILE_BASELINE_INFORMATION: true @@ -23,3 +24,20 @@ steps: name: with-baseline-information-${{ matrix.os }}-${{ matrix.version }}.sarif.json path: "${{ runner.temp }}/results/javascript.sarif" retention-days: 7 + - name: Check results + shell: bash + run: | + cd "$RUNNER_TEMP/results" + expected_baseline_languages="cpp csharp go java js python ruby" + + for lang in ${expected_baseline_languages}; do + rule_name="${lang}/baseline/expected-extracted-files" + 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 + echo "Expected SARIF output to contain notification '${rule_name}', but found no such notification." + exit 1 + else + echo "Found notification '${rule_name}'." + fi + done