Skip to content

fix(OPENFRAM-002-20): CU-17tkuw60605 2 review findings in JsonKafkaListener.java #9428

fix(OPENFRAM-002-20): CU-17tkuw60605 2 review findings in JsonKafkaListener.java

fix(OPENFRAM-002-20): CU-17tkuw60605 2 review findings in JsonKafkaListener.java #9428

Workflow file for this run

name: OpenFrame OSS Libs Test
permissions:
contents: read
pull-requests: read
on:
pull_request:
types: [opened, synchronize, ready_for_review, reopened, closed]
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
env:
REGISTRY: "com.openframe.oss"
ORGANISATION: ${{ github.repository_owner }}
REPOSITORY: "com/openframe/oss/${{ github.event.repository.name }}"
# =============================================================================
# JOBS
# =============================================================================
jobs:
changes:
name: Changes
uses: ./.github/workflows/changes.yaml
if: github.event.pull_request.state == 'open' && !github.event.pull_request.draft
scan:
name: "Scan Code"
runs-on: ubuntu-latest
needs: [changes]
permissions:
contents: read
packages: read
if: github.event_name == 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
persist-credentials: false
- name: Scan code
uses: ./.github/steps/trivy
with:
scan: code
test-java:
name: Test Java
runs-on: ubuntu-latest
needs: [changes]
if: fromJSON(needs.changes.outputs.changes || '{}').java == 'true'
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Java 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Cache Maven repository
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-
- name: Resolve PR Snapshot Version
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
URL="https://maven.pkg.github.com/${{ github.repository }}/${{ env.REPOSITORY }}/maven-metadata.xml"
OLD_VERSION=$(curl -sf -H "Authorization: token $GITHUB_TOKEN" "$URL" |
grep -oP '<version>\K[0-9]+\.[0-9]+\.[0-9]+(?=</version>)' | sort -V | tail -1)
echo "NEW_VERSION=${OLD_VERSION%.*}.$((${OLD_VERSION##*.} + 1))-${{ github.event.pull_request.number }}-SNAPSHOT" >> $GITHUB_ENV
- name: Build and Publish ${{ env.NEW_VERSION }}
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
mvn clean deploy \
-Drevision="${{ env.NEW_VERSION }}" \
-s .mvn/settings.xml \
--threads 2C \
--batch-mode \
--no-transfer-progress \
-Dmaven.source.skip=true
test-node:
name: Test Node (${{ matrix.name }})
runs-on: ubuntu-latest
needs: [changes]
# npm's defaults allow 970s of silence per hung registry socket; these bound it to 115s
env:
NPM_CONFIG_FETCH_TIMEOUT: 30000
NPM_CONFIG_FETCH_RETRY_MAXTIMEOUT: 15000
NPM_CONFIG_LOGLEVEL: http
strategy:
matrix:
include: ${{ fromJson(needs.changes.outputs.node_matrix) }}
steps:
- name: Check if should run
id: should_run
run: echo "run=${{ fromJSON(needs.changes.outputs.changes || '{}')[matrix.name] == 'true' }}" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
if: steps.should_run.outputs.run == 'true'
- name: Setup Node.js
if: steps.should_run.outputs.run == 'true'
uses: actions/setup-node@v4
with:
node-version: '22'
# Caches ~/.npm so a run does not re-download the whole tree.
# Keyed on package.json, NOT package-lock.json: this repo ignores
# lockfiles (.gitignore), so none is committed and pointing the key at
# one fails the step outright with "paths were not resolved".
cache: npm
cache-dependency-path: ${{ matrix.path }}/package.json
# Works around an Arborist bug in the npm version `actions/setup-node`'s
# Node 22 image currently bundles: resolving this project's tree with no
# lockfile to pin it (see the comment on Install Dependencies below)
# intermittently throws "Cannot read properties of null (reading
# 'edgesOut')" — reproduced on unrelated PRs the same day, not
# reproducible locally on npm 11.9.0. Pin removed once the bundled npm
# on that image picks up the fix upstream.
- name: Upgrade npm (workaround for a bundled-npm Arborist bug)
if: steps.should_run.outputs.run == 'true'
run: npm install -g npm@11.9.0
# `install`, not `ci`: `npm ci` requires a committed lockfile and this
# repo has none. The consequence is that CI resolves dependencies afresh
# and can test a different tree than a developer has — worth fixing, but
# by committing lockfiles, which is a repo-wide policy call.
- name: Install Dependencies
if: steps.should_run.outputs.run == 'true'
working-directory: ${{ matrix.path }}
run: npm install
# Config smoke first: it is ~1s and a broken eslint config makes every
# lint result below meaningless rather than failing honestly.
- name: Lint Config Smoke
if: steps.should_run.outputs.run == 'true'
working-directory: ${{ matrix.path }}
run: npm run lint:config-smoke
# No `continue-on-error` — a failing tsc MUST block the merge.
- name: Type Check
if: steps.should_run.outputs.run == 'true'
working-directory: ${{ matrix.path }}
run: npm run type-check
- name: Lint
if: steps.should_run.outputs.run == 'true'
working-directory: ${{ matrix.path }}
run: npm run lint
# Separate step, not folded into Lint: it needs a TypeScript program and
# an 8 GB heap, and it is the slowest check in the job. Keeping it apart
# makes a failure legible at a glance and lets the fast pass fail early.
- name: Lint (type-aware)
if: steps.should_run.outputs.run == 'true'
working-directory: ${{ matrix.path }}
run: npm run lint:types
- name: Format
if: steps.should_run.outputs.run == 'true'
working-directory: ${{ matrix.path }}
run: npm run format
- name: Test
if: steps.should_run.outputs.run == 'true'
working-directory: ${{ matrix.path }}
run: npm run test:run
- name: Build
if: steps.should_run.outputs.run == 'true'
working-directory: ${{ matrix.path }}
run: npm run build
- name: Resolve PR Version
if: steps.should_run.outputs.run == 'true'
working-directory: ${{ matrix.path }}
run: |
OLD_VERSION=$(npm view "$(jq -r .name package.json)" dist-tags.latest)
echo "NEW_VERSION=${OLD_VERSION%.*}.$((${OLD_VERSION##*.} + 1))-${{ github.event.pull_request.number }}.${{ github.run_number }}.${{ github.run_attempt }}" >> $GITHUB_ENV
- name: Check publish manifest
if: steps.should_run.outputs.run == 'true'
# No local (file:/link:/.yalc) specs may reach the registry - see the script.
run: node openframe-frontend-core/scripts/check-publish-manifest.mjs "${{ matrix.path }}/package.json"
- name: Publish ${{ env.NEW_VERSION }} (pr-${{ github.event.pull_request.number }} tag)
if: steps.should_run.outputs.run == 'true'
working-directory: ${{ matrix.path }}
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm version "${{ env.NEW_VERSION }}" --no-git-tag-version
npm publish --tag "pr-${{ github.event.pull_request.number }}" --ignore-scripts
# `lint:cycles` gets its OWN job, purely for wall-clock. It is graph-wide —
# a cycle is a property of the whole import graph, so it cannot be cached or
# narrowed to a diff — and on this runner it takes longer than every other
# step in `test-node` put together. Run sequentially it made a PR's checks
# ~16 min; run in parallel the two jobs overlap and the wall clock is roughly
# this job alone. The price is a second `npm install`: about a minute of
# machine time, none of it wall time.
#
# Keep it a REQUIRED check (it is in `all-checks` below). It sat misconfigured
# and reporting zero for months while a real cycle was in the tree, so a
# cheaper-looking arrangement that quietly drops it is the one thing to avoid.
test-node-cycles:
name: Test Node Cycles (${{ matrix.name }})
runs-on: ubuntu-latest
needs: [changes]
env:
NPM_CONFIG_FETCH_TIMEOUT: 30000
NPM_CONFIG_FETCH_RETRY_MAXTIMEOUT: 15000
NPM_CONFIG_LOGLEVEL: http
strategy:
matrix:
include: ${{ fromJson(needs.changes.outputs.node_matrix) }}
steps:
- name: Check if should run
id: should_run
run: echo "run=${{ fromJSON(needs.changes.outputs.changes || '{}')[matrix.name] == 'true' }}" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
if: steps.should_run.outputs.run == 'true'
- name: Setup Node.js
if: steps.should_run.outputs.run == 'true'
uses: actions/setup-node@v4
with:
node-version: '22'
cache: npm
cache-dependency-path: ${{ matrix.path }}/package.json
# See the identical step in test-node above for why this is here.
- name: Upgrade npm (workaround for a bundled-npm Arborist bug)
if: steps.should_run.outputs.run == 'true'
run: npm install -g npm@11.9.0
- name: Install Dependencies
if: steps.should_run.outputs.run == 'true'
working-directory: ${{ matrix.path }}
run: npm install
- name: Lint (import cycles)
if: steps.should_run.outputs.run == 'true'
working-directory: ${{ matrix.path }}
run: npm run lint:cycles
test-rust:
name: "Test Rust (${{ matrix.os }})"
needs: changes
if: fromJSON(needs.changes.outputs.changes || '{}').rust == 'true'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest]
defaults:
run:
shell: bash
env:
OPENFRAME_VERSION: 0.0.0-dev
CARGO_INCREMENTAL: 0
steps:
- uses: actions/checkout@v4
- name: Prepare Rust tools
uses: ./.github/steps/rust-setup
with:
path: clients/openframe-client
components: clippy,rustfmt
shared-key: openframe-client-${{ matrix.os }}
- name: Lint (cargo fmt --check + cargo clippy -D warnings)
run: make -C clients/openframe-client lint
- name: Build client binary
run: make -C clients/openframe-client build-bin
- name: Test
run: make -C clients/openframe-client test
cleanup:
name: Cleanup
if: github.event.pull_request.state != 'open'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.ref }}
- name: Delete PR ${{ github.event.pull_request.number }} java snapshots
env:
GH_TOKEN: ${{ github.token }}
SUFFIX: -${{ github.event.pull_request.number }}-SNAPSHOT
run: |
gh api "/orgs/${{ env.ORGANISATION }}/packages?package_type=maven" --paginate \
--jq '.[] | select(.name | startswith("${{ env.REGISTRY }}.")) | .name' |
while read -r PKG; do
gh api "/orgs/${{ env.ORGANISATION }}/packages/maven/$PKG/versions" --paginate \
--jq "[.[] | select(.name | endswith(\"$SUFFIX\"))] | .[].id" |
xargs -r -I{} gh api --silent -X DELETE "/orgs/${{ env.ORGANISATION }}/packages/maven/$PKG/versions/{}"
done
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Delete PR ${{ github.event.pull_request.number }} npm versions
working-directory: openframe-frontend-core
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
PKG=$(jq -r .name package.json)
npm dist-tag rm "$PKG" "pr-${{ github.event.pull_request.number }}" || true
npm view "$PKG" versions | grep -oE "[0-9.]+-${{ github.event.pull_request.number }}\.[0-9.]+" |
xargs -r -I{} npm unpublish "$PKG@{}"
all-checks:
name: "All Checks"
needs: [changes, test-java, test-node, test-node-cycles, test-rust]
runs-on: ubuntu-latest
if: |
always() &&
(contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || !contains(needs.*.result, 'skipped'))
steps:
- if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
run: exit 1
- run: echo "All checks passed"