From 01bc09e1d6d54d0c4f34e18bc5a1c79b3c05cc5d Mon Sep 17 00:00:00 2001 From: DWAA1660 Date: Wed, 18 Nov 2026 15:40:40 -0700 Subject: [PATCH] ci(workflows): shorten required CI and nightly release paths --- .github/workflows/build-website.yml | 1 + .github/workflows/ci.yml | 19 +++- .github/workflows/nightly-release.yml | 35 +++++-- .github/workflows/website-deploy.yml | 130 +++++++++++++++++++++++++ .github/workflows/website-pipeline.yml | 118 ++++++++++------------ docs/releasing.md | 6 +- 6 files changed, 229 insertions(+), 80 deletions(-) create mode 100644 .github/workflows/website-deploy.yml diff --git a/.github/workflows/build-website.yml b/.github/workflows/build-website.yml index 55b3fb9b..436c540d 100644 --- a/.github/workflows/build-website.yml +++ b/.github/workflows/build-website.yml @@ -9,6 +9,7 @@ on: - ".github/workflows/build-website.yml" - ".github/workflows/deploy-website.yml" - ".github/workflows/website-pipeline.yml" + - ".github/workflows/website-deploy.yml" - ".github/web-build/**" - "Cargo.toml" - "Cargo.lock" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 22a83ae3..5cb75ea0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -288,6 +288,16 @@ jobs: free -h df -h / - run: cargo xtask coverage + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: coverage-linux-${{ github.run_attempt }} + path: target/coverage-summary.json + if-no-files-found: error + - name: Report missing coverage evidence + if: failure() + run: | + echo "::warning title=Coverage unavailable::The advisory coverage job could not produce or upload its report." + echo "Advisory coverage report unavailable. See this job's logs." >> "$GITHUB_STEP_SUMMARY" # The Android app (android/): clippy for the arm64 target, which also builds every crate the # APK links, so a change that breaks the Android build fails here. The APK itself is built by @@ -311,7 +321,8 @@ jobs: ci-status: name: CI runs-on: ubuntu-latest - needs: [changes, fmt, clippy, platform-build-test, android, voice, static, coverage] + # Coverage is advisory and can finish after the required check. + needs: [changes, fmt, clippy, platform-build-test, android, voice, static] if: always() steps: - name: Check CI result @@ -331,11 +342,15 @@ jobs: echo "The change filter did not succeed ($CHANGES)" exit 1 fi + if [[ "$CODE" != "true" && "$CODE" != "false" ]]; then + echo "Unexpected change filter output: '$CODE'" + exit 1 + fi for result in "$FMT" "$STATIC"; do if [[ "$result" != "success" ]]; then echo "Quality checks failed"; exit 1; fi done for result in "$CLIPPY" "$BUILD_TEST" "$ANDROID" "$VOICE"; do - if [[ "$CODE" == "true" && "$result" != "success" ]] || [[ "$result" == "failure" || "$result" == "cancelled" ]]; then + if [[ "$result" != "success" && ! ( "$CODE" == "false" && "$result" == "skipped" ) ]]; then echo "Quality checks failed" exit 1 fi diff --git a/.github/workflows/nightly-release.yml b/.github/workflows/nightly-release.yml index 5bc66bb6..deac33d2 100644 --- a/.github/workflows/nightly-release.yml +++ b/.github/workflows/nightly-release.yml @@ -13,8 +13,8 @@ # 2. test: builds and runs the workspace tests on the tagged commit. # 3. packaging: the Packaging workflow on the tagged commit (Windows, Linux x86_64 and aarch64, # macOS Apple Silicon and Intel, Android arm64). -# 4. website: the Website pipeline on the tagged commit, deployed to production. Its web build -# is also kept as a release asset. +# 4. website: build the tagged commit alongside tests and packaging. After all three pass, +# deploy the verified site to production. The web ZIP is also a release asset. # 5. release: publishes GitHub Release v, marked latest, with every package and one # SHA256SUMS.txt. # @@ -58,6 +58,7 @@ jobs: release: ${{ steps.decide.outputs.release }} version: ${{ steps.decide.outputs.version }} tag: ${{ steps.decide.outputs.tag }} + sha: ${{ steps.tag.outputs.sha }} env: GH_TOKEN: ${{ github.token }} steps: @@ -151,6 +152,7 @@ jobs: git status --short - name: Commit and push the tag (main is not touched) + id: tag if: steps.decide.outputs.release == 'true' env: TAG: ${{ steps.decide.outputs.tag }} @@ -163,6 +165,7 @@ jobs: git commit -q -m "release: v$VERSION" -m "Nightly release of main at $(git rev-parse --short HEAD)." git tag -f -a "$TAG" -m "NoteCraft $TAG" git push --force origin "refs/tags/$TAG" + echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" echo "### NoteCraft $TAG (\`$(git rev-parse --short HEAD)\`, main at \`$(git rev-parse --short HEAD~1)\`)" >>"$GITHUB_STEP_SUMMARY" test: @@ -176,7 +179,7 @@ jobs: steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: - ref: ${{ needs.prepare.outputs.tag }} + ref: ${{ needs.prepare.outputs.sha }} - name: Install Linux build dependencies run: | sudo apt-get update @@ -203,26 +206,40 @@ jobs: attestations: write uses: ./.github/workflows/packaging.yml with: - ref: ${{ needs.prepare.outputs.tag }} + ref: ${{ needs.prepare.outputs.sha }} # The Android release key, when the repository has one (packaging.yml). secrets: inherit website: - name: Website - needs: [prepare, test, packaging] + name: Build website + needs: prepare + if: needs.prepare.outputs.release == 'true' permissions: contents: read uses: ./.github/workflows/website-pipeline.yml with: - deploy: true - ref: ${{ needs.prepare.outputs.tag }} + deploy: false + ref: ${{ needs.prepare.outputs.sha }} artifact-name: notecraft-web + upload-site: true + + website-deploy: + name: Deploy website + needs: [prepare, test, packaging, website] + permissions: + contents: read + uses: ./.github/workflows/website-deploy.yml + with: + artifact-id: ${{ needs.website.outputs.site-artifact-id }} + site-sha256: ${{ needs.website.outputs.site-sha256 }} + source-sha: ${{ needs.prepare.outputs.sha }} + version: ${{ needs.prepare.outputs.version }} secrets: AZURE_STATIC_WEB_APPS_API_TOKEN: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} release: name: Publish the GitHub Release - needs: [prepare, test, packaging, website] + needs: [prepare, test, packaging, website-deploy] runs-on: ubuntu-24.04 timeout-minutes: 30 permissions: diff --git a/.github/workflows/website-deploy.yml b/.github/workflows/website-deploy.yml new file mode 100644 index 00000000..a56a9cd9 --- /dev/null +++ b/.github/workflows/website-deploy.yml @@ -0,0 +1,130 @@ +name: Deploy verified website + +on: + workflow_call: + inputs: + artifact-id: + required: true + type: string + site-sha256: + required: true + type: string + source-sha: + required: true + type: string + version: + required: true + type: string + secrets: + AZURE_STATIC_WEB_APPS_API_TOKEN: + required: true + +permissions: + contents: read + +jobs: + deploy: + runs-on: ubuntu-latest + concurrency: + group: production-website-deploy + cancel-in-progress: false + steps: + - name: Require one site artifact ID + env: + SITE_ARTIFACT_ID: ${{ inputs.artifact-id }} + run: | + [[ "$SITE_ARTIFACT_ID" =~ ^[1-9][0-9]*$ ]] + + - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 + with: + artifact-ids: ${{ inputs.artifact-id }} + # ID-based downloads otherwise add a directory named after the artifact. + merge-multiple: true + path: ${{ runner.temp }}/website-artifact + + - name: Verify the site archive and its source + env: + SITE_SHA256: ${{ inputs.site-sha256 }} + SOURCE_SHA: ${{ inputs.source-sha }} + NOTECRAFT_VERSION: ${{ inputs.version }} + run: | + set -euo pipefail + [[ "$SOURCE_SHA" =~ ^[0-9a-f]{40}$ ]] + [[ "$SITE_SHA256" =~ ^[0-9a-f]{64}$ ]] + [[ -n "$NOTECRAFT_VERSION" ]] + cd "$RUNNER_TEMP/website-artifact" + [[ "$(cat source-sha.txt)" == "$SOURCE_SHA" ]] + [[ "$(cat version.txt)" == "$NOTECRAFT_VERSION" ]] + printf '%s site.tar\n' "$SITE_SHA256" | sha256sum -c - + mkdir "$GITHUB_WORKSPACE/website" + tar -xf site.tar -C "$GITHUB_WORKSPACE/website" + test -f "$GITHUB_WORKSPACE/website/index.html" + test -f "$GITHUB_WORKSPACE/website/demo/index.html" + test -f "$GITHUB_WORKSPACE/website/demo/welcome-notebook.zip" + + - uses: Azure/static-web-apps-deploy@v1 + with: + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} + repo_token: ${{ github.token }} + action: upload + app_location: "website" + output_location: "" + skip_app_build: true + + - name: Verify deployed production demo version + env: + NOTECRAFT_VERSION: ${{ inputs.version }} + VERIFY_QUERY: ${{ inputs.source-sha }} + run: | + python3 - <<'PY' + import os + import re + import sys + import time + import zipfile + from io import BytesIO + from urllib.error import URLError + from urllib.parse import urljoin + from urllib.request import urlopen + + base = "https://notecraft.cloud/demo/" + version = os.environ["NOTECRAFT_VERSION"].encode() + query = "?release-check=" + os.environ["VERIFY_QUERY"] + last_error = "no attempt made" + for attempt in range(1, 13): + try: + with urlopen(base + query, timeout=30) as response: + html = response.read().decode("utf-8") + match = re.search(r"['\"](\./[^'\"]+\.wasm)['\"]", html) + if not match: + raise RuntimeError("deployed demo index does not reference a WASM file") + wasm_url = urljoin(base, match.group(1)) + query + with urlopen(wasm_url, timeout=60) as response: + wasm = response.read() + if version not in wasm: + last_error = f"live WASM does not contain NoteCraft {version.decode()}" + raise RuntimeError(last_error) + with urlopen(base + "welcome-notebook.zip" + query, timeout=60) as response: + archive_bytes = response.read() + with zipfile.ZipFile(BytesIO(archive_bytes)) as notebook: + html = notebook.read("html/00-start/welcome/index.html").decode("utf-8") + cmgfm = notebook.read("cmgfm/00-start/welcome/index.md").decode("utf-8") + names = notebook.namelist() + title = f"Welcome to NoteCraft (Ver {version.decode()})" + if title not in html or title not in cmgfm: + last_error = f"live Welcome notebook formats do not match NoteCraft {version.decode()}" + raise RuntimeError(last_error) + if not all(name in names for name in ( + "html/_node.toml", "cmgfm/_node.toml", + "html/00-start/welcome/index.html", "cmgfm/00-start/welcome/index.md", + )): + last_error = "live Welcome notebook must contain both generated formats" + raise RuntimeError(last_error) + print(f"Live demo at {wasm_url} and both Welcome notebook formats embed NoteCraft {version.decode()}") + sys.exit(0) + except (URLError, TimeoutError, RuntimeError, zipfile.BadZipFile, KeyError, UnicodeDecodeError) as error: + last_error = str(error) + if attempt < 12: + time.sleep(10) + sys.exit(f"Live demo version verification failed after {attempt} attempts: {last_error}") + PY diff --git a/.github/workflows/website-pipeline.yml b/.github/workflows/website-pipeline.yml index 00caf091..3d04c38f 100644 --- a/.github/workflows/website-pipeline.yml +++ b/.github/workflows/website-pipeline.yml @@ -16,8 +16,8 @@ # all 43 patches apply, `cargo check --target wasm32-unknown-unknown` passes, and a full `trunk build # --release` (the playground-web profile: LTO fat, one codegen unit) produces a working demo. # -# Shared website pipeline called by two workflows: PR builds and the separate manual deployment. -# The PR workflow does not receive the Azure token; only the manual workflow can request deployment. +# PRs build and verify the site. Nightly releases build it early and deploy it after +# packaging and tests. Manual deployments build and deploy in the same workflow run. # # Needs one repository secret: AZURE_STATIC_WEB_APPS_API_TOKEN (the Azure Static Web App's deployment # token — create the Free-tier resource first, then copy its token here; never commit it). Set on @@ -42,6 +42,15 @@ on: required: false type: string default: "" + upload-site: + description: Upload the verified site for deployment by the caller. + type: boolean + default: false + outputs: + site-artifact-id: + value: ${{ jobs.build.outputs.site-artifact-id }} + site-sha256: + value: ${{ jobs.build.outputs.site-sha256 }} secrets: AZURE_STATIC_WEB_APPS_API_TOKEN: required: false @@ -52,11 +61,20 @@ permissions: jobs: build: runs-on: ubuntu-latest + outputs: + source-sha: ${{ steps.source.outputs.sha }} + version: ${{ steps.version.outputs.value }} + site-artifact-id: ${{ steps.site-upload.outputs.artifact-id }} + site-sha256: ${{ steps.site.outputs.sha256 }} steps: - uses: actions/checkout@v7 with: ref: ${{ inputs.ref || (inputs.deploy && 'main' || github.sha) }} + - name: Record the checked-out commit + id: source + run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" + - name: Install the wasm32 target run: rustup target add wasm32-unknown-unknown @@ -161,71 +179,37 @@ jobs: path: ${{ runner.temp }}/web/*.zip if-no-files-found: error - - uses: Azure/static-web-apps-deploy@v1 - if: inputs.deploy - with: - azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} - repo_token: ${{ github.token }} - action: upload - app_location: "website" - output_location: "" - skip_app_build: true - - - name: Verify deployed production demo version - if: inputs.deploy + - name: Archive the verified site for deployment + id: site + if: inputs.deploy || inputs.upload-site env: + SOURCE_SHA: ${{ steps.source.outputs.sha }} NOTECRAFT_VERSION: ${{ steps.version.outputs.value }} - VERIFY_QUERY: ${{ github.sha }} run: | - python3 - <<'PY' - import os - import re - import sys - import time - import zipfile - from io import BytesIO - from urllib.error import URLError - from urllib.parse import urljoin - from urllib.request import urlopen - - base = "https://notecraft.cloud/demo/" - version = os.environ["NOTECRAFT_VERSION"].encode() - query = "?release-check=" + os.environ["VERIFY_QUERY"] - last_error = "no attempt made" - for attempt in range(1, 13): - try: - with urlopen(base + query, timeout=30) as response: - html = response.read().decode("utf-8") - match = re.search(r"['\"](\./[^'\"]+\.wasm)['\"]", html) - if not match: - raise RuntimeError("deployed demo index does not reference a WASM file") - wasm_url = urljoin(base, match.group(1)) + query - with urlopen(wasm_url, timeout=60) as response: - wasm = response.read() - if version not in wasm: - last_error = f"live WASM does not contain NoteCraft {version.decode()}" - raise RuntimeError(last_error) - with urlopen(base + "welcome-notebook.zip" + query, timeout=60) as response: - archive_bytes = response.read() - with zipfile.ZipFile(BytesIO(archive_bytes)) as notebook: - html = notebook.read("html/00-start/welcome/index.html").decode("utf-8") - cmgfm = notebook.read("cmgfm/00-start/welcome/index.md").decode("utf-8") - names = notebook.namelist() - title = f"Welcome to NoteCraft (Ver {version.decode()})" - if title not in html or title not in cmgfm: - last_error = f"live Welcome notebook formats do not match NoteCraft {version.decode()}" - raise RuntimeError(last_error) - if not all(name in names for name in ( - "html/_node.toml", "cmgfm/_node.toml", - "html/00-start/welcome/index.html", "cmgfm/00-start/welcome/index.md", - )): - last_error = "live Welcome notebook must contain both generated formats" - raise RuntimeError(last_error) - print(f"Live demo at {wasm_url} and both Welcome notebook formats embed NoteCraft {version.decode()}") - sys.exit(0) - except (URLError, TimeoutError, RuntimeError, zipfile.BadZipFile, KeyError, UnicodeDecodeError) as error: - last_error = str(error) - if attempt < 12: - time.sleep(10) - sys.exit(f"Live demo version verification failed after {attempt} attempts: {last_error}") - PY + set -euo pipefail + staging="$RUNNER_TEMP/website-artifact" + mkdir -p "$staging" + tar -C website -cf "$staging/site.tar" . + printf '%s\n' "$SOURCE_SHA" > "$staging/source-sha.txt" + printf '%s\n' "$NOTECRAFT_VERSION" > "$staging/version.txt" + sha256sum "$staging/site.tar" | awk '{print "sha256=" $1}' >> "$GITHUB_OUTPUT" + + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + id: site-upload + if: inputs.deploy || inputs.upload-site + with: + name: website-site-${{ github.run_attempt }} + path: ${{ runner.temp }}/website-artifact/ + if-no-files-found: error + + deploy: + if: inputs.deploy + needs: build + uses: ./.github/workflows/website-deploy.yml + with: + artifact-id: ${{ needs.build.outputs.site-artifact-id }} + site-sha256: ${{ needs.build.outputs.site-sha256 }} + source-sha: ${{ needs.build.outputs.source-sha }} + version: ${{ needs.build.outputs.version }} + secrets: + AZURE_STATIC_WEB_APPS_API_TOKEN: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} diff --git a/docs/releasing.md b/docs/releasing.md index 331891fd..8a879776 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -22,8 +22,10 @@ One run: 5. Runs the Packaging workflow on the tagged commit: Windows x64 (MSI and portable zip), Linux x86_64 and aarch64 (tar.gz, AppImage, deb and rpm), macOS Apple Silicon and Intel (DMG and command line zip), and Android arm64 (APK; see Android signing below). -6. Runs the Website pipeline on the tagged commit and deploys it to notecraft.cloud, including - `/demo/`. The built web app is kept as `notecraft-web-.zip`. +6. Builds and verifies the website for the same tagged commit while Linux tests and packaging + run. Once all three pass, the deploy job downloads the site's artifact, verifies its source + commit, version and checksum, and deploys it to notecraft.cloud. It checks the live `/demo/` + and both Welcome notebook formats. The built web app is kept as `notecraft-web-.zip`. 7. Publishes GitHub Release `v` as a regular release marked latest, with every file above and one `SHA256SUMS.txt`. The notes are a fixed alpha notice plus GitHub's list of merged pull requests.