Skip to content

refactor(ui): fix the unused-vars and no-v-html findings of the dashboard #4282

refactor(ui): fix the unused-vars and no-v-html findings of the dashboard

refactor(ui): fix the unused-vars and no-v-html findings of the dashboard #4282

Workflow file for this run

# Builds and tests the project on pull requests, in the merge queue and on pushes to main.
#
# A pull request runs every light job. The merge queue runs them again on the merge group, scoped by the diff of the
# merge group the same way. Only the Build job is left to merge-queue.yml, because its shared workflow cannot run
# there. A push to main runs only what main needs: the Coverage (backend) and Coverage (frontend) jobs, which write
# the Gradle and npm caches and the Codecov base that pull requests read.
# Everything else was already proven by the pull request that merged. A nightly run and a manual run cover the whole
# workflow. The container images, the Helm chart, the HA smoke test and the dashboard end-to-end job are heavy and
# run from heavy.yml.
name: "CI"
on:
push:
branches: [ "main", "release/**" ]
pull_request:
branches: [ "main", "release/**" ]
# The merge queue. Every required check of this workflow has to report on the merge group, or the queue stalls.
merge_group:
types: [ "checks_requested" ]
# Nightly full run of this workflow on main, so main gets every job once a day even though a push runs a subset.
schedule:
- cron: "23 3 * * *"
workflow_dispatch:
permissions:
contents: read
# Opt-in for the Gradle jobs: set the repository variable INGOT_CI_MAVEN_MIRROR to route Maven Central through a mirror.
# Unset, every build resolves from Maven Central as before.
env:
INGOT_CI_MAVEN_MIRROR: ${{ vars.INGOT_CI_MAVEN_MIRROR }}
# Superseded pull request runs are cancelled. Runs on main, scheduled runs and manual runs are not: each one
# finishes its own work, so a later push cannot cut short the caches and the coverage base of an earlier one. A merge
# group has no pull request number and falls back to its ref, which is unique per queue entry, so entries never cancel
# each other.
concurrency:
group: "ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}"
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
# Baseline build on the minimum supported JDK. The project compiles with
# sourceCompatibility/targetCompatibility 17, so 17 is what has to keep working.
build:
name: "Build"
# Pull requests only, as the name gradle-build-pr says. In the merge queue merge-queue.yml reports this job's
# required check, "Build / Aggregate test results", because the filter below cannot run on a merge group.
#
# Its first job runs dorny/paths-filter without a checkout, which works on pull_request because the action
# asks the API for the changed files, and fails on push because there it needs a
# working copy to diff. A failing filter job takes the build with it, since the build
# job's `if` carries no status function and is therefore implicitly gated on success.
#
# Pushes to main are covered by the Coverage job below, which builds and runs the full
# backend suite. Drop this condition once the shared workflow checks out before
# filtering.
if: github.event_name == 'pull_request'
# gradle-build-pr.yml publishes the JUnit results as a check and a PR comment, so it
# declares checks: write and pull-requests: write on that job. A called workflow cannot
# request more than the caller granted, and the repository default here is
# contents: read, so without this block GitHub rejects the whole run during startup
# validation rather than failing a job. That is why it reported startup_failure and
# never produced a single log line.
permissions:
contents: read
checks: write
pull-requests: write
uses: OneLiteFeatherNET/workflows/.github/workflows/gradle-build-pr.yml@6eca5b5d8612ab1aac0f0f25248cd44ff9594886 # v2.4.0
with:
java-version: "17"
java-distribution: "temurin"
# Compile and unit tests only. `build` also made javadoc, the shadow jar and the distributions, about 80 seconds
# that no test needs. The container images job builds the jar. The integration suite is left to main and to a
# maintainer's request. Both task names are excluded: `integration` is the suite itself and `integrationTest` is
# its alias, which would otherwise run the full suite again.
gradle-task: "test -x integration -x integrationTest"
# The default 3-OS matrix is narrowed to Linux on purpose: the backend integration
# tests use Testcontainers, and only the ubuntu runners ship a usable Docker daemon.
runs-on: '["ubuntu-latest"]'
secrets: inherit
# Ingot ships as FOSS, so a dependency whose licence changes under us is a release
# blocker rather than a footnote. ApexCharts is the case this exists for: same package
# id, new licence, one Renovate bump. Both halves of the product are checked, because
# the JVM and npm trees fail in completely different ways.
licenses:
name: "Licenses"
needs: coverage-changes
if: ${{ !cancelled() && github.event_name != 'push' && (needs.coverage-changes.result != 'success' || needs.coverage-changes.outputs.unit == 'true') }}
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: "Checkout repository"
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: "Validate Gradle wrapper"
uses: gradle/actions/wrapper-validation@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
- name: "Set up Java"
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
with:
java-version: "21"
distribution: "temurin"
- name: "Set up Gradle"
uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
- name: "Route Maven Central through the CI mirror"
if: ${{ vars.INGOT_CI_MAVEN_MIRROR != '' }}
run: |
mkdir -p "$HOME/.gradle/init.d"
cp .github/gradle/ci-maven-mirror.init.gradle "$HOME/.gradle/init.d/"
- name: "Check backend dependency licenses"
run: ./gradlew --build-cache :reposilite-backend:checkLicense
- name: "Set up Node"
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: "24"
cache: "npm"
cache-dependency-path: "reposilite-frontend/package-lock.json"
- name: "Install frontend dependencies"
working-directory: reposilite-frontend
run: npm ci
# Checks the registry signatures and provenance attestations of what npm ci installed.
# The lockfile hashes only prove the bytes did not change since the lockfile was written.
- name: "Verify frontend package signatures"
working-directory: reposilite-frontend
run: npm audit signatures
- name: "Check frontend dependency licenses"
working-directory: reposilite-frontend
run: npm run license-check
# Own job rather than steps in Licenses, so a lint failure shows as its own check and does not hide
# the licence result. ESLint is in its warn phase: findings are printed in the log and only a broken
# configuration fails the job. The unit tests run in Coverage (frontend), once, with coverage.
frontend:
name: "Frontend"
needs: coverage-changes
if: ${{ !cancelled() && github.event_name != 'push' && (needs.coverage-changes.result != 'success' || (needs.coverage-changes.outputs.frontend == 'true' || (needs.coverage-changes.outputs.image == 'true' && needs.coverage-changes.outputs.chart == 'true'))) }}
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: "Checkout repository"
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: "Set up Node"
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: "24"
cache: "npm"
cache-dependency-path: "reposilite-frontend/package-lock.json"
- name: "Install frontend dependencies"
working-directory: reposilite-frontend
run: npm ci
- name: "Lint the frontend"
working-directory: reposilite-frontend
run: npm run eslint
- name: "Type-check the frontend"
working-directory: reposilite-frontend
run: npm run typecheck
# Nothing checked dependencies for known advisories before this, which is how 67 of them
# accumulated unnoticed across the JVM and npm trees. Renovate raises versions but says
# nothing about whether the current ones are exploitable, and the licence gate next to
# this one answers a different question entirely.
vulnerabilities:
name: "Vulnerabilities"
needs: coverage-changes
if: ${{ !cancelled() && github.event_name != 'push' && (needs.coverage-changes.result != 'success' || needs.coverage-changes.outputs.unit == 'true') }}
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: "Checkout repository"
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: "Validate Gradle wrapper"
uses: gradle/actions/wrapper-validation@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
- name: "Set up Java"
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
with:
java-version: "21"
distribution: "temurin"
- name: "Set up Gradle"
uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
- name: "Route Maven Central through the CI mirror"
if: ${{ vars.INGOT_CI_MAVEN_MIRROR != '' }}
run: |
mkdir -p "$HOME/.gradle/init.d"
cp .github/gradle/ci-maven-mirror.init.gradle "$HOME/.gradle/init.d/"
# Trivy reads lockfiles, and a Gradle build without dependency locking has none. The
# task copies the resolved runtime classpath out so the jars can be identified by
# checksum instead.
- name: "Collect the resolved runtime dependencies"
run: ./gradlew --build-cache :reposilite-backend:collectRuntimeDependencies
- name: "Scan the backend dependencies"
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
scan-type: rootfs
scan-ref: reposilite-backend/build/dependency-jars
scanners: vuln
severity: CRITICAL,HIGH,MEDIUM
exit-code: "1"
- name: "Scan the frontend dependencies"
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
scan-type: fs
scan-ref: reposilite-frontend/package-lock.json
scanners: vuln
severity: CRITICAL,HIGH,MEDIUM
exit-code: "1"
# The release job generates, validates and attests the same two SBOMs, but only for a release. This job runs the
# generation and the validation on each pull request, so that a generator which breaks is found by the pull request
# that breaks it. It only reads the repository: no identity token and no write permission.
sbom:
name: "SBOM"
needs: coverage-changes
if: ${{ !cancelled() && github.event_name != 'push' && (needs.coverage-changes.result != 'success' || needs.coverage-changes.outputs.unit == 'true') }}
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: "Checkout repository"
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: "Set up Java"
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
with:
java-version: "21"
distribution: "temurin"
- name: "Set up Gradle"
uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
- name: "Route Maven Central through the CI mirror"
if: ${{ vars.INGOT_CI_MAVEN_MIRROR != '' }}
run: |
mkdir -p "$HOME/.gradle/init.d"
cp .github/gradle/ci-maven-mirror.init.gradle "$HOME/.gradle/init.d/"
- name: "Generate the SBOM of the standalone jar"
run: ./gradlew --build-cache :reposilite-backend:cyclonedxDirectBom
- name: "Set up Node"
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: "24"
# The same pinned generator as the release job, see there for why --flatten-components is needed.
- name: "Generate the SBOM of the dashboard"
working-directory: reposilite-frontend
env:
CYCLONEDX_NPM_VERSION: "6.0.1"
run: |
set -euo pipefail
mkdir -p "$GITHUB_WORKSPACE/build/sbom"
npx --yes "@cyclonedx/cyclonedx-npm@${CYCLONEDX_NPM_VERSION}" \
--package-lock-only --omit dev --flatten-components \
--spec-version 1.6 --output-format JSON \
--output-file "$GITHUB_WORKSPACE/build/sbom/ingot-frontend.cdx.json"
- name: "Set up Python"
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version: "3.12"
- name: "Install the SBOM validation dependencies"
run: python3 -m pip install "jsonschema==4.26.0"
- name: "Validate the SBOMs"
run: python3 .github/scripts/verify_sbom.py build/sbom/*.cdx.json
# Decides which coverage jobs have to run. Pull requests that only touch documentation, OpenSpec
# proposals or repository metadata skip all of them. A pull request that only touches the dashboard
# skips the full backend suite and runs only the backend tests that serve the dashboard. Pushes always
# run everything, and so does any path the deny list in ci_scope.sh does not name.
coverage-changes:
name: "Detect coverage changes"
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
backend: ${{ steps.filter.outputs.backend }}
frontend: ${{ steps.filter.outputs.frontend }}
frontend_only: ${{ steps.filter.outputs.frontend_only }}
image: ${{ steps.filter.outputs.image }}
chart: ${{ steps.filter.outputs.chart }}
e2e: ${{ steps.filter.outputs.e2e }}
unit: ${{ steps.filter.outputs.unit }}
steps:
- name: "Checkout repository"
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
# Both ends of the pull request or the merge group have to be present for the diff below.
fetch-depth: 0
# A merge group is scoped like a pull request, from the diff of its base to its head.
- name: "Check which coverage jobs are needed"
id: filter
env:
EVENT: ${{ github.event_name }}
BASE: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha }}
HEAD: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}
run: |
set -euo pipefail
# Every coverage job runs in full. Used whenever the answer is not known, so a failed
# detection can never skip a test.
full_run() {
echo "$1, running every coverage job."
echo "backend=true" >> "$GITHUB_OUTPUT"
echo "frontend=true" >> "$GITHUB_OUTPUT"
echo "frontend_only=false" >> "$GITHUB_OUTPUT"
echo "image=true" >> "$GITHUB_OUTPUT"
echo "chart=true" >> "$GITHUB_OUTPUT"
echo "e2e=true" >> "$GITHUB_OUTPUT"
echo "unit=true" >> "$GITHUB_OUTPUT"
exit 0
}
# Pushes to main always run everything.
if [ "$EVENT" != "pull_request" ] && [ "$EVENT" != "merge_group" ]; then
full_run "Not a pull request or a merge group"
fi
# A missing or unreadable range is no reason to skip the tests.
if [ -z "$BASE" ] || [ -z "$HEAD" ] \
|| ! git cat-file -e "${BASE}^{commit}" 2>/dev/null \
|| ! git cat-file -e "${HEAD}^{commit}" 2>/dev/null; then
full_run "No usable pull request range"
fi
# Three dots diff against the merge base, so commits that reached main after this branch
# was cut do not count as changes of this pull request.
if ! git diff --name-only "$BASE...$HEAD" > "$RUNNER_TEMP/changed.txt"; then
full_run "Could not diff the pull request"
fi
bash .github/scripts/ci_scope.sh < "$RUNNER_TEMP/changed.txt" >> "$GITHUB_OUTPUT"
# Backend coverage. It is gated on coverage-changes, and a job skipped by its `if` counts as success
# for the aggregate Coverage check below. The condition only skips when coverage-changes succeeded and
# found no backend change. A failed detection runs the full suite, and the !cancelled() guard keeps a
# cancelled run from starting the job.
#
# A dashboard-only pull request runs the backend tests that serve the dashboard, because the server
# bundles and serves the built frontend. Any other pull request runs the backend tests its change can
# reach (select_backend_tests.py), or the full suite when the selection says so. Only a full run uploads to
# Codecov, since a partial report would misstate the coverage Codecov shows for the default branch.
coverage-backend:
name: "Coverage (backend)"
needs: coverage-changes
if: ${{ !cancelled() && (needs.coverage-changes.result != 'success' || needs.coverage-changes.outputs.backend == 'true') }}
runs-on: ubuntu-latest
permissions:
contents: read
env:
# Trial: four integration forks instead of the two that half of the four runner cores give. Every fork starts its
# own MariaDB, PostgreSQL, S3, NATS and Valkey containers, so memory scales with it. Read by integrationForks() in
# build.gradle.kts.
INGOT_TEST_FORKS: "4"
steps:
- name: "Checkout repository"
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
# Full history so Codecov can attribute coverage to the right commits. The build
# itself no longer needs tags: the version is a literal in build.gradle.kts.
fetch-depth: 0
- name: "Validate Gradle wrapper"
uses: gradle/actions/wrapper-validation@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
- name: "Set up Java"
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
with:
java-version: "21"
distribution: "temurin"
- name: "Set up Gradle"
uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
- name: "Route Maven Central through the CI mirror"
if: ${{ vars.INGOT_CI_MAVEN_MIRROR != '' }}
run: |
mkdir -p "$HOME/.gradle/init.d"
cp .github/gradle/ci-maven-mirror.init.gradle "$HOME/.gradle/init.d/"
# Decides which backend tests a pull request can reach (select_backend_tests.py, design Decision 3). Only a pull
# request gets a partial run. A push to main, a missing diff and a failing script all give mode=full, so the
# full suite and the Codecov upload run. The dashboard-only path below keeps its own decision. A merge group is
# selected like a pull request, from its own diff.
- name: "Select the backend tests"
id: select
if: ${{ needs.coverage-changes.outputs.frontend_only != 'true' }}
env:
EVENT: ${{ github.event_name }}
BASE: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha }}
HEAD: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}
run: |
selection="$RUNNER_TEMP/backend-selection.txt"
changed="$RUNNER_TEMP/backend-changed.txt"
if [ "$EVENT" != "pull_request" ] && [ "$EVENT" != "merge_group" ]; then
printf '%s\n' "mode=full" "reason=not a pull request or a merge group" > "$selection"
elif [ -z "$BASE" ] || [ -z "$HEAD" ] || ! git diff --name-only "$BASE...$HEAD" > "$changed"; then
printf '%s\n' "mode=full" "reason=the pull request diff is not available" > "$selection"
elif ! python3 .github/scripts/select_backend_tests.py < "$changed" > "$selection"; then
printf '%s\n' "mode=full" "reason=the selection script failed" > "$selection"
fi
mode="$(sed -n 's/^mode=//p' "$selection" | head -n 1)"
case "$mode" in
full|partial) ;;
*) mode=full ;;
esac
echo "mode=$mode" >> "$GITHUB_OUTPUT"
{
echo "## Backend test selection"
echo
echo "- Mode: \`$mode\`"
sed -n 's/^reason=/- Reason: /p' "$selection"
sed -n 's/^package=\(.*\)$/- Package: `\1`/p' "$selection"
} >> "$GITHUB_STEP_SUMMARY"
# The backend unit tests the pull request can reach. The smoke set is always in the filters. A pull request runs no
# integration test: that suite starts containers and takes about two hours, so it runs on main and when a
# maintainer asks for it. A partial run builds no coverage report and uploads nothing.
- name: "Run the selected backend tests"
if: ${{ needs.coverage-changes.outputs.frontend_only != 'true' && steps.select.outputs.mode == 'partial' }}
run: |
selection="$RUNNER_TEMP/backend-selection.txt"
test_args=()
while IFS= read -r pattern; do test_args+=(--tests "$pattern"); done < <(sed -n 's/^test=//p' "$selection")
if [ "${#test_args[@]}" -eq 0 ]; then
echo "::error::The selection named no filter for the unit tests."
exit 1
fi
./gradlew --build-cache :reposilite-backend:test "${test_args[@]}"
# The backend unit tests that serve the dashboard. The filters select the frontend package and the dashboard policy.
- name: "Run the dashboard tests of the backend"
if: ${{ needs.coverage-changes.outputs.frontend_only == 'true' }}
run: |
./gradlew --build-cache :reposilite-backend:test --tests 'com.reposilite.frontend.*' --tests 'net.onelitefeather.ingot.web.DashboardPolicyTest'
# A pull request or a merge group that the selection sends to the full suite runs every unit test, with no report
# and no upload. Only main writes the Codecov base.
- name: "Run the backend unit tests"
if: ${{ (github.event_name == 'pull_request' || github.event_name == 'merge_group') && needs.coverage-changes.outputs.frontend_only != 'true' && steps.select.outputs.mode == 'full' }}
run: ./gradlew --build-cache :reposilite-backend:test
- name: "Run tests with coverage"
if: ${{ github.event_name != 'pull_request' && github.event_name != 'merge_group' && needs.coverage-changes.outputs.frontend_only != 'true' && steps.select.outputs.mode == 'full' }}
run: ./gradlew --build-cache :reposilite-backend:testCoverage
- name: "Upload coverage to Codecov"
if: ${{ github.event_name != 'pull_request' && github.event_name != 'merge_group' && needs.coverage-changes.outputs.frontend_only != 'true' && steps.select.outputs.mode == 'full' }}
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v6.0.2
with:
files: "./reposilite-backend/build/reports/jacoco/reposilite-backend-report.xml"
fail_ci_if_error: false
# Tokenless uploads are rate limited. Set CODECOV_TOKEN in the repository secrets,
# or drop this input together with codecov.yml if coverage reporting is not wanted.
token: ${{ secrets.CODECOV_TOKEN }}
# Frontend coverage. The dashboard suite runs here and nowhere else, so a pull request that does not
# touch reposilite-frontend/ does not run it. The report is an artifact, not a Codecov upload.
#
# A pull request runs only the tests that reach its changed modules, found by vitest related. frontend_scope.sh
# widens that to the full suite whenever a change could reach a test the module graph does not show. A push
# runs in full, and so does a related run that reaches no test. A partial report is published under its own
# artifact name, so nobody reads a partial percentage as the full suite.
coverage-frontend:
name: "Coverage (frontend)"
needs: coverage-changes
if: ${{ !cancelled() && (needs.coverage-changes.result != 'success' || needs.coverage-changes.outputs.frontend == 'true') }}
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: "Checkout repository"
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
# Both ends of the pull request have to be present for the diff below.
fetch-depth: 0
- name: "Set up Node"
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: "24"
cache: "npm"
cache-dependency-path: "reposilite-frontend/package-lock.json"
- name: "Install frontend dependencies"
working-directory: reposilite-frontend
run: npm ci
- name: "Decide which frontend tests the change needs"
id: scope
env:
EVENT: ${{ github.event_name }}
BASE: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha }}
HEAD: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}
run: |
set -uo pipefail
# The full suite unless a pull request or merge group diff is readable and the script can place every change.
result="frontend_scope=full"
if { [ "$EVENT" = "pull_request" ] || [ "$EVENT" = "merge_group" ]; } \
&& [ -n "$BASE" ] && [ -n "$HEAD" ] \
&& git cat-file -e "${BASE}^{commit}" && git cat-file -e "${HEAD}^{commit}" \
&& git diff --name-status "$BASE...$HEAD" > "$RUNNER_TEMP/name-status.txt"; then
result=$(bash .github/scripts/frontend_scope.sh "$RUNNER_TEMP/frontend-scope" < "$RUNNER_TEMP/name-status.txt") \
|| result="frontend_scope=full"
fi
echo "$result" >> "$GITHUB_OUTPUT"
- name: "Run the frontend unit tests with coverage"
id: run
working-directory: reposilite-frontend
env:
SCOPE: ${{ steps.scope.outputs.frontend_scope }}
SCOPE_DIR: ${{ runner.temp }}/frontend-scope
run: |
set -uo pipefail
if [ "$SCOPE" = "related" ]; then
mapfile -t targets < <(cat "$SCOPE_DIR/related.txt" "$SCOPE_DIR/readers.txt")
status=0
npx vitest related "${targets[@]}" --run --coverage --maxWorkers=2 \
--reporter=default --reporter=json --outputFile.json="$RUNNER_TEMP/related.json" || status=$?
# Tests reached through the graph, not counting the reader tests that always run. Zero, or a
# missing report, means nothing was proven, so the full suite runs below.
graph=$(jq --rawfile readers "$SCOPE_DIR/readers.txt" \
'($readers | split("\n") | map(select(. != ""))) as $fs
| [.testResults[].name | sub(".*/reposilite-frontend/"; "")] - $fs | length' \
"$RUNNER_TEMP/related.json" 2>/dev/null || echo 0)
if [ "$graph" != "0" ]; then
echo "effective=related" >> "$GITHUB_OUTPUT"
exit "$status"
fi
echo "No test reaches the changed modules through the module graph, running the full frontend suite."
fi
echo "effective=full" >> "$GITHUB_OUTPUT"
npm run test:coverage
- name: "Publish the frontend coverage report"
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
# A partial run gets its own name, so its percentages are never mistaken for the full suite.
name: ${{ steps.run.outputs.effective == 'related' && 'frontend-coverage-partial' || 'frontend-coverage' }}
path: reposilite-frontend/coverage
retention-days: 7
if-no-files-found: ignore
# The required status check. Its name is exactly "Coverage", which the ruleset requires, so it stays one
# job while the work is split above. It runs even when a needed job was skipped, and fails only when a
# needed job failed or was cancelled. A skipped job counts as success, as it did before the split.
coverage:
name: "Coverage"
needs: [coverage-backend, coverage-frontend]
if: ${{ always() }}
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: "Check the coverage jobs"
env:
BACKEND: ${{ needs.coverage-backend.result }}
FRONTEND: ${{ needs.coverage-frontend.result }}
run: |
for result in "$BACKEND" "$FRONTEND"; do
case "$result" in
success|skipped) ;;
*) echo "::error::A coverage job ended with '$result'."; exit 1 ;;
esac
done
# A plugin written for Reposilite 3.5.28 has to keep running on Ingot, and nothing else checks that. The job compares
# the plugin API with 3.5.28, starts a fresh server with the upstream jars of two bundled plugins, and compiles and
# tests the bundled plugins, whose sources are the 3.5.28 sources today.
#
# Report only: a finding in the binary report and a failing canary do not fail this job. The gate becomes blocking in
# a later change, once the first report has been triaged. The bundled plugin tests are ordinary tests and still do.
#
# The slim plugin API jar (openspec change add-plugin-api-artifact) is blocking: its closure check and the consumer
# fixture that compiles against it fail this job.
plugin-api:
name: "Plugin API"
needs: coverage-changes
if: ${{ !cancelled() && github.event_name != 'push' && (needs.coverage-changes.result != 'success' || needs.coverage-changes.outputs.unit == 'true') }}
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: "Checkout repository"
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
# The base commit has to be present for the diff of the bundled plugin sources further down.
fetch-depth: 0
- name: "Validate Gradle wrapper"
uses: gradle/actions/wrapper-validation@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
- name: "Set up Java"
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
with:
java-version: "21"
distribution: "temurin"
- name: "Set up Gradle"
uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
- name: "Route Maven Central through the CI mirror"
if: ${{ vars.INGOT_CI_MAVEN_MIRROR != '' }}
run: |
mkdir -p "$HOME/.gradle/init.d"
cp .github/gradle/ci-maven-mirror.init.gradle "$HOME/.gradle/init.d/"
- name: "Compare the plugin API with Reposilite 3.5.28"
run: ./gradlew --build-cache :reposilite-backend:pluginApiReport
- name: "Build the slim plugin API jar and check its closure"
run: ./gradlew --build-cache :reposilite-backend:pluginApiClosure
- name: "Run the consumer fixture against the slim plugin API jar"
run: ./gradlew --build-cache :reposilite-test:plugin-api-consumer:test
# The releases repository asks for credentials even to read the baseline. Without them, as in a fork, the report
# skips itself and says so in the job log. Report-only: a finding or a failed comparison does not fail the job.
- name: "Compare the Ingot plugin API with the last Ingot release"
id: ingot
continue-on-error: true
env:
ONELITEFEATHER_MAVEN_USERNAME: ${{ secrets.ONELITEFEATHER_MAVEN_USERNAME }}
ONELITEFEATHER_MAVEN_PASSWORD: ${{ secrets.ONELITEFEATHER_MAVEN_PASSWORD }}
run: ./gradlew --build-cache :reposilite-backend:ingotPluginApiReport
- name: "Run the upstream plugin canaries"
id: canaries
continue-on-error: true
run: ./gradlew --build-cache :reposilite-backend:integration --tests '*UpstreamPluginCanary*'
- name: "Test the bundled plugins"
run: ./gradlew --build-cache :reposilite-plugins:checksum-plugin:test :reposilite-plugins:migration-plugin:test
# The release job publishes the bundle, the libraries and the slim plugin API jar. Writing their POMs here catches
# a publication that cannot be written before a release does.
- name: "Generate the POM of every publication"
run: ./gradlew --build-cache generatePublicationPoms
- name: "Write the results to the job summary"
if: always()
env:
BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha }}
CANARY_OUTCOME: ${{ steps.canaries.outcome }}
run: |
{
echo "## Plugin API"
echo
if [ -f reposilite-backend/build/reports/plugin-api/report.md ]; then
cat reposilite-backend/build/reports/plugin-api/report.md
else
echo "The binary report was not produced. See the job log."
fi
echo
echo "## Upstream plugin canaries"
echo
echo "Step outcome: \`${CANARY_OUTCOME}\`. Each canary loads the jar that upstream published for 3.5.28 into a fresh server."
echo
} >> "$GITHUB_STEP_SUMMARY"
python3 - >> "$GITHUB_STEP_SUMMARY" <<'PY'
import glob
import xml.etree.ElementTree as ET
rows = []
for path in sorted(glob.glob("reposilite-backend/build/test-results/integration/*UpstreamPluginCanary*.xml")):
for case in ET.parse(path).getroot().iter("testcase"):
failed = case.find("failure") is not None or case.find("error") is not None
rows.append(f"| {case.get('name')} | {'failed' if failed else 'passed'} |")
if rows:
print("| Test | Result |")
print("| --- | --- |")
print("\n".join(rows))
else:
print("No canary results were produced. See the job log.")
PY
changed=$(git diff --name-only "$BASE_SHA" HEAD -- reposilite-plugins/checksum-plugin/src/main reposilite-plugins/migration-plugin/src/main)
if [ -n "$changed" ]; then
{
echo
echo "## Bundled plugin sources changed"
echo
echo "This pull request edits the sources of a bundled plugin. An edit there can hide a break of the plugin API, so read the binary report above closely."
echo
echo "$changed" | sed 's/^/- `/; s/$/`/'
} >> "$GITHUB_STEP_SUMMARY"
fi
- name: "Write the Ingot plugin API to the job summary"
if: always()
env:
INGOT_OUTCOME: ${{ steps.ingot.outcome }}
run: |
{
echo "## Ingot plugin API"
echo
} >> "$GITHUB_STEP_SUMMARY"
report=reposilite-backend/build/reports/plugin-api/ingot-report.md
if [ -f "$report" ]; then
python3 .github/scripts/plugin_api_summary.py "$report" >> "$GITHUB_STEP_SUMMARY" || echo "The Ingot report could not be summarised. See the job log." >> "$GITHUB_STEP_SUMMARY"
else
echo "No Ingot report was written (step outcome: \`${INGOT_OUTCOME}\`). Without the credentials of the releases repository the step skips. See the job log." >> "$GITHUB_STEP_SUMMARY"
fi
- name: "Publish the HTML report"
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: plugin-api-report
path: reposilite-backend/build/reports/plugin-api/
retention-days: 7
if-no-files-found: ignore
# The contract tests of the Official plugins boot a server with the shipped jar of each plugin and check what the plugin
# promises. They are blocking, unlike the report-only Plugin API job, which watches the upstream 3.5.28 jars.
plugin-contracts:
name: "Plugin contract tests"
if: ${{ !cancelled() && github.event_name != 'push' }}
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: "Checkout repository"
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: "Validate Gradle wrapper"
uses: gradle/actions/wrapper-validation@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
- name: "Set up Java"
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
with:
java-version: "21"
distribution: "temurin"
- name: "Set up Gradle"
uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
- name: "Route Maven Central through the CI mirror"
if: ${{ vars.INGOT_CI_MAVEN_MIRROR != '' }}
run: |
mkdir -p "$HOME/.gradle/init.d"
cp .github/gradle/ci-maven-mirror.init.gradle "$HOME/.gradle/init.d/"
- name: "Run the contract tests of the Official plugins"
run: ./gradlew --build-cache :reposilite-plugins:checksum-plugin:contractTest :reposilite-plugins:migration-plugin:contractTest
# Every plugin module declares the tier its sources back up: an opt-in to an experimental Ingot API needs the
# EXPERIMENTAL declaration, and the declaration needs the opt-in. It reads sources only, so it runs on every pull
# request and on the nightly run, and it is blocking through Light checks.
plugin-tiers:
name: "Plugin tiers"
if: ${{ !cancelled() && github.event_name != 'push' }}
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: "Checkout repository"
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: "Validate Gradle wrapper"
uses: gradle/actions/wrapper-validation@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
- name: "Set up Java"
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
with:
java-version: "21"
distribution: "temurin"
- name: "Set up Gradle"
uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
- name: "Route Maven Central through the CI mirror"
if: ${{ vars.INGOT_CI_MAVEN_MIRROR != '' }}
run: |
mkdir -p "$HOME/.gradle/init.d"
cp .github/gradle/ci-maven-mirror.init.gradle "$HOME/.gradle/init.d/"
- name: "Check the plugin tiers"
run: ./gradlew --build-cache checkPluginTiers
# The release runs the Gradle publish task for every project, and no other job builds a publication, so a module whose
# publication points at an artifact the build no longer produces is found only by the release. This publishes into a
# throwaway local repository instead. It covers every project, so the set matches the release.
publications:
name: "Publications"
if: ${{ !cancelled() && github.event_name != 'push' }}
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: "Checkout repository"
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: "Validate Gradle wrapper"
uses: gradle/actions/wrapper-validation@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
- name: "Set up Java"
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
with:
java-version: "21"
distribution: "temurin"
- name: "Set up Gradle"
uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
- name: "Route Maven Central through the CI mirror"
if: ${{ vars.INGOT_CI_MAVEN_MIRROR != '' }}
run: |
mkdir -p "$HOME/.gradle/init.d"
cp .github/gradle/ci-maven-mirror.init.gradle "$HOME/.gradle/init.d/"
- name: "Publish into a throwaway local repository"
run: ./gradlew --build-cache publishToMavenLocal -Dmaven.repo.local="$RUNNER_TEMP/m2"
# The workflow script tests used to run only inside the container images job, which is heavy. A change to a workflow
# or a workflow script is the one that can break them, and the scope step turns the image and chart flags on together
# only for a path it cannot place, which is what an edit under .github is. They need no Docker and no network.
script-tests:
name: "Workflow script tests"
needs: coverage-changes
if: ${{ !cancelled() && github.event_name != 'push' && (needs.coverage-changes.result != 'success' || (needs.coverage-changes.outputs.image == 'true' && needs.coverage-changes.outputs.chart == 'true')) }}
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: "Checkout repository"
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: "Set up Python"
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version: "3.12"
# The workflow script tests import PyYAML and the SBOM validation tests import jsonschema, neither of which the
# runner image guarantees. The versions are pinned like the chart job.
- name: "Install test dependencies"
run: python3 -m pip install "pyyaml==6.0.3" "jsonschema==4.26.0"
- name: "Run the workflow script tests"
run: python3 -m unittest discover -s .github/scripts/tests -t .github/scripts/tests -v
# The guide tests check the GitBook pages against docs/gitbook/SUMMARY.md. They used to run only in the heavy
# Helm chart job, so a docs change that moved a page passed every pull request. They need nothing but PyYAML, so
# they run here on every pull request.
docs-tests:
name: "Docs tests"
if: ${{ !cancelled() && github.event_name != 'push' }}
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: "Checkout repository"
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: "Set up Python"
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version: "3.12"
- name: "Install test dependencies"
run: python3 -m pip install "pyyaml==6.0.3"
- name: "Run the docs guide tests"
run: python3 -m unittest discover -s charts/ingot/tests -t charts/ingot/tests -p 'test_*guides.py' -v
# Decides whether the pull request changes the Helm chart. Only a change under charts/ counts. A diff that cannot be
# read counts as a change, so the lint below is never skipped by accident.
chart-changes:
name: "Detect chart changes"
if: ${{ !cancelled() && github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
chart: ${{ steps.filter.outputs.chart }}
steps:
- name: "Checkout repository"
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
# Both ends of the pull request have to be present for the diff below.
fetch-depth: 0
persist-credentials: false
- name: "Check whether the chart changed"
id: filter
env:
BASE: ${{ github.event.pull_request.base.sha }}
HEAD: ${{ github.event.pull_request.head.sha }}
run: |
set -euo pipefail
if ! git diff --name-only "$BASE...$HEAD" > "$RUNNER_TEMP/changed.txt"; then
echo "chart=true" >> "$GITHUB_OUTPUT"
echo "Could not diff the pull request, running the chart lint." >&2
elif grep -q '^charts/' "$RUNNER_TEMP/changed.txt"; then
echo "chart=true" >> "$GITHUB_OUTPUT"
else
echo "chart=false" >> "$GITHUB_OUTPUT"
fi
# The pre-cluster part of the Helm chart job in heavy.yml, run on every pull request that changes charts/. The
# cluster install and the image smoke test stay label-gated in heavy.yml. This job is not a required check.
chart-lint:
name: "Chart lint"
needs: [ chart-changes ]
if: ${{ !cancelled() && github.event_name == 'pull_request' && (needs.chart-changes.result != 'success' || needs.chart-changes.outputs.chart == 'true') }}
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read
steps:
- name: "Checkout repository"
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
persist-credentials: false
- name: "Set up Helm"
uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5.0.1
with:
version: v4.3.0
- name: "Set up Python"
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version: "3.12"
- name: "Install the chart test dependencies"
run: python3 -m pip install "pyyaml==6.0.3"
- name: "Install promtool"
# Prometheus 3.5.0 release archive, verified against the sha256 published with the release.
run: |
curl --fail --silent --show-error --location --output "$RUNNER_TEMP/prometheus.tar.gz" \
https://github.com/prometheus/prometheus/releases/download/v3.5.0/prometheus-3.5.0.linux-amd64.tar.gz
echo "e811827af26d822afb09a4f28314f61b618b12cff5369835a67f674d8b46f39a $RUNNER_TEMP/prometheus.tar.gz" | sha256sum --check --strict -
tar --extract --gzip --file "$RUNNER_TEMP/prometheus.tar.gz" --directory "$RUNNER_TEMP" prometheus-3.5.0.linux-amd64/promtool
echo "PROMTOOL=$RUNNER_TEMP/prometheus-3.5.0.linux-amd64/promtool" >> "$GITHUB_ENV"
- name: "Lint the chart in both deploy modes"
run: |
helm lint charts/ingot --strict -f charts/ingot/ci/allinone-values.yaml
helm lint charts/ingot --strict -f charts/ingot/ci/split-values.yaml
helm lint charts/ingot --strict -f charts/ingot/tests/scalable/values.yaml
- name: "Check the alert rules with promtool"
run: |
helm template ingot charts/ingot --namespace reposilite-staging --set prometheusRule.enabled=true \
--show-only templates/prometheusrule.yaml > "$RUNNER_TEMP/prometheusrule.yaml"
python3 -c 'import sys, yaml; print(yaml.safe_dump(yaml.safe_load(open(sys.argv[1]))["spec"]))' \
"$RUNNER_TEMP/prometheusrule.yaml" > "$RUNNER_TEMP/rules.yaml"
"$PROMTOOL" check rules "$RUNNER_TEMP/rules.yaml"
- name: "Run the chart tests"
run: python3 -m unittest discover -s charts/ingot/tests -t charts/ingot/tests -v
- name: "Check the dashboard segment copy against its source"
run: cmp charts/ingot/files/dashboard-segments.json reposilite-frontend/src/router/dashboard-segments.json
- name: "Set up chart-testing"
uses: helm/chart-testing-action@6ec842c01de15ebb84c8627d2744a0c2f2755c9f # v2.8.0
with:
version: "3.14.0"
- name: "Lint the chart with chart-testing"
run: ct lint --config ct.yaml --all
# The support tables of SUPPORT.md and .github/SECURITY.md are rendered from support-lines.json, so a window
# cannot drift from its table. The job fails when a table differs, when a backport label is missing for an open
# line, or when an open line has no release branch. With no open line the label and branch loops do nothing.
support-lines:
name: "Support lines"
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: "Checkout repository"
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: "Check the support tables against support-lines.json"
run: python3 .github/scripts/render_support_tables.py --mode check
- name: "Check the backport labels and release branches of the open lines"
env:
GH_TOKEN: ${{ github.token }}
run: |
while read -r label branch; do
if ! gh label list --repo "$GITHUB_REPOSITORY" --limit 500 --json name --jq '.[].name' | grep -qxF "$label"; then
echo "::error::the label $label is missing, create it before the line is open"
exit 1
fi
if ! git ls-remote --exit-code --heads origin "$branch" >/dev/null 2>&1; then
echo "::error::the branch $branch is missing for an open line"
exit 1
fi
done < <(python3 .github/scripts/render_support_tables.py --mode labels)
# The required check for everything that must stay fast. It is green when each light job succeeded or was skipped,
# and red when one failed or was cancelled. The summary lists each light job's duration against its budget, and a
# job over budget only warns, so a slow runner does not block a merge. Container images, the Helm chart, the HA smoke
# test and the dashboard end-to-end job are heavy and are not part of it.
light-checks:
name: "Light checks"
needs: [build, coverage-changes, coverage-backend, coverage-frontend, frontend, licenses, vulnerabilities, sbom, plugin-api, plugin-contracts, plugin-tiers, publications, script-tests, docs-tests, support-lines]
if: ${{ always() }}
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
steps:
- name: "Checkout repository"
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
# The job list of this run. The jobs of this run that are still running have no end time and are left out.
- name: "Read the job durations"
env:
GH_TOKEN: ${{ github.token }}
run: |
gh api --paginate "repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/jobs?per_page=100" \
--jq '{jobs: .jobs}' | jq -s '{jobs: map(.jobs) | add}' > "$RUNNER_TEMP/jobs.json" \
|| echo '{"jobs":[]}' > "$RUNNER_TEMP/jobs.json"
- name: "Check the light jobs and report their durations"
env:
NEEDS: ${{ toJSON(needs) }}
JOBS_FILE: ${{ runner.temp }}/jobs.json
run: |
set -o pipefail
python3 .github/scripts/light_checks.py | tee -a "$GITHUB_STEP_SUMMARY"