Repository navigation
feat: versioned (CAS) user writes in basic lock script #1719
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Test: Integration" | |
| # Java integration test-suite, run against an all-in-one (AIO) server with the | |
| # integration test-data loaded (CN_PERSISTENCE_LOAD_TEST_DATA=true). Replaces the | |
| # legacy Jenkins test runner. | |
| # | |
| # Flow per matrix leg (MYSQL / PGSQL): | |
| # build persistence-loader + config-api (from this checkout) + assemble AIO | |
| # -> run DB + AIO + a TLS terminating proxy | |
| # -> extract live secrets from the AIO -> render profiles/<fqdn>/ | |
| # -> import the AIO cert into the JDK truststore | |
| # -> full build with tests enabled (mvn install -Dcfg=<fqdn>) across all reactors | |
| # -> publish results (step summary + artifact + PR check). | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| persistence: | |
| description: "Persistence backend(s) to test" | |
| type: choice | |
| options: ["BOTH", "MYSQL", "PGSQL"] | |
| default: "BOTH" | |
| aio_image: | |
| description: "Prebuilt AIO image to test (leave empty to build from this checkout)" | |
| type: string | |
| default: "" | |
| log_level: | |
| description: "AIO log level (TRACE = detailed FILE logs to debug a failure; INFO = default, lower memory)" | |
| type: choice | |
| options: ["INFO", "TRACE"] | |
| default: "INFO" | |
| # Module selection: leave "all modules" checked to test everything (the default, and what | |
| # PR/nightly always do). Uncheck it and tick specific modules to narrow the suites that run. | |
| # The reactor + AIO are always built in full regardless, so build dependencies are honoured. | |
| all_modules: | |
| description: "Test all modules (uncheck to pick specific modules below)" | |
| type: boolean | |
| default: true | |
| jans_auth_server: | |
| description: "jans-auth-server" | |
| type: boolean | |
| default: false | |
| jans_config_api: | |
| description: "jans-config-api" | |
| type: boolean | |
| default: false | |
| jans_fido2: | |
| description: "jans-fido2" | |
| type: boolean | |
| default: false | |
| jans_scim: | |
| description: "jans-scim" | |
| type: boolean | |
| default: false | |
| jans_core: | |
| description: "jans-core" | |
| type: boolean | |
| default: false | |
| jans_orm: | |
| description: "jans-orm (units + persistence integration tests)" | |
| type: boolean | |
| default: false | |
| agama: | |
| description: "agama" | |
| type: boolean | |
| default: false | |
| jans_cedarling: | |
| description: "jans-cedarling (cedarling-java)" | |
| type: boolean | |
| default: false | |
| jans_lock: | |
| description: "jans-lock" | |
| type: boolean | |
| default: false | |
| script_catalog: | |
| description: "docs/script-catalog (custom scripts load + behavior; PRs run it only when the catalog changes)" | |
| type: boolean | |
| default: false | |
| schedule: | |
| - cron: "0 4 * * *" | |
| pull_request: | |
| paths: | |
| - "docker-jans-persistence-loader/**" | |
| - "docker-jans-config-api/**" | |
| - "docker-jans-all-in-one/**" | |
| - ".github/workflows/test-integration.yml" | |
| - ".github/workflows/scripts/render_test_profiles.py" | |
| - "automation/ci/run_aio_integration.sh" | |
| - "jans-linux-setup/jans_setup/templates/test/**" | |
| - "jans-linux-setup/jans_setup/schema/jans_test_schema.json" | |
| - "jans-auth-server/**" | |
| - "jans-scim/**" | |
| - "jans-config-api/**" | |
| - "jans-fido2/**" | |
| - "jans-orm/**" | |
| - "docs/script-catalog/**" | |
| - "automation/ci/script_catalog/**" | |
| permissions: | |
| contents: read | |
| concurrency: | |
| # Per branch/PR (github.ref), so a newer commit only cancels this ref's own now-stale run. | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| setup: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.matrix.outputs.matrix }} | |
| steps: | |
| - name: Harden runner | |
| uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0 | |
| with: | |
| egress-policy: audit | |
| - name: Compute persistence matrix | |
| id: matrix | |
| run: | | |
| # dispatch can target a single backend; PR/nightly run both (full MySQL + PostgreSQL coverage). | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ inputs.persistence }}" = "MYSQL" ]; then | |
| echo 'matrix=["MYSQL"]' >> "$GITHUB_OUTPUT" | |
| elif [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ inputs.persistence }}" = "PGSQL" ]; then | |
| echo 'matrix=["PGSQL"]' >> "$GITHUB_OUTPUT" | |
| else | |
| echo 'matrix=["MYSQL","PGSQL"]' >> "$GITHUB_OUTPUT" | |
| fi | |
| integration: | |
| needs: setup | |
| runs-on: ubuntu-latest | |
| # Gate PR runs behind manual approval (set required reviewers on the `integration-tests` | |
| # environment in repo settings); nightly/dispatch are intentional and run ungated. | |
| environment: ${{ github.event_name == 'pull_request' && 'integration-tests' || '' }} | |
| # Headroom over the ~1h15 runtime so a slow leg reports rather than being cancelled at the cap. | |
| timeout-minutes: 150 | |
| permissions: | |
| contents: read | |
| checks: write | |
| pull-requests: write | |
| actions: read # list this run's jobs to build #summary-<job-id> deep links | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| persistence: ${{ fromJson(needs.setup.outputs.matrix) }} | |
| env: | |
| JANS_FQDN: aio.jans.io | |
| DB_NAME: jans | |
| DB_USER: jans | |
| DB_PASSWORD: "Test1234#" | |
| # config-api test client, pinned so the suite has deterministic credentials | |
| CN_CONFIG_API_TEST_CLIENT_ID: "1801.00000000-0000-0000-0000-00000000c1ce" | |
| CN_CONFIG_API_TEST_CLIENT_SECRET: "integration-test-config-api-secret" | |
| CN_CONFIG_API_TEST_CLIENT_TRUSTED: "true" | |
| steps: | |
| - name: Harden runner | |
| uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0 | |
| with: | |
| egress-policy: audit | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| # .git is rsync'd to the VM (the maven buildnumber plugin needs it); don't carry the token. | |
| persist-credentials: false | |
| # Script-catalog tests run only on demand: a PR touching the catalog/harness, or a ticked dispatch. | |
| - name: Decide script-catalog tests | |
| id: catalog | |
| env: | |
| BASE_SHA: ${{ github.event.pull_request.base.sha }} | |
| run: | | |
| run=false | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| run="${{ inputs.script_catalog }}" | |
| elif [ "${{ github.event_name }}" = "pull_request" ]; then | |
| git fetch -q --no-tags --depth=1 origin "$BASE_SHA" | |
| rc=0 | |
| git diff --quiet "$BASE_SHA" HEAD -- docs/script-catalog automation/ci/script_catalog || rc=$? | |
| case "$rc" in 0) ;; 1) run=true ;; *) echo "::error::git diff failed ($rc)"; exit "$rc" ;; esac | |
| fi | |
| echo "run=$run" >> "$GITHUB_OUTPUT" | |
| echo "[info] script-catalog tests: $run" | |
| # Offline: catches a renamed catalog script or stale manifest entry before a VM is provisioned. | |
| - name: Script-catalog harness self-test | |
| if: steps.catalog.outputs.run == 'true' | |
| run: python3 -m unittest discover -s automation/ci/script_catalog | |
| - name: Sweep stale CI droplets | |
| env: | |
| DO_TOKEN: ${{ secrets.DO_TOKEN }} | |
| run: | | |
| set -uo pipefail | |
| [ -n "${DO_TOKEN:-}" ] || { echo "[warn] DO_TOKEN unset; skipping sweep"; exit 0; } | |
| # Only jans-ci droplets older than 2h: leaks from crashed runs. Age gate spares a | |
| # concurrent run's fresh droplet (same-run cleanup is teardown/reap's job). | |
| cutoff=$(date -u -d '2 hours ago' +%s) | |
| curl -sS --connect-timeout 10 --max-time 30 -H "Authorization: Bearer ${DO_TOKEN}" \ | |
| 'https://api.digitalocean.com/v2/droplets?tag_name=jans-ci&per_page=200' \ | |
| | jq -r --argjson cutoff "$cutoff" \ | |
| '.droplets[]? | select((.created_at | fromdateiso8601) < $cutoff) | "\(.id)\t\(.name)\t\(.created_at)"' \ | |
| | while IFS=$'\t' read -r id name created; do | |
| [ -n "$id" ] || continue | |
| echo "[sweep] deleting stale droplet $id ($name, created $created)" | |
| curl -sS --connect-timeout 10 --max-time 30 -X DELETE \ | |
| "https://api.digitalocean.com/v2/droplets/$id" \ | |
| -H "Authorization: Bearer ${DO_TOKEN}" || true | |
| done | |
| - name: Provision CI droplet | |
| id: vm | |
| env: | |
| DO_TOKEN: ${{ secrets.DO_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| [ -n "${DO_TOKEN:-}" ] || { echo "::error::DO_TOKEN secret is not set (add a DigitalOcean PAT with droplet create/delete to the repo's Actions secrets)"; exit 1; } | |
| # Surface the API error body; curl -f would reduce a 422 to an opaque "exit code 22". | |
| # Non-retrying: a timeout must not re-POST and duplicate an already-accepted operation. | |
| do_post() { | |
| local url="$1" data="$2" out status body | |
| out=$(curl -sS --connect-timeout 10 --max-time 30 -w '\n%{http_code}' -X POST "$url" \ | |
| -H "Authorization: Bearer ${DO_TOKEN}" -H "Content-Type: application/json" -d "$data") | |
| status=${out##*$'\n'}; body=${out%$'\n'*} | |
| if [ "$status" -lt 200 ] || [ "$status" -ge 300 ]; then | |
| echo "::error::DO API POST ${url##*/} -> HTTP $status: $(jq -rc '.message // .' <<<"$body" 2>/dev/null || echo "$body")" >&2 | |
| return 1 | |
| fi | |
| printf '%s' "$body" | |
| } | |
| # Diagnostic droplet count (a full account is the usual create-422 cause). Fail closed to | |
| # '?' rather than a false 0; meta.total covers all pages. | |
| count=$(curl -fsS --connect-timeout 10 --max-time 30 -H "Authorization: Bearer ${DO_TOKEN}" \ | |
| 'https://api.digitalocean.com/v2/droplets?per_page=1' | jq -e '.meta.total' 2>/dev/null) || count='?' | |
| echo "[info] existing droplets on account: $count" | |
| # Ephemeral keypair: the public key is registered on the droplet at create time and both | |
| # the key + droplet are destroyed in teardown, so no long-lived credential is persisted. | |
| ssh-keygen -t rsa -b 4096 -N '' -f id_ci -q | |
| # Host key is provisioned via user_data (authenticated DO API) so the VM is pinned, not TOFU. | |
| ssh-keygen -t ed25519 -N '' -C '' -f ci_hostkey -q | |
| user_data=$(printf '#cloud-config\nssh_keys:\n ed25519_private: |\n%s\n ed25519_public: %s\n' \ | |
| "$(sed 's/^/ /' ci_hostkey)" "$(cat ci_hostkey.pub)") | |
| key_id=$(do_post "https://api.digitalocean.com/v2/account/keys" \ | |
| "$(jq -n --arg name "jans-ci-${{ github.run_id }}-${{ matrix.persistence }}" \ | |
| --arg key "$(cat id_ci.pub)" '{name:$name, public_key:$key}')" \ | |
| | jq -er '.ssh_key.id') | |
| # Persist now so teardown can delete the key even if droplet creation below fails. | |
| echo "key_id=$key_id" >> "$GITHUB_OUTPUT" | |
| # DO accepts the key POST before the key is usable for droplet creation. | |
| for _ in $(seq 1 10); do | |
| curl -fsS --connect-timeout 10 --max-time 30 -o /dev/null \ | |
| -H "Authorization: Bearer ${DO_TOKEN}" \ | |
| "https://api.digitalocean.com/v2/account/keys/$key_id" && break | |
| sleep 3 | |
| done | |
| # Only the two 422s handled below are recoverable; any other non-2xx aborts (a re-POST | |
| # after e.g. a 5xx could duplicate an already-accepted droplet). Dedicated-CPU classes | |
| # first (the build is CPU-bound and Basic droplets get throttled), degrading to Basic. | |
| # Newest jans-ci-base-* snapshot has the toolchain prebaked; stock Ubuntu is the fallback, | |
| # and is tried again when the snapshot's own regions have no capacity for any size. | |
| snap=$(curl -fsS --connect-timeout 10 --max-time 30 -H "Authorization: Bearer ${DO_TOKEN}" \ | |
| 'https://api.digitalocean.com/v2/snapshots?resource_type=droplet&per_page=200' \ | |
| | jq -c '[.snapshots[]? | select(.name|startswith("jans-ci-base-"))] | |
| | sort_by(.created_at) | last // empty') || snap="" | |
| snap_id=""; snap_regions="" | |
| if [ -n "$snap" ]; then | |
| snap_id=$(jq -r '.id' <<<"$snap") | |
| snap_regions=$(jq -r '.regions | join(" ")' <<<"$snap") | |
| echo "[info] CI snapshot $(jq -r '.name' <<<"$snap") ($snap_id) in: $snap_regions" | |
| else | |
| echo "[info] no jans-ci-base-* snapshot; booting stock Ubuntu" | |
| fi | |
| droplet_id="" | |
| for image in ${snap_id:+$snap_id} ubuntu-22-04-x64; do | |
| if [ "$image" = "ubuntu-22-04-x64" ]; then | |
| img_json='"ubuntu-22-04-x64"'; regions="nyc1 nyc3 sfo3 ams3 fra1 tor1" | |
| else | |
| img_json="$image"; regions="$snap_regions" | |
| fi | |
| for SIZE in g-8vcpu-32gb c-8 s-8vcpu-16gb; do | |
| for region in $regions; do | |
| for attempt in 1 2 3 4 5; do | |
| out=$(curl -sS --connect-timeout 10 --max-time 30 -w '\n%{http_code}' -X POST \ | |
| "https://api.digitalocean.com/v2/droplets" \ | |
| -H "Authorization: Bearer ${DO_TOKEN}" -H "Content-Type: application/json" \ | |
| -d "$(jq -n \ | |
| --arg name "jans-ci-${{ github.run_id }}-${{ matrix.persistence }}" \ | |
| --argjson key "$key_id" \ | |
| --arg run "run-${{ github.run_id }}" \ | |
| --arg region "$region" --arg size "$SIZE" --argjson image "$img_json" \ | |
| --arg ud "$user_data" \ | |
| '{name:$name, region:$region, size:$size, image:$image, | |
| ssh_keys:[$key], tags:["jans-ci", $run], user_data:$ud}')") | |
| status=${out##*$'\n'}; body=${out%$'\n'*} | |
| if [ "$status" -ge 200 ] && [ "$status" -lt 300 ]; then | |
| droplet_id=$(jq -er '.droplet.id' <<<"$body") | |
| echo "[info] created droplet $droplet_id ($SIZE, image $image) in $region" | |
| break | |
| fi | |
| msg=$(jq -rc '.message // .' <<<"$body" 2>/dev/null || echo "$body") | |
| # No region or size can fix an unusable key, so stop rather than walk the list. | |
| if [ "$status" -eq 422 ] && printf '%s' "$msg" | grep -qi "invalid key identifier"; then | |
| if [ "$attempt" -eq 5 ]; then | |
| echo "::error::DO still rejects SSH key $key_id after 5 attempts: $msg"; exit 1 | |
| fi | |
| echo "[warn] SSH key $key_id not usable yet (attempt $attempt/5); retrying in 10s" | |
| sleep 10 | |
| continue | |
| fi | |
| if [ "$status" -eq 422 ] && printf '%s' "$msg" | grep -qi "not available in this region"; then | |
| echo "[warn] $region: $SIZE unavailable here, trying next region" | |
| continue 2 | |
| fi | |
| echo "::error::DO droplet create -> HTTP $status: $msg"; exit 1 | |
| done | |
| if [ -n "$droplet_id" ]; then break; fi | |
| done | |
| if [ -n "$droplet_id" ]; then break; fi | |
| echo "[warn] $SIZE unavailable in every candidate region, trying the next size" | |
| done | |
| if [ -n "$droplet_id" ]; then break; fi | |
| echo "[warn] no capacity for image $image, trying the next image" | |
| done | |
| [ -n "$droplet_id" ] && [ "$droplet_id" != "null" ] || { | |
| echo "::error::could not create a droplet of any candidate size in any candidate region"; exit 1; } | |
| echo "droplet_id=$droplet_id" >> "$GITHUB_OUTPUT" | |
| echo "[info] created droplet $droplet_id (key $key_id)" | |
| - name: Wait for droplet IP + SSH | |
| id: ip | |
| env: | |
| DO_TOKEN: ${{ secrets.DO_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| ip="" | |
| for _ in $(seq 1 60); do | |
| ip=$(curl -fsS "https://api.digitalocean.com/v2/droplets/${{ steps.vm.outputs.droplet_id }}" \ | |
| -H "Authorization: Bearer ${DO_TOKEN}" \ | |
| | jq -r '.droplet.networks.v4[]? | select(.type=="public") | .ip_address' | head -n1) | |
| [ -n "$ip" ] && [ "$ip" != "null" ] && break | |
| sleep 10 | |
| done | |
| if [ -z "$ip" ] || [ "$ip" = "null" ]; then echo "::error::droplet never reported a public IP"; exit 1; fi | |
| echo "[info] droplet IP: $ip" | |
| echo "$ip $(cut -d' ' -f1,2 ci_hostkey.pub)" > ci_known_hosts | |
| for _ in $(seq 1 60); do | |
| ssh -i id_ci -o StrictHostKeyChecking=yes -o UserKnownHostsFile=ci_known_hosts -o ConnectTimeout=10 "root@$ip" true 2>/dev/null && break | |
| sleep 10 | |
| done | |
| # user_data stays readable through the VM metadata service, so swap the provisioned host key | |
| # over the pinned session before any repository code runs there. | |
| new_hostkey=$(ssh -i id_ci -o StrictHostKeyChecking=yes -o UserKnownHostsFile=ci_known_hosts -o ConnectTimeout=10 "root@$ip" \ | |
| 'set -e; rm -f /etc/ssh/ssh_host_*; ssh-keygen -q -t ed25519 -N "" -C "" -f /etc/ssh/ssh_host_ed25519_key; systemctl reload ssh 2>/dev/null || systemctl reload sshd; cut -d" " -f1,2 /etc/ssh/ssh_host_ed25519_key.pub') | |
| echo "$ip $new_hostkey" > ci_known_hosts | |
| for attempt in $(seq 1 6); do | |
| ssh -i id_ci -o StrictHostKeyChecking=yes -o UserKnownHostsFile=ci_known_hosts -o ConnectTimeout=10 "root@$ip" true && break | |
| [ "$attempt" -eq 6 ] && { echo "::error::droplet unreachable with the rotated host key"; exit 1; } | |
| sleep 5 | |
| done | |
| echo "ip=$ip" >> "$GITHUB_OUTPUT" | |
| - name: Resolve test modules | |
| id: mods | |
| run: | | |
| # PR/nightly (and dispatch with "all modules" ticked) run everything; otherwise collect the | |
| # individually-ticked modules into the comma list run_aio_integration.sh's TEST_MODULES expects. | |
| if [ "${{ github.event_name }}" != "workflow_dispatch" ] || [ "${{ inputs.all_modules }}" = "true" ]; then | |
| echo "modules=all" >> "$GITHUB_OUTPUT"; exit 0 | |
| fi | |
| sel="" | |
| [ "${{ inputs.jans_auth_server }}" = "true" ] && sel="$sel,jans-auth-server" || true | |
| [ "${{ inputs.jans_config_api }}" = "true" ] && sel="$sel,jans-config-api" || true | |
| [ "${{ inputs.jans_fido2 }}" = "true" ] && sel="$sel,jans-fido2" || true | |
| [ "${{ inputs.jans_scim }}" = "true" ] && sel="$sel,jans-scim" || true | |
| [ "${{ inputs.jans_core }}" = "true" ] && sel="$sel,jans-core" || true | |
| [ "${{ inputs.jans_orm }}" = "true" ] && sel="$sel,jans-orm" || true | |
| [ "${{ inputs.agama }}" = "true" ] && sel="$sel,agama" || true | |
| [ "${{ inputs.jans_cedarling }}" = "true" ] && sel="$sel,jans-cedarling" || true | |
| [ "${{ inputs.jans_lock }}" = "true" ] && sel="$sel,jans-lock" || true | |
| sel="${sel#,}" | |
| # only the script-catalog box ticked: run no Java suites | |
| [ -z "$sel" ] && [ "${{ inputs.script_catalog }}" = "true" ] && sel="none" | |
| echo "modules=${sel:-all}" >> "$GITHUB_OUTPUT" | |
| echo "[info] selected test modules: ${sel:-all}" | |
| - name: Cache week | |
| id: date | |
| run: echo "week=$(date +%Y-%U)" >> "$GITHUB_OUTPUT" | |
| - name: Restore build caches | |
| id: bcache | |
| uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 | |
| with: | |
| # In the workspace so the bootstrap rsync ships it to the VM, which seeds ~/.m2 + ~/.cargo. | |
| path: ci-cache | |
| # Weekly bucket, not a content hash: entries are immutable, so a pom change would write | |
| # another ~3 GB entry and churn the 10 GB budget shared with the other workflows. | |
| key: aio-build-${{ steps.date.outputs.week }} | |
| restore-keys: aio-build- | |
| - name: Bootstrap + run on the VM | |
| env: | |
| IP: ${{ steps.ip.outputs.ip }} | |
| GITHUB_ACTOR: ${{ github.actor }} | |
| JANS_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| SSH=(ssh -i id_ci -o StrictHostKeyChecking=yes -o UserKnownHostsFile=ci_known_hosts -o ServerAliveInterval=30 "root@$IP") | |
| # Ship the checkout (incl. render script + maven-settings); docker is installed by the demo script. | |
| rsync -az -e "ssh -i id_ci -o StrictHostKeyChecking=yes -o UserKnownHostsFile=ci_known_hosts" ./ "root@$IP:/root/jans/" | |
| # $JANS_FQDN expands on the runner; the host -> loopback alias lets the VM reach the AIO at | |
| # https://$JANS_FQDN (traefik publishes 443 on the droplet). | |
| "${SSH[@]}" "set -e | |
| export DEBIAN_FRONTEND=noninteractive | |
| cloud-init status --wait 2>/dev/null || true | |
| if ! command -v mvn >/dev/null 2>&1 || ! command -v javac >/dev/null 2>&1 || ! command -v rsync >/dev/null 2>&1; then | |
| apt-get -o DPkg::Lock::Timeout=600 update -qq | |
| apt-get -o DPkg::Lock::Timeout=600 install -y -qq openjdk-17-jdk maven rsync | |
| fi | |
| command -v docker >/dev/null 2>&1 || curl -fsSL https://get.docker.com | sh | |
| git config --global --add safe.directory '*' | |
| grep -q '$JANS_FQDN\$' /etc/hosts || echo '127.0.0.1 $JANS_FQDN' >> /etc/hosts" | |
| # Drive the whole jans-side flow on the VM. Env is expanded HERE (runner) into the remote | |
| # command so the matrix/secret values land in the VM shell. | |
| "${SSH[@]}" "cd /root/jans && \ | |
| JANS_FQDN='$JANS_FQDN' \ | |
| JANS_PERSISTENCE='${{ matrix.persistence }}' \ | |
| AIO_IMAGE='${{ inputs.aio_image }}' \ | |
| LOG_LEVEL='${{ inputs.log_level }}' \ | |
| TEST_MODULES='${{ steps.mods.outputs.modules }}' \ | |
| SCRIPT_CATALOG='${{ steps.catalog.outputs.run }}' \ | |
| SAVE_CACHE='${{ github.event_name != 'pull_request' && matrix.persistence == fromJson(needs.setup.outputs.matrix)[0] && 1 || 0 }}' \ | |
| DB_NAME='$DB_NAME' DB_USER='$DB_USER' DB_PASSWORD='$DB_PASSWORD' \ | |
| CN_CONFIG_API_TEST_CLIENT_ID='$CN_CONFIG_API_TEST_CLIENT_ID' \ | |
| CN_CONFIG_API_TEST_CLIENT_SECRET='$CN_CONFIG_API_TEST_CLIENT_SECRET' \ | |
| CN_CONFIG_API_TEST_CLIENT_TRUSTED='$CN_CONFIG_API_TEST_CLIENT_TRUSTED' \ | |
| GITHUB_ACTOR='$GITHUB_ACTOR' JANS_TOKEN='$JANS_TOKEN' \ | |
| bash automation/ci/run_aio_integration.sh" | |
| - name: Collect results from the VM | |
| if: always() | |
| env: | |
| IP: ${{ steps.ip.outputs.ip }} | |
| run: | | |
| set -uo pipefail | |
| [ -n "${IP:-}" ] || { echo "[warn] no VM IP; skipping result collection"; exit 0; } | |
| scp -i id_ci -o StrictHostKeyChecking=yes -o UserKnownHostsFile=ci_known_hosts -r "root@$IP:/root/jans/test-reports" ./ || true | |
| scp -i id_ci -o StrictHostKeyChecking=yes -o UserKnownHostsFile=ci_known_hosts -r "root@$IP:/root/jans/aio-logs" ./ || true | |
| # The gate passes on any non-empty, non-failing result set, so a lost catalog report must fail here. | |
| - name: Require script-catalog report | |
| if: always() && steps.catalog.outputs.run == 'true' | |
| run: | | |
| python3 - <<'PY' | |
| import sys, xml.etree.ElementTree as ET | |
| path = "test-reports/script-catalog-TEST-ScriptCatalog.xml" | |
| try: | |
| cases = ET.parse(path).getroot().iter("testcase") | |
| if next(cases, None) is None: | |
| sys.exit(f"::error::{path} has no test cases") | |
| except (OSError, ET.ParseError) as e: | |
| sys.exit(f"::error::script-catalog report missing or unreadable: {e}") | |
| PY | |
| # First matrix leg only (both build the same artifacts), and non-PR only: a PR's cache is | |
| # scoped to its own ref, so it would evict in-use entries while being readable by nothing. | |
| - name: Collect build caches from the VM | |
| id: ccache | |
| if: always() && github.event_name != 'pull_request' && matrix.persistence == fromJson(needs.setup.outputs.matrix)[0] | |
| env: | |
| IP: ${{ steps.ip.outputs.ip }} | |
| run: | | |
| set -uo pipefail | |
| [ -n "${IP:-}" ] || exit 0 | |
| rm -rf ci-cache | |
| # Timeouts throughout: this step is if:always(), so a wedged VM would otherwise hang it | |
| # until the job cap. | |
| if rsync -az --timeout=300 \ | |
| -e "ssh -i id_ci -o StrictHostKeyChecking=yes -o UserKnownHostsFile=ci_known_hosts -o ConnectTimeout=15 -o ServerAliveInterval=15 -o ServerAliveCountMax=4" \ | |
| "root@$IP:/root/jans/ci-cache/" ci-cache/; then | |
| # The VM writes .save-ok only when the repack was complete and inside the size budget. | |
| [ -f ci-cache/.save-ok ] && echo "ok=1" >> "$GITHUB_OUTPUT" | |
| du -sh ci-cache 2>/dev/null || true | |
| else | |
| echo "[warn] cache fetch failed; discarding the partial copy" | |
| rm -rf ci-cache | |
| fi | |
| - name: Save build caches | |
| # A re-save under an unchanged key only warns; never let it fail the run. | |
| continue-on-error: true | |
| if: always() && steps.ccache.outputs.ok == '1' | |
| uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 | |
| with: | |
| path: ci-cache | |
| key: ${{ steps.bcache.outputs.cache-primary-key }} | |
| - name: Summarise results | |
| if: always() | |
| run: | | |
| # De-duplicates TestNG RetryAnalyzer re-runs so the totals reflect distinct tests | |
| # (comparable to Jenkins) rather than every retry attempt. | |
| python3 .github/workflows/scripts/summarize_testng.py >> "$GITHUB_STEP_SUMMARY" || true | |
| env: | |
| MATRIX: ${{ matrix.persistence }} | |
| - name: Summary deep-links | |
| if: always() | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| JOBS_URL: ${{ github.api_url }}/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}/jobs | |
| BASE: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }} | |
| run: | | |
| # Append links to the sibling (other backend) and combined summaries so a reader can jump | |
| # straight to them instead of scrolling the run. | |
| { echo ""; curl -sS --connect-timeout 10 --max-time 30 -H "Authorization: Bearer $GH_TOKEN" \ | |
| -H "Accept: application/vnd.github+json" "$JOBS_URL?per_page=100" \ | |
| | python3 .github/workflows/scripts/summary_links.py "$BASE"; } >> "$GITHUB_STEP_SUMMARY" || true | |
| - name: Upload test reports | |
| if: always() | |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 | |
| with: | |
| name: test-reports-${{ matrix.persistence }} | |
| path: test-reports/ | |
| if-no-files-found: warn | |
| retention-days: 5 | |
| - name: Publish test report (PR check) | |
| if: always() | |
| continue-on-error: true | |
| uses: dorny/test-reporter@a43b3a5f7366b97d083190328d2c652e1a8b6aa2 # v3.0.0 | |
| with: | |
| name: integration-tests (${{ matrix.persistence }}) | |
| # surefire also emits JUnit-format TEST-*.xml; testng-results.xml feeds the step summary | |
| path: "test-reports/*TEST-*.xml" | |
| reporter: java-junit | |
| fail-on-error: false | |
| - name: AIO key events | |
| if: always() | |
| run: | | |
| # aio-logs/ was scp'd back from the VM; surface the key events in the step log. | |
| echo "::group::supervisord status"; cat aio-logs/supervisord-status.txt 2>/dev/null || true; echo "::endgroup::" | |
| echo "::group::AIO key events" | |
| grep -aiE "jans-auth -|jans-scim -|jans-config-api -|jans-fido2 -|ERROR|Exception|FATAL|503|Unauthorized" aio-logs/aio-container.log 2>/dev/null | tail -n 200 || true | |
| echo "::endgroup::" | |
| - name: Gate on test outcome | |
| if: always() | |
| # Gates on distinct failures (retries de-duplicated), so flaky-but-passing tests don't trip it. | |
| # MATRIX carries the DB backend so per-backend baselines (KNOWN_FAILING_ON_BACKEND) apply. | |
| env: | |
| MATRIX: ${{ matrix.persistence }} | |
| run: python3 .github/workflows/scripts/summarize_testng.py --gate | |
| - name: Upload AIO logs | |
| if: always() | |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 | |
| with: | |
| name: aio-logs-${{ matrix.persistence }} | |
| path: aio-logs/ | |
| if-no-files-found: warn | |
| retention-days: 5 | |
| - name: Tear down CI droplet | |
| if: always() | |
| env: | |
| DO_TOKEN: ${{ secrets.DO_TOKEN }} | |
| run: | | |
| # Best-effort: the reap job is the safety net if this step is skipped (e.g. cancellation). | |
| if [ -n "${{ steps.vm.outputs.droplet_id }}" ]; then | |
| curl -fsS -X DELETE "https://api.digitalocean.com/v2/droplets/${{ steps.vm.outputs.droplet_id }}" \ | |
| -H "Authorization: Bearer ${DO_TOKEN}" || true | |
| fi | |
| if [ -n "${{ steps.vm.outputs.key_id }}" ]; then | |
| curl -fsS -X DELETE "https://api.digitalocean.com/v2/account/keys/${{ steps.vm.outputs.key_id }}" \ | |
| -H "Authorization: Bearer ${DO_TOKEN}" || true | |
| fi | |
| # Global view: every matrix leg in one step summary, MySQL + PostgreSQL side by side. | |
| aggregate: | |
| needs: integration | |
| if: always() | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| actions: read # list this run's jobs to build #summary-<job-id> deep links | |
| steps: | |
| - name: Harden runner | |
| uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0 | |
| with: | |
| egress-policy: audit | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: false | |
| - name: Download every leg's reports | |
| uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1 | |
| with: | |
| pattern: test-reports-* | |
| path: aggregated | |
| - name: Combined summary + Zulip message | |
| id: sum | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
| # Branch under test + who to ask about it: the PR's head branch/author on a PR, the | |
| # pushed/dispatched ref and the triggering actor otherwise. | |
| REF_NAME: ${{ github.head_ref || github.ref_name }} | |
| AUTHOR: ${{ github.event.pull_request.user.login && format('@{0}', github.event.pull_request.user.login) || format('@{0}', github.actor) }} | |
| JOBS_URL: ${{ github.api_url }}/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}/jobs | |
| BASE: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }} | |
| run: | | |
| # Per-backend + combined deep links (reused for both the step summary and Zulip). | |
| jobs=$(curl -sS --connect-timeout 10 --max-time 30 -H "Authorization: Bearer $GH_TOKEN" \ | |
| -H "Accept: application/vnd.github+json" "$JOBS_URL?per_page=100" || echo '{}') | |
| links_md=$(printf '%s' "$jobs" | python3 .github/workflows/scripts/summary_links.py "$BASE" md || true) | |
| links_zulip=$(printf '%s' "$jobs" | python3 .github/workflows/scripts/summary_links.py "$BASE" zulip || true) | |
| { python3 .github/workflows/scripts/summarize_testng.py --combined aggregated; echo ""; echo "$links_md"; } \ | |
| >> "$GITHUB_STEP_SUMMARY" || true | |
| { | |
| echo 'content<<ZULIP_EOF' | |
| python3 .github/workflows/scripts/summarize_testng.py --zulip aggregated --run-url "$RUN_URL" \ | |
| --ref "$REF_NAME" --author "$AUTHOR" \ | |
| || echo "**Integration tests**: could not build summary — $RUN_URL" | |
| [ -n "$links_zulip" ] && { echo ""; echo "$links_zulip"; } | |
| echo 'ZULIP_EOF' | |
| } >> "$GITHUB_OUTPUT" | |
| # Post to Zulip #bot_reporter on every run, pass or fail. Needs the ZULIP_API_KEY secret. | |
| - name: Report to Zulip | |
| if: always() | |
| continue-on-error: true | |
| uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1 | |
| with: | |
| api-key: ${{ secrets.ZULIP_API_KEY }} | |
| email: "git-gluu@gluu.org" | |
| organization-url: "https://chat.gluu.org" | |
| to: "bot_reporter" | |
| type: "stream" | |
| topic: "integration-tests" | |
| content: ${{ steps.sum.outputs.content }} | |
| # Safety net: if the integration job is cancelled before its teardown step runs, this deletes any | |
| # droplet tagged run-<run_id> and any SSH key named jans-ci-<run_id>-*, scoped to this run only. | |
| reap: | |
| needs: integration | |
| if: always() | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Harden runner | |
| uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0 | |
| with: | |
| egress-policy: audit | |
| - name: Delete any leftover droplets for this run | |
| env: | |
| DO_TOKEN: ${{ secrets.DO_TOKEN }} | |
| run: | | |
| set -uo pipefail | |
| curl -fsS -X DELETE \ | |
| "https://api.digitalocean.com/v2/droplets?tag_name=run-${{ github.run_id }}" \ | |
| -H "Authorization: Bearer ${DO_TOKEN}" || true | |
| - name: Delete any leftover SSH keys for this run | |
| env: | |
| DO_TOKEN: ${{ secrets.DO_TOKEN }} | |
| run: | | |
| set -uo pipefail | |
| # Keys can't be tagged; collect this run's keys (exact prefix jans-ci-<run_id>-) across all | |
| # pages, then delete -- collect-then-delete so deletions don't shift the pages mid-walk. | |
| prefix="jans-ci-${{ github.run_id }}-" | |
| ids="" | |
| page=1 | |
| while :; do | |
| resp=$(curl -fsS "https://api.digitalocean.com/v2/account/keys?per_page=200&page=${page}" \ | |
| -H "Authorization: Bearer ${DO_TOKEN}") || break | |
| ids="$ids $(jq -r --arg p "$prefix" '.ssh_keys[]? | select(.name | startswith($p)) | .id' <<<"$resp")" | |
| jq -e '.links.pages.next' >/dev/null 2>&1 <<<"$resp" || break | |
| page=$((page + 1)) | |
| done | |
| for kid in $ids; do | |
| curl -fsS -X DELETE "https://api.digitalocean.com/v2/account/keys/$kid" \ | |
| -H "Authorization: Bearer ${DO_TOKEN}" || true | |
| done |