Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions .github/workflows/codeql_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ jobs:
id: cache-codeql
uses: actions/cache@v4
with:
# A list of files, directories, and wildcard patterns to cache and restore
path: ${{github.workspace}}/codeql_home
# An explicit key for restoring and saving the cache
key: codeql-home-${{matrix.os}}-${{matrix.codeql_cli}}-${{matrix.codeql_standard_library}}

- name: Install CodeQL
Expand All @@ -83,7 +81,6 @@ jobs:
run: |
${{ github.workspace }}/codeql_home/codeql/codeql query compile --threads 0 ${{ matrix.language }}


- name: Run test suites
id: run-test-suites
env:
Expand Down Expand Up @@ -124,7 +121,6 @@ jobs:
print(f"Executing tests found (recursively) in the directory '{test_root}'")
files_to_close = []
try:
# XL runners have 8 cores, so split the tests into 8 "slices", and run one per thread
num_slices = 8
procs = []

Expand All @@ -139,12 +135,8 @@ jobs:
_, err = p.communicate()
if p.returncode != 0:
if p.returncode == 122:
# Failed because a test case failed, so just print the regular output.
# This will allow us to proceed to validate-test-results, which will fail if
# any test cases failed
print(f"{err.decode()}")
else:
# Some more serious problem occurred, so print and fail fast
print_error_and_fail(f"Failed to run tests with return code {p.returncode}\n{err.decode()}")
finally:
for file in files_to_close:
Expand All @@ -170,18 +162,20 @@ jobs:
with:
script: |
core.setFailed('Test run job failed')

- name: Collect test results
uses: actions/download-artifact@v4
uses: actions/download-artifact@v5

- name: Validate test results
run: |
for json_report in *-test-results-*/test_report_*
do
jq --raw-output '"PASS \(map(select(.pass == true)) | length)/\(length)'" $json_report\"" "$json_report"
jq --raw-output 'PASS \(map(select(.pass == true)) | length)/\(length)' $json_report
Copy link
Collaborator

@MichaelRFairhurst MichaelRFairhurst Aug 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pienso que la versión anterior es correcta. Sin embargo, es muy confundido con todos los quotes de tipos diferentes y escapados, y multiples lenguas.

Perdóname si este comento no sea útil. No estoy completamente seguro que intentaste commit este cambio, o si escribí demasiado 🤓 😄

El uno ' empieza una sección que BASH no interpreta, así que jq ve el doble ". Antes, el uno ' termina la que BASH no interpreta. Pero, el siguendo doble " indica una sección que interpreta BASH para expander $json_report, y tambien para que el escapado doble " se intepreta parte del texto. Esta seccion (de double ") termina antes del escapado ", y cumple el argumento que se pasara a jq. Es solamente un argumento, porque no hay un espacio entre ' y ". Por fin, "$json_report" simplemente es un argumento para jq, y esta quoted porque es práctica buena, en caso de $json_report tiene algunos espacios, BASH todavía pasara este filepath como un argumento singular.

El ultimo resulto es que jq ve argumentos asi:

  • $0 = jq
  • $1 = --raw-output
  • $2 = "PASS \(map(select.pass == true)) | length)/\(length) json_report_path.json"
  • $3 = json_report_path.json

Ahora solo que falta es saber que jq tiene strings también, y que el argumento segundo es un string así. En jq, se puede interpolate con el syntax "hello \(interpolated) world". Entonces, jq construye un string "PASS x/y json_report_path.json" y esto es la selección del query, y corre este query sobre el archivo json_report_path.json.

done
FAILING_TESTS=$(jq --raw-output '.[] | select(.pass == false)' *-test-results-*/test_report_*.json)
if [[ ! -z "$FAILING_TESTS" ]]; then
echo "ERROR: The following tests failed:"
echo $FAILING_TESTS | jq .
exit 1
fi

2 changes: 1 addition & 1 deletion .github/workflows/standard_library_upgrade_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ jobs:
python-version: "3.9"

- name: Collect test results
uses: actions/download-artifact@v4
uses: actions/download-artifact@v5

- name: Validate test results
shell: python
Expand Down