.github/workflows/ci.yml
name: Check
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
# Runs for one version branch of this repository share a group, whether a pull request event or Release version PR's
# dispatch started them, so a newer run and Version PR closed cancel them. Other manual dispatches are never cancelled
group: >-
${{ (github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == github.repository) &&
startsWith(github.head_ref || github.ref_name, 'release/version-') &&
format('check-version-{0}', github.head_ref || github.ref_name) ||
format('check-{0}-{1}', github.event_name, github.event_name == 'workflow_dispatch' && github.run_id || github.ref) }}
cancel-in-progress: ${{ github.event_name != 'workflow_dispatch' || startsWith(github.ref_name, 'release/version-') }}
jobs:
# Identical git trees need one full Check, so a run for content that already passed reuses that result. A commit that
# changes only release version files from a parent whose content passed runs only the release tooling and the website
# and contribution checks. Release prepare still refuses a Stable whose package content differs from the newest nightly
#
# Two certificates carry the result. The check job certifies the whole Check. The npm release checks job certifies only
# what a published package needs: the SDK checks, the release tooling checks and the consumers on both Node versions.
# Each has its own lookup, so npm evidence never waits for website jobs. A lookup waits for the certificate it reads,
# not for the rest of the run, and a reuse is accepted only from a lookup job that succeeded with a complete reference.
# The jobs behind a certificate skip only for a lookup that succeeded, so a failed lookup runs the actual checks
reuse:
name: Reuse a passing Check for identical content
runs-on: ubuntu-latest
timeout-minutes: 45
permissions:
contents: read
actions: read
outputs:
reused: ${{ steps.reuse.outputs.reused }}
run_id: ${{ steps.reuse.outputs.run_id }}
run_attempt: ${{ steps.reuse.outputs.run_attempt }}
run_url: ${{ steps.reuse.outputs.run_url }}
version_only: ${{ steps.reuse.outputs.version_only }}
parent_run_id: ${{ steps.reuse.outputs.parent_run_id }}
parent_run_attempt: ${{ steps.reuse.outputs.parent_run_attempt }}
parent_run_url: ${{ steps.reuse.outputs.parent_run_url }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
id: checkout
with:
persist-credentials: false
# The parent commit, which the version-only change is compared with
fetch-depth: 2
- uses: pnpm/setup@731dfb6463bbd11c11fd0ee11fe00ed0e36d48a1 # v3.2.0
id: setup
with:
working-directory: projects
install: false
- name: Find an earlier passing Check for the same git tree
id: reuse
env:
GH_TOKEN: ${{ github.token }}
run: node projects/release/reuse.js --scope check
release-reuse:
name: Reuse npm release checks
runs-on: ubuntu-latest
timeout-minutes: 45
permissions:
contents: read
actions: read
outputs:
reused: ${{ steps.reuse.outputs.reused }}
run_id: ${{ steps.reuse.outputs.run_id }}
run_attempt: ${{ steps.reuse.outputs.run_attempt }}
run_url: ${{ steps.reuse.outputs.run_url }}
version_only: ${{ steps.reuse.outputs.version_only }}
parent_run_id: ${{ steps.reuse.outputs.parent_run_id }}
parent_run_attempt: ${{ steps.reuse.outputs.parent_run_attempt }}
parent_run_url: ${{ steps.reuse.outputs.parent_run_url }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
id: checkout
with:
persist-credentials: false
# The parent commit, which the version-only change is compared with
fetch-depth: 2
- uses: pnpm/setup@731dfb6463bbd11c11fd0ee11fe00ed0e36d48a1 # v3.2.0
id: setup
with:
working-directory: projects
install: false
- name: Find an earlier passing npm release checks job for the same git tree
id: reuse
env:
GH_TOKEN: ${{ github.token }}
run: node projects/release/reuse.js --scope npm
sdk:
name: SDK checks
needs: release-reuse
# A failed reuse lookup still runs the full job
if: ${{ !cancelled() && (needs.release-reuse.result != 'success' || (needs.release-reuse.outputs.reused != 'true' && needs.release-reuse.outputs.version_only != 'true')) }}
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
id: checkout
with:
persist-credentials: false
- uses: pnpm/setup@731dfb6463bbd11c11fd0ee11fe00ed0e36d48a1 # v3.2.0
id: setup
with:
working-directory: projects
require-lockfile: true
cache: true
- name: Check SDK formatting, build, types, runtime and packed consumers
id: sdk
env:
CHECK_RESULTS_FILE: ${{ runner.temp }}/sdk-checks.json
run: pnpm --filter @neontechspace/fluxerly check
working-directory: projects
- name: Summarize SDK checks
if: always()
uses: $/.github/actions/summary
with:
title: SDK checks
steps: ${{ toJSON(steps) }}
checks: '{"SDK checks": "sdk"}'
results: '{"sdk": "${{ runner.temp }}/sdk-checks.json"}'
next: Nothing to fix here. The npm release checks job combines this result with the release tooling and consumer jobs
failure: Fix the failed checks and push. Checks that need the SDK build are skipped while the build fails
release:
name: Release tooling checks
needs: release-reuse
# Also for a version-only change, because this job checks the version, changelog and Changesets state it changes
if: ${{ !cancelled() && (needs.release-reuse.result != 'success' || needs.release-reuse.outputs.reused != 'true') }}
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
id: checkout
with:
persist-credentials: false
- uses: pnpm/setup@731dfb6463bbd11c11fd0ee11fe00ed0e36d48a1 # v3.2.0
id: setup
with:
working-directory: projects
require-lockfile: true
cache: true
- name: Check the release tooling
id: tooling
env:
CHECK_RESULTS_FILE: ${{ runner.temp }}/release-checks.json
run: node scripts/check.mjs release
working-directory: projects
- name: Lint the workspace scripts that run the checks
id: scripts
run: pnpm lint:scripts
working-directory: projects
- name: Check that the SDK version, changelog and Changesets state agree
id: version
if: needs.release-reuse.result == 'success' && needs.release-reuse.outputs.version_only == 'true'
run: node release/version-change.js check
working-directory: projects
- name: Check the changelog and manifest formatting and the SDK folder for em dashes
id: format
# The SDK checks job, which a version-only change skips, otherwise covers these files
if: needs.release-reuse.result == 'success' && needs.release-reuse.outputs.version_only == 'true'
run: |
pnpm --filter @neontechspace/fluxerly exec prettier --check CHANGELOG.md package.json
pnpm --filter @neontechspace/fluxerly lint:dashes
working-directory: projects
- name: Summarize release tooling checks
if: always()
uses: $/.github/actions/summary
with:
title: Release tooling checks
steps: ${{ toJSON(steps) }}
checks: '{"Release tooling": "tooling", "Workspace scripts lint": "scripts", "Version, changelog and Changesets state": "version", "Changelog and manifest formatting": "format"}'
results: '{"tooling": "${{ runner.temp }}/release-checks.json"}'
next: Nothing to fix here. The npm release checks job combines this result with the SDK and consumer jobs
failure: Fix the failed checks and push
tooling:
name: Website and contribution checks
needs: reuse
# Also for a version-only change, because the website builds its changelog page and search from the new notes
if: ${{ !cancelled() && (needs.reuse.result != 'success' || needs.reuse.outputs.reused != 'true') }}
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
id: checkout
with:
persist-credentials: false
- uses: pnpm/setup@731dfb6463bbd11c11fd0ee11fe00ed0e36d48a1 # v3.2.0
id: setup
with:
working-directory: projects
require-lockfile: true
cache: true
- name: Build the SDK declarations for the documentation reference
id: build
run: pnpm --filter @neontechspace/fluxerly build
working-directory: projects
- name: Restore Fluxer's pinned OpenAPI document and docs source
id: fluxer_source_cache
# Saved here and only restored by the release, website and screen workflows, which never save caches. The endpoint
# map checks every file against the sha256 in projects/release/upstream/manifest.json, so unchanged hashes reuse
# the previous pin's cached copies through restore-keys
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: projects/release/.cache/upstream
key: fluxer-source-${{ hashFiles('projects/release/upstream/manifest.json') }}
restore-keys: fluxer-source-
- name: Check contribution forms and the documentation website side by side
id: website
env:
CHECK_RESULTS_FILE: ${{ runner.temp }}/tooling-checks.json
# Each check starts once the checks it reads from have passed, and the log names every result with its time
run: node scripts/check.mjs contributions web
working-directory: projects
- name: Summarize website and contribution checks
if: always()
uses: $/.github/actions/summary
with:
title: Website and contribution checks
steps: ${{ toJSON(steps) }}
checks: '{"SDK declarations build": "build", "Contribution forms and website": "website"}'
results: '{"website": "${{ runner.temp }}/tooling-checks.json"}'
next: Nothing to fix here. The check job combines this result with the other jobs
failure: Fix the failed checks and push. Website checks that read the built site are skipped while its build fails
workflows:
name: Workflow lint and security audit
needs: reuse
if: ${{ !cancelled() && (needs.reuse.result != 'success' || (needs.reuse.outputs.reused != 'true' && needs.reuse.outputs.version_only != 'true')) }}
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
id: checkout
with:
persist-credentials: false
- uses: pnpm/setup@731dfb6463bbd11c11fd0ee11fe00ed0e36d48a1 # v3.2.0
id: setup
with:
working-directory: projects
install: false
- name: Restore the kept actionlint release
id: actionlint_cache
# Keyed by the pinned release and its checksum. The lint step checks the kept archive against that checksum before
# each use, so an entry can't change what runs
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/actionlint
key: actionlint-1.7.12-linux-amd64-8aca8db96f1b94770f1b0d72b6dddcb1ebb8123cb3712530b08cc387b349a3d8
- name: Lint workflow syntax, expressions and shell scripts
id: actionlint
# The allowed-actions policy accepts no container images, so the pinned release binary is verified by its checksum.
# An absent or damaged kept archive is downloaded again and checked the same way
run: |
archive="$RUNNER_TEMP/actionlint/actionlint_1.7.12_linux_amd64.tar.gz"
checksum="8aca8db96f1b94770f1b0d72b6dddcb1ebb8123cb3712530b08cc387b349a3d8 $archive"
if ! echo "$checksum" | sha256sum --check --strict --status 2>/dev/null; then
mkdir -p "$RUNNER_TEMP/actionlint"
curl --fail --silent --show-error --location --output "$archive" \
https://github.com/rhysd/actionlint/releases/download/v1.7.12/actionlint_1.7.12_linux_amd64.tar.gz
echo "$checksum" | sha256sum --check --strict
fi
tar --extract --gzip --file "$archive" actionlint
./actionlint -color
- name: Restore the kept zizmor download
id: zizmor_cache
# The action downloads zizmor's wheel through pip, which reuses a response it already holds. pip checks the wheel
# against the hashes the action pins for this version, so an entry can't change what runs
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.cache/pip
key: zizmor-pip-${{ runner.os }}-1.30.1
- name: Audit workflow security
id: zizmor
uses: zizmorcore/zizmor-action@45d7276c9ca790aabd705e31ca99c6185c3e76dd # v0.8.1
with:
version: 1.30.1
advanced-security: false
annotations: true
- name: Summarize workflow checks
if: always()
uses: $/.github/actions/summary
with:
title: Workflow lint and security audit
steps: ${{ toJSON(steps) }}
checks: '{"Workflow syntax, expressions and shell scripts (actionlint)": "actionlint", "Workflow security audit (zizmor)": "zizmor"}'
next: Nothing to fix here. The check job combines this result with the other jobs
failure: Fix each finding in the workflow source rather than suppressing it. The actionlint step log and the zizmor annotations name the file and line
reproduce: |-
actionlint
uvx zizmor@1.30.1 .github/workflows
browser:
name: Documentation browser checks
needs: reuse
if: ${{ !cancelled() && (needs.reuse.result != 'success' || (needs.reuse.outputs.reused != 'true' && needs.reuse.outputs.version_only != 'true')) }}
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
id: checkout
with:
persist-credentials: false
# The screen check compares with a pull request's base or the commit a push started from, so it needs history
fetch-depth: 0
- uses: pnpm/setup@731dfb6463bbd11c11fd0ee11fe00ed0e36d48a1 # v3.2.0
id: setup_node
with:
working-directory: projects
install: false
- name: Detect whether changed files reach any website screen or version check
id: scope
env:
EVENT_NAME: ${{ github.event_name }}
PULL_REQUEST_BASE: ${{ github.event.pull_request.base.sha }}
PUSH_BEFORE: ${{ github.event.before }}
run: |
if [ "$EVENT_NAME" = pull_request ]; then
base="$PULL_REQUEST_BASE"
elif [ "$EVENT_NAME" = push ] && [ -n "${PUSH_BEFORE//0/}" ]; then
base="$PUSH_BEFORE"
else
base=origin/main
fi
if [ "$EVENT_NAME" = workflow_dispatch ]; then
printf 'run=true\n' >> "$GITHUB_OUTPUT"
printf 'Manual dispatch runs documentation browser checks against %s\n' "$base"
exit 0
fi
BASE="$base" node --input-type=module <<'NODE'
import { appendFileSync } from "node:fs"
import { areasForChanges, changedPaths, repositoryRoot } from "./projects/web/scripts/checks/changed.mjs"
let run = true
try {
const paths = changedPaths(repositoryRoot, process.env.BASE)
const { areas, reasons } = areasForChanges(paths, repositoryRoot)
for (const reason of reasons) console.log(reason)
const hasWebsiteInput =
areas === "all" ||
areas.size > 0 ||
reasons.length > 0 ||
paths.includes("projects/web/scripts/checks/versions.mjs")
run = hasWebsiteInput
if (!run) console.log("No website inputs changed, skipping browser and version checks")
} catch (error) {
console.log(`${error instanceof Error ? error.message : error}, running documentation browser checks`)
run = true
}
appendFileSync(process.env.GITHUB_OUTPUT, `run=${run}\n`)
NODE
- uses: pnpm/setup@731dfb6463bbd11c11fd0ee11fe00ed0e36d48a1 # v3.2.0
id: setup
if: steps.scope.outputs.run == 'true'
with:
working-directory: projects
require-lockfile: true
cache: true
- name: Restore Fluxer's pinned OpenAPI document and docs source
id: fluxer_source_cache
if: steps.scope.outputs.run == 'true'
# Saved here and only restored by the release, website and screen workflows, which never save caches. The endpoint
# map checks every file against the sha256 in projects/release/upstream/manifest.json, so unchanged hashes reuse
# the previous pin's cached copies through restore-keys
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: projects/release/.cache/upstream
key: fluxer-source-${{ hashFiles('projects/release/upstream/manifest.json') }}
restore-keys: fluxer-source-
- name: Build the SDK and documentation
id: build
if: steps.scope.outputs.run == 'true'
run: pnpm build
working-directory: projects
- name: Read the locked Playwright version
id: playwright
if: steps.scope.outputs.run == 'true'
run: printf 'version=%s\n' "$(node --print 'require("./web/node_modules/playwright/package.json").version')" >> "$GITHUB_OUTPUT"
working-directory: projects
- name: Restore Playwright browsers
id: browser_cache
if: steps.scope.outputs.run == 'true'
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ steps.playwright.outputs.version }}-chromium
- name: Install browser and system dependencies
id: browser_install
if: steps.scope.outputs.run == 'true'
env:
BROWSER_CACHED: ${{ steps.browser_cache.outputs.cache-hit }}
run: |
if [ "$BROWSER_CACHED" = true ]; then
pnpm --filter fluxerly-docs exec playwright install-deps chromium
else
pnpm --filter fluxerly-docs exec playwright install --with-deps chromium
fi
working-directory: projects
- name: Restore the kept release snapshots
id: release_snapshots_cache
if: github.event_name == 'push'
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: projects/web/.cache/releases
key: release-snapshots-${{ github.sha }}
restore-keys: release-snapshots-
- name: Keep a copy of each release snapshot the website imports
id: release_snapshots
# The website workflow restores these copies and checks each against the fresh release metadata, so a deploy
# downloads only snapshots published since. A failed read here costs that deploy the downloads, not this Check
if: github.event_name == 'push'
continue-on-error: true
env:
GH_TOKEN: ${{ github.token }}
run: node web/scripts/fetch-releases.js --cache-only
working-directory: projects
- name: Save the release snapshots when they changed
id: release_snapshots_save
if: >-
github.event_name == 'push' && steps.release_snapshots.outcome == 'success' &&
hashFiles('projects/web/.cache/releases/*.json') != '' &&
steps.release_snapshots_cache.outputs.cache-matched-key != format('release-snapshots-{0}', hashFiles('projects/web/.cache/releases/*.json'))
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: projects/web/.cache/releases
key: release-snapshots-${{ hashFiles('projects/web/.cache/releases/*.json') }}
- name: Check documentation in a browser
id: browser
if: steps.scope.outputs.run == 'true'
env:
# Every run tests only what the changed files reach on every screen size. The Screens workflow tests every
# screen after each push to main that changes the website's inputs
EVENT_NAME: ${{ github.event_name }}
PULL_REQUEST_BASE: ${{ github.event.pull_request.base.sha }}
PUSH_BEFORE: ${{ github.event.before }}
run: |
# A pull request compares with its base commit and a push with the commit it started from. A new branch, whose
# start is all zeros, and a manual run compare with where HEAD left main
if [ "$EVENT_NAME" = pull_request ]; then
base="$PULL_REQUEST_BASE"
elif [ "$EVENT_NAME" = push ] && [ -n "${PUSH_BEFORE//0/}" ]; then
base="$PUSH_BEFORE"
else
base=origin/main
fi
pnpm --filter fluxerly-docs test:browser --changed --base="$base"
pnpm --filter fluxerly-docs test:versions
working-directory: projects
- name: Summarize browser checks
if: always()
uses: $/.github/actions/summary
with:
title: Documentation browser checks
steps: ${{ toJSON(steps) }}
checks: >-
${{ steps.scope.outputs.run == 'false' && '{"Website input change check": "scope"}' || '{"Website input change check": "scope", "SDK and documentation build": "build", "Documentation screens in Chromium and version checks": "browser"}' }}
details: >-
${{ steps.scope.outputs.run == 'false' && '{"Screens tested": "None, no website inputs changed"}' || '{"Screens tested": "Those the changed files reach, on every screen size"}' }}
next: Nothing to fix here. The check job combines this result with the other jobs
failure: Fix the failed screens or version checks named in the browser step log and push
reproduce: |-
cd projects
pnpm build
pnpm --filter fluxerly-docs test:browser --changed --base=origin/main
pnpm --filter fluxerly-docs test:versions
consumers:
name: ${{ matrix.name }}
needs: release-reuse
if: ${{ !cancelled() && (needs.release-reuse.result != 'success' || (needs.release-reuse.outputs.reused != 'true' && needs.release-reuse.outputs.version_only != 'true')) }}
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
max-parallel: 2
matrix:
include:
- name: SDK consumers on the development Node version
- name: SDK consumers on the declared Node floor
runtime: node@26.13.0
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
id: checkout
with:
persist-credentials: false
- uses: pnpm/setup@731dfb6463bbd11c11fd0ee11fe00ed0e36d48a1 # v3.2.0
id: setup
with:
working-directory: projects
require-lockfile: true
cache: true
runtime: ${{ matrix.runtime }}
- name: Build the SDK on the selected Node version
id: build
run: pnpm --filter @neontechspace/fluxerly build
working-directory: projects
# The sdk job runs the suite on the development Node version, so this covers the declared engines floor
- name: Run the SDK test suite on the declared Node floor
id: test
if: matrix.runtime
run: pnpm --filter @neontechspace/fluxerly test
working-directory: projects
# The sdk job's check runs the example bots' tests on the development Node version
- name: Run the example bots' tests on the declared Node floor
id: examples
if: matrix.runtime
run: pnpm --filter @neontechspace/fluxerly test:examples
working-directory: projects
# The sdk job's check already packs and runs these consumers on the development Node version
- name: Check packed JavaScript and TypeScript consumers on the declared Node floor
id: package
if: matrix.runtime
run: pnpm --filter @neontechspace/fluxerly test:package
working-directory: projects
- name: Check npm-installed consumers
id: npm
run: pnpm --filter @neontechspace/fluxerly test:npm
working-directory: projects
- name: Summarize consumer compatibility
if: always()
uses: $/.github/actions/summary
with:
title: ${{ matrix.name }}
steps: ${{ toJSON(steps) }}
# The development version's tests and packed consumers run in the SDK checks job, so only the floor job lists them
checks: >-
${{ matrix.runtime && '{"Build the SDK": "build", "SDK test suite": "test", "Example bot tests": "examples", "Packed JavaScript and TypeScript consumers": "package", "npm-installed consumers": "npm"}' || '{"Build the SDK": "build", "npm-installed consumers": "npm"}' }}
details: '{"Node version": ${{ toJSON(matrix.runtime || ''projects/.node-version'') }}}'
next: Nothing to fix here. The npm release checks job needs both Node versions to pass
failure: Fix the failed check for this Node version and push. The other Node version runs on its own
reproduce: |-
cd projects
pnpm --filter @neontechspace/fluxerly build
pnpm --filter @neontechspace/fluxerly test:npm
npm-check:
name: npm release checks
# The certificate of everything a published package needs: the SDK checks, the release tooling checks and the consumers
# on both Node versions. It never waits for the website, workflow lint or the browser, so npm evidence and the Stable
# start do not depend on them. The status function lets it report a skipped or cancelled producer instead of skipping
needs: [release-reuse, sdk, release, consumers]
if: always()
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Summarize npm release checks and enforce the result
shell: bash
env:
REUSE_RESULT: ${{ needs.release-reuse.result }}
REUSED: ${{ needs.release-reuse.outputs.reused }}
RUN_ID: ${{ needs.release-reuse.outputs.run_id }}
RUN_ATTEMPT: ${{ needs.release-reuse.outputs.run_attempt }}
RUN_URL: ${{ needs.release-reuse.outputs.run_url }}
VERSION_ONLY: ${{ needs.release-reuse.outputs.version_only }}
PARENT_RUN_ID: ${{ needs.release-reuse.outputs.parent_run_id }}
PARENT_RUN_ATTEMPT: ${{ needs.release-reuse.outputs.parent_run_attempt }}
PARENT_RUN_URL: ${{ needs.release-reuse.outputs.parent_run_url }}
SDK_RESULT: ${{ needs.sdk.result }}
RELEASE_RESULT: ${{ needs.release.result }}
CONSUMERS_RESULT: ${{ needs.consumers.result }}
run: |
# A reference is complete only with a numeric run ID and attempt and the URL of that run
complete() {
[[ "$1" =~ ^[1-9][0-9]*$ && "$2" =~ ^[1-9][0-9]*$ && "$3" == "https://github.com/$GITHUB_REPOSITORY/actions/runs/$1" ]]
}
# A reuse counts only from a lookup job that succeeded, because a failed job can still leave outputs behind. A
# failed lookup runs the actual checks, and their success is as good as any reuse
mode=ordinary
if [ "$REUSE_RESULT" = success ]; then
if [ "$REUSED" = true ] && complete "$RUN_ID" "$RUN_ATTEMPT" "$RUN_URL"; then
mode=reuse
elif [ "$VERSION_ONLY" = true ] && complete "$PARENT_RUN_ID" "$PARENT_RUN_ATTEMPT" "$PARENT_RUN_URL"; then
mode=version-only
fi
fi
# The wanted result of the SDK, release tooling and consumer jobs. A version-only change reuses the SDK and
# consumer checks of its parent commit and runs the release tooling checks itself
case "$mode" in
reuse) want_sdk=skipped want_release=skipped want_consumers=skipped ;;
version-only) want_sdk=skipped want_release=success want_consumers=skipped ;;
*) want_sdk=success want_release=success want_consumers=success ;;
esac
status=0
failed=""
table=""
judge() {
case "$2" in
success) word=passed ;;
failure) word=failed ;;
cancelled | skipped) word="$2" ;;
*) word="not reported" ;;
esac
table+="| $1 | $word |"$'\n'
if [ "$2" != "$3" ]; then
status=1
failed+="${failed:+, }$1"
fi
}
judge "SDK checks" "$SDK_RESULT" "$want_sdk"
judge "Release tooling checks" "$RELEASE_RESULT" "$want_release"
judge "SDK consumers on both Node versions" "$CONSUMERS_RESULT" "$want_consumers"
{
printf '## npm release checks\n\n'
if [ "$status" -ne 0 ]; then
printf 'Did not pass: %s\n\n' "$failed"
elif [ "$mode" = reuse ]; then
printf 'Passed by reuse. The npm release checks of an earlier Check run passed for identical content, so the SDK, release tooling and consumer jobs did not run again\n\nReused run: %s\n\n' "$RUN_URL"
elif [ "$mode" = version-only ]; then
printf 'Passed as a version-only change. Only release version files changed from the parent commit, whose npm release checks passed, so only the release tooling checks ran\n\nParent commit run: %s\n\n' "$PARENT_RUN_URL"
else
printf 'The SDK checks, the release tooling checks and both Node consumer versions passed\n\n'
fi
printf '| Job | Result |\n| --- | --- |\n%s\n### Next action\n\n' "$table"
if [ "$status" -eq 0 ]; then
printf 'Nothing to fix. Release preparation reads this result, not the website checks\n'
else
printf 'Open the jobs listed above, their summaries name the failing checks and how to reproduce them. Then push a fix or re-run all jobs\n'
fi
} >> "$GITHUB_STEP_SUMMARY"
exit "$status"
check:
name: check
needs: [reuse, npm-check, tooling, workflows, browser]
if: always()
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Summarize required checks and enforce the result
shell: bash
env:
REUSE_RESULT: ${{ needs.reuse.result }}
REUSED: ${{ needs.reuse.outputs.reused }}
RUN_ID: ${{ needs.reuse.outputs.run_id }}
RUN_ATTEMPT: ${{ needs.reuse.outputs.run_attempt }}
RUN_URL: ${{ needs.reuse.outputs.run_url }}
VERSION_ONLY: ${{ needs.reuse.outputs.version_only }}
PARENT_RUN_ID: ${{ needs.reuse.outputs.parent_run_id }}
PARENT_RUN_ATTEMPT: ${{ needs.reuse.outputs.parent_run_attempt }}
PARENT_RUN_URL: ${{ needs.reuse.outputs.parent_run_url }}
NPM_RESULT: ${{ needs.npm-check.result }}
TOOLING_RESULT: ${{ needs.tooling.result }}
WORKFLOWS_RESULT: ${{ needs.workflows.result }}
BROWSER_RESULT: ${{ needs.browser.result }}
run: |
# A reference is complete only with a numeric run ID and attempt and the URL of that run
complete() {
[[ "$1" =~ ^[1-9][0-9]*$ && "$2" =~ ^[1-9][0-9]*$ && "$3" == "https://github.com/$GITHUB_REPOSITORY/actions/runs/$1" ]]
}
# A reuse counts only from a lookup job that succeeded, because a failed job can still leave outputs behind. A
# failed lookup runs the actual checks, and their success is as good as any reuse
mode=ordinary
if [ "$REUSE_RESULT" = success ]; then
if [ "$REUSED" = true ] && complete "$RUN_ID" "$RUN_ATTEMPT" "$RUN_URL"; then
mode=reuse
elif [ "$VERSION_ONLY" = true ] && complete "$PARENT_RUN_ID" "$PARENT_RUN_ATTEMPT" "$PARENT_RUN_URL"; then
mode=version-only
fi
fi
# The npm release checks always count, because they report their own reuse. A reuse of a whole Check skips the
# other jobs. A version-only change runs the website and contribution checks, because the website builds its
# changelog page and search from the new notes, and skips workflow lint and the browser
case "$mode" in
reuse) want_tooling=skipped want_workflows=skipped want_browser=skipped ;;
version-only) want_tooling=success want_workflows=skipped want_browser=skipped ;;
*) want_tooling=success want_workflows=success want_browser=success ;;
esac
status=0
failed=""
table=""
judge() {
case "$2" in
success) word=passed ;;
failure) word=failed ;;
cancelled | skipped) word="$2" ;;
*) word="not reported" ;;
esac
table+="| $1 | $word |"$'\n'
if [ "$2" != "$3" ]; then
status=1
failed+="${failed:+, }$1"
fi
}
judge "npm release checks" "$NPM_RESULT" success
judge "Website and contribution checks" "$TOOLING_RESULT" "$want_tooling"
judge "Workflow lint and security audit" "$WORKFLOWS_RESULT" "$want_workflows"
judge "Documentation browser checks" "$BROWSER_RESULT" "$want_browser"
{
printf '## Required checks\n\n'
if [ "$status" -ne 0 ]; then
printf 'Did not pass: %s\n\n' "$failed"
elif [ "$mode" = reuse ]; then
printf 'Passed by reuse. An earlier Check run passed for identical content, so the website, workflow lint and browser jobs did not run again\n\nReused run: %s\n\n' "$RUN_URL"
elif [ "$mode" = version-only ]; then
printf 'Passed as a version-only change. Only release version files changed from the parent commit, whose content passed Check, so only the npm release checks and the website and contribution checks ran\n\nParent commit Check: %s\n\n' "$PARENT_RUN_URL"
else
printf 'All four required jobs passed, including the npm release checks on both Node consumer versions\n\n'
fi
printf '| Job | Result |\n| --- | --- |\n%s\n### Next action\n\n' "$table"
if [ "$status" -eq 0 ]; then
printf 'Nothing to fix. Live sandbox checks and publishing are not part of Check\n'
else
printf 'Open the jobs listed above, their summaries name the failing checks and how to reproduce them. Then push a fix or re-run all jobs\n'
fi
} >> "$GITHUB_STEP_SUMMARY"
exit "$status"
release-trigger:
name: Release preparation trigger
needs: npm-check
# Release preparation reads the npm release checks, so only they gate its start: A website or workflow lint failure
# never blocks a release. The default condition would skip this job when a reuse skipped the jobs behind the npm
# release checks, so it reads that result itself
if: ${{ !cancelled() && needs.npm-check.result == 'success' && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
actions: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
id: checkout
with:
persist-credentials: false
- uses: pnpm/setup@731dfb6463bbd11c11fd0ee11fe00ed0e36d48a1 # v3.2.0
id: setup
with:
working-directory: projects
install: false
- name: Detect a pushed SDK version that npm does not have
id: trigger
env:
GH_TOKEN: ${{ github.token }}
BEFORE_SHA: ${{ github.event.before }}
AFTER_SHA: ${{ github.sha }}
run: node projects/release/github.js prepare-trigger
- name: Dispatch Release prepare for the pushed source
id: dispatch
if: steps.trigger.outputs.prepare == 'true'
env:
GH_TOKEN: ${{ github.token }}
SOURCE_COMMIT: ${{ github.sha }}
run: gh workflow run release-prepare.yml --repo "$GITHUB_REPOSITORY" --ref main -f source_ref="$SOURCE_COMMIT"
- name: Summarize the release preparation trigger
if: always()
uses: $/.github/actions/summary
with:
title: Release preparation trigger
steps: ${{ toJSON(steps) }}
checks: '{"Unpublished SDK version detected": "trigger", "Release prepare dispatched": "dispatch"}'
details: >-
{"SDK version": ${{ toJSON(steps.trigger.outputs.version) }}, "Release prepare dispatched": ${{ toJSON(steps.trigger.outputs.prepare) }}}
next: ${{ steps.trigger.outputs.prepare == 'true' && 'Review the candidate in the Release prepare run it started before publishing' || 'No release to prepare. This push did not bring a Stable SDK version that npm lacks' }}
failure: Release prepare was not started for this push. Rerun this job, or start Release prepare from the Actions tab with this commit as the source