Conversation
A canary is a workflow to do something like test against this library. This is a non-production document, not intended for the average user, just documentation.
|
Claude finished @scottf's task in 1m 45s —— View job PR Review
The document is clear, well-structured, and the core logic (read 1. Shell injection risk in single-build 2. Hardcoded Everything else looks correct: the |
| JARVER=$(curl -sf https://raw.githubusercontent.com/nats-io/nats.java/main/build.gradle \ | ||
| | grep -oP 'def jarVersion\s*=\s*"\K[^"]+' | head -1) | ||
| VERSION="${JARVER}-SNAPSHOT" | ||
| fi |
There was a problem hiding this comment.
The sed command directly interpolates the GitHub Actions expression ${{ steps.v.outputs.version }} into the shell command text. If the version string were to contain shell metacharacters or # (the sed delimiter used here), it could break the command or, in a worst case, allow injection.
The resolve step correctly isolates user input via an env var (INPUT_VERSION). The single-build sed step should do the same:
| fi | |
| - name: Pin jnats ${{ steps.v.outputs.version }} for this run (not committed) | |
| env: | |
| JNATS_VERSION: ${{ steps.v.outputs.version }} | |
| run: sed -i "s#io.nats:jnats:[^'\"]*#io.nats:jnats:${JNATS_VERSION}#" build.gradle |
The matrix version already does this correctly (env: VERSION: ${{ needs.resolve.outputs.version }}).
| test: | ||
| needs: resolve | ||
| runs-on: ubuntu-latest | ||
| strategy: |
There was a problem hiding this comment.
The matrix job sets TARGET_COMPATIBILITY: ${{ matrix.tc }} (env var for Gradle) but hardcodes java-version: 25 for all matrix legs. If the goal is to test across different JDK versions (8, 17, 21, 25) — not just different --release compatibility flags — this should be java-version: ${{ matrix.tc }}.
If the intent is "compile with Java 25 but verify source compatibility at each level" (i.e., --release flag style), this is fine and should have a comment explaining that. As written, a reader who's adapting this for multi-JDK testing will silently always test under Java 25.
| strategy: | |
| - uses: actions/setup-java@v5 | |
| with: | |
| java-version: ${{ matrix.tc }} | |
| distribution: temurin |
(Or add a comment clarifying the hardcoded 25 is intentional.)
A canary is a workflow to do something like test against this library. This is a non-production document, not intended for the average user, just documentation.