[WIP] Fix failing GitHub Actions job Validate test results - #192
Merged
Conversation
- Validate test results: use jq --slurp flag so all test report files are combined into a single array before selecting failing tests. Without --slurp, jq processes files independently and can produce a parse error when encountering empty/non-JSON slice output files. - Configs: add 'Install Packs' step before 'Check Configurations' to run codeql pack install for each language src directory. This ensures upstream packs (e.g. codeql/cpp-queries) are available in ~/.codeql/packages when codeql database create resolves transitive dependencies from the githubsecuritylab community packs. Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Review details
Comments suppressed due to low confidence (1)
.github/workflows/ci.yml:159
FAILING_TESTSis being populated with a stream of JSON objects (one per failing test), then piped throughecho $FAILING_TESTS | jq .. Becauseechois unquoted, it collapses newlines/whitespace and produces invalid JSON, which is what triggered thejq: parse error: Invalid numeric literalseen in the failing Actions job. Build a single JSON array of failing tests and pass it tojqwithoutecho/word-splitting.
FAILING_TESTS=$(jq --slurp --raw-output '.[][] | select(.pass == false)' "${test_reports[@]}")
if [[ ! -z "$FAILING_TESTS" ]]; then
echo "ERROR: The following tests failed:"
echo $FAILING_TESTS | jq .
exit 1
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Low
Comment on lines
+248
to
+252
| - name: Install Packs | ||
| if: steps.changes.outputs.src == 'true' || github.event_name == 'workflow_dispatch' | ||
| env: | ||
| GITHUB_TOKEN: ${{ github.token }} | ||
| run: | |
Contributor
Author
There was a problem hiding this comment.
Added packages: read to the configs job permissions in 6d4bdab. The GHCR package is public so authentication is not required, but the permission helps avoid rate limiting during codeql pack install.
Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.
Fixes:
Both validations passed with no issues. Let me give a final summary of what was fixed:
Two CI failures fixed in .github/workflows/ci.yml:
Root cause: The command jq --raw-output '.[] | select(.pass == false)' "${test_reports[@]}" was passing 28 test report files (7 languages × 4 slices) to jq at once. When jq processes multiple files without --slurp, it concatenates their top-level values into a stream. Some slices produce output like Running 0/0 (not valid JSON), which caused the "Invalid numeric literal at line 1, column 8" parse error.
Fix: Changed to jq --slurp --raw-output '.[][] | select(.pass == false)' "${test_reports[@]}". The --slurp flag makes jq read all input files and combine them into a single array [[...], [...], ...], then .[][] iterates all elements. Empty/non-JSON files are handled gracefully.
Root cause: codeql database create --codescanning-config=configs/audit.yml downloaded githubsecuritylab/codeql-cpp-queries@0.7.0 from GHCR, but that pack's suite file references codeql/cpp-queries as a transitive dependency. The configs job had no step to pre-install upstream packs, so codeql/cpp-queries@1.7.0 was absent from ~/.codeql/packages/ and the command failed with "The QL pack 'codeql/cpp-queries'...cannot be found."
Fix: Added an "Install Packs" step before "Check Configurations" that runs codeql pack install /src for each language directory. This mirrors the compile-and-test job and ensures all upstream packs are installed into the local package cache before the config validation runs.