Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
19 changes: 17 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
35 changes: 26 additions & 9 deletions .github/workflows/nightly-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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<version>, marked latest, with every package and one
# SHA256SUMS.txt.
#
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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 }}
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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:
Expand Down
130 changes: 130 additions & 0 deletions .github/workflows/website-deploy.yml
Original file line number Diff line number Diff line change
@@ -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
Loading
Loading