diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 88fe7bf..cd03377 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,20 +7,16 @@ on: pull_request: branches: [main] -# Allow one concurrent deployment; newer runs supersede in-progress ones. -concurrency: - group: pages - cancel-in-progress: false - jobs: build: name: Build & Validate runs-on: ubuntu-latest + timeout-minutes: 10 steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: '20' + node-version-file: '.nvmrc' cache: 'npm' - run: npm ci - run: npm run build @@ -31,26 +27,45 @@ jobs: name: Version matches tag if: startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-latest + timeout-minutes: 10 steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: '20' + node-version-file: '.nvmrc' - run: bash scripts/check-version.sh "${GITHUB_REF_NAME}" test: name: E2E Tests runs-on: ubuntu-latest needs: build + timeout-minutes: 15 steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: '20' + node-version-file: '.nvmrc' cache: 'npm' - run: npm ci - run: npm run build - - run: npx playwright install chromium --with-deps + # Cache the Playwright browser by its version so we don't re-download + # Chromium on every run (the download/apt step is the slowest and most + # stall-prone part of CI). On a cache hit we only install the system deps. + - name: Resolve Playwright version + id: pw + run: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> "$GITHUB_OUTPUT" + - name: Cache Playwright browsers + id: pw-cache + uses: actions/cache@v4 + with: + path: ~/.cache/ms-playwright + key: playwright-${{ runner.os }}-${{ steps.pw.outputs.version }} + - name: Install Playwright (browser + system deps) + if: steps.pw-cache.outputs.cache-hit != 'true' + run: npx playwright install chromium --with-deps + - name: Install Playwright system deps (cached browser) + if: steps.pw-cache.outputs.cache-hit == 'true' + run: npx playwright install-deps chromium - run: npm test # Assemble the full Pages site (root = newest release tag, /preview = main) @@ -60,6 +75,13 @@ jobs: needs: [build, test] if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) runs-on: ubuntu-latest + timeout-minutes: 15 + # Serialize deployments only (one Pages deploy at a time); queued deploys + # wait rather than cancel. Scoped to this job so a slow/stuck test run never + # blocks the whole CI pipeline. + concurrency: + group: pages + cancel-in-progress: false permissions: contents: read pages: write @@ -74,7 +96,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-node@v4 with: - node-version: '20' + node-version-file: '.nvmrc' cache: 'npm' - run: npm ci - name: Assemble Pages site (release + preview) diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..a45fd52 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +24 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3f92fcc..1f3aade 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,8 +3,8 @@ ## Getting Started ```bash -git clone https://github.com/opencoachingformat/editor.git -cd editor +git clone https://github.com/opencoachingformat/ocf-editor.git +cd ocf-editor npm install npm run build open index.html diff --git a/README.md b/README.md index 1bd3b01..b0ebcb9 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [](LICENSE) [](opencoachingformat-v1.schema.json) -[](https://github.com/opencoachingformat/editor/actions/workflows/ci.yml) +[](https://github.com/opencoachingformat/ocf-editor/actions/workflows/ci.yml) Reference web editor for the [Open Coaching Format](https://github.com/opencoachingformat/spec) — an open standard for basketball drill diagrams and animations. @@ -29,8 +29,8 @@ Reference web editor for the [Open Coaching Format](https://github.com/opencoach ## Quick Start ```bash -git clone https://github.com/opencoachingformat/editor.git -cd editor +git clone https://github.com/opencoachingformat/ocf-editor.git +cd ocf-editor npm install npm run build # Open index.html in your browser @@ -73,7 +73,8 @@ Until the first release tag exists, the root mirrors the preview build. To cut a release: -1. Bump `version` in `package.json` (and the `.app-version` badge in `index.html`). +1. Bump `version` in `package.json` — the only place it lives. The build injects + it into the in-app badge (`scripts/build.js`), and the E2E test derives it. 2. Commit and merge to `main`. 3. Tag the merge commit and push the tag: ```bash diff --git a/doc/arc42.md b/doc/arc42.md index f8b8d09..57f5487 100644 --- a/doc/arc42.md +++ b/doc/arc42.md @@ -7,7 +7,7 @@ animations. > Status: living document. Last substantive update reflects work up to and > including the mobile-touch / rendering fixes and the release/preview CI -> pipeline (app version `0.2.0`). +> pipeline (app version `0.2.1`). --- @@ -300,7 +300,8 @@ flowchart TD ### Release process -1. Bump `version` in `package.json` and the `.app-version` badge in `index.html`. +1. Bump `version` in `package.json` (single source — the build injects it into + the badge and the E2E test derives it). 2. Merge to `main` (updates `/preview`). 3. `git tag vX.Y.Z && git push origin vX.Y.Z` → version-check gate → deploy to root. @@ -321,8 +322,11 @@ flowchart TD notifications; the singleton is reset in tests for order-independence. - **Validation.** Structural validator with no external deps; CI validates all `examples/*.ocf.json`. -- **Versioning.** Version lives in `package.json`, the in-app badge, and the - version test; the CI gate keeps a release tag consistent with `package.json`. +- **Versioning.** The version lives solely in `package.json`. `scripts/build.js` + injects it into the bundle at build time (esbuild `define` → `__APP_VERSION__`, + read from `$npm_package_version`), `main.js` writes it into the badge, and the + E2E test derives the expected value from `package.json`. The CI gate keeps a + release tag consistent with `package.json`. --- diff --git a/index.html b/index.html index 921ebfb..527126f 100644 --- a/index.html +++ b/index.html @@ -23,7 +23,7 @@