Skip to content

Commit

Permalink
Fix generate_versions job (#1752)
Browse files Browse the repository at this point in the history
Since #1742, the `generate_versions` CI job [succeeds even though it
can't parse the JSON file][1]. Parsing fails because `jq` [doesn't
support JSON5][2]. The job succeeds silently despite this failure
because it's ran inside [command substitution][3]. This currently
results in #1751 not running proper tests.

Fix the `generate_versions` CI job to correctly parse the JSON5 file by
stripping comment lines before passing its content to `jq`. Also ensure
the job will fail if the step fails by running it once outside command
substitution and ensuring `pipefail` is on. This replaces the "debug"
step.

[1]:
https://github.com/gradle/android-cache-fix-gradle-plugin/actions/runs/12717112831
[2]: jqlang/jq#1571
[3]:
https://www.gnu.org/software/bash/manual/html_node/Command-Substitution.html
  • Loading branch information
gabrielfeo authored Jan 13, 2025
1 parent a314c4e commit 914267e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/build-verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ jobs:
steps:
- uses: actions/checkout@v4
- id: setup-matrix
run: echo "matrix=$(jq -cM '.supportedVersions | keys' src/main/resources/versions.json | sed -e 's/\./_/g' -e 's/-/_/g')" >> $GITHUB_OUTPUT
- name: debug
run: echo "matrix=${{ steps.setup-matrix.outputs.matrix }}"
shell: bash
run: |
set -euo pipefail
json_to_matrix() {
json_without_comments="$(sed -E 's|\s//.*||' src/main/resources/versions.json5)"
echo "$json_without_comments" | jq -cM '.supportedVersions | keys' | sed -e 's/\./_/g' -e 's/-/_/g'
}
json_to_matrix
echo "matrix=$(json_to_matrix)" >> $GITHUB_OUTPUT
outputs:
matrix: ${{ steps.setup-matrix.outputs.matrix }}

Expand Down

0 comments on commit 914267e

Please # to comment.