From 200c39c7764ae2cc815b3843898c9c3da0e63606 Mon Sep 17 00:00:00 2001 From: agent Date: Sat, 21 Nov 2026 17:09:32 -0500 Subject: [PATCH 1/2] Run the CI checks together, and drop the npm cache and audit scripts/ci-checks.sh runs the five definition-of-done checks at the same time in one step, with Types before Production build, and prints each check's output in a group named for it, with an error annotation for each failure. setup-node no longer restores the npm cache, and npm ci skips the audit and funding output. ci.md says where a failed check now appears, and ci.meta.md has the local measurements and the options not taken. Closes #52 Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 15 +++-------- docs/engineering/ci.md | 5 ++-- docs/engineering/ci.meta.md | 27 +++++++++++++++++++- scripts/ci-checks.sh | 51 +++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 15 deletions(-) create mode 100644 scripts/ci-checks.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d55349..d31dea4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,15 +30,6 @@ jobs: - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 26 - cache: npm - - run: npm ci - - name: Lint - run: npm run lint - - name: Formatting - run: npm run format:check - - name: Types - run: npm run typecheck - - name: Tests - run: npm test - - name: Production build - run: npm run build + - run: npm ci --no-audit --no-fund + - name: Lint, formatting, types, tests, build + run: bash scripts/ci-checks.sh diff --git a/docs/engineering/ci.md b/docs/engineering/ci.md index df5883b..9861aaf 100644 --- a/docs/engineering/ci.md +++ b/docs/engineering/ci.md @@ -4,14 +4,14 @@ ## When a run fails -1. **Find the failed step.** Each check is its own step, named as in the definition of done. +1. **Find the failed check.** All five checks run in one step, `Lint, formatting, types, tests, build`. Its log has a group for each check, named as in the definition of done with its `npm run` command and exit code, and an `error` line naming each check that failed, right after that check's group. ```bash gh pr checks gh run view --log-failed ``` -2. **Reproduce it locally** with the same `npm run` command, fix it, and push. Don't re-run a failed job hoping it passes; if a check fails in CI and passes locally, find out why. +2. **Reproduce it locally** with the `npm run` command the group names, or run all five as CI does with `bash scripts/ci-checks.sh`, fix it, and push. Don't re-run a failed job hoping it passes; if a check fails in CI and passes locally, find out why. 3. **Put a ready pull request back to draft** while CI fails, as [Submitting work](workflow/submitting-work.md#draft-until-done) says. ## Updating what CI runs @@ -24,6 +24,7 @@ - **Pin each action to a full commit SHA,** with its release tag in a comment: `uses: actions/checkout@ # v7.0.1`. Choose a release published at least two weeks earlier, as [dependencies](dependencies.md#after-approval) says for packages. Resolve the SHA with `gh api repos///commits/ -q .sha`. - **Use the standard `ubuntu-latest` runner,** never a larger runner. Larger runners are billed even on a public repository. +- **The checks CI runs are listed in [`scripts/ci-checks.sh`](../../scripts/ci-checks.sh).** When the definition of done changes, change the script in the same commit: its `names` and `scripts` lists, and the `check ` lines that start each one. Keep Types running before Production build, not beside it. - **Keep the checks in one job.** Split them into parallel jobs only when a measured run shows one check holding the others up, and say which in the pull request. - **Report the run time** in the pull request that changes `ci.yml`: the total, and the steps that changed. - **A new action or image is a new dependency.** It needs the owner's approval, as [dependencies](dependencies.md) says. diff --git a/docs/engineering/ci.meta.md b/docs/engineering/ci.meta.md index 2b3f305..2bb526d 100644 --- a/docs/engineering/ci.meta.md +++ b/docs/engineering/ci.meta.md @@ -34,9 +34,34 @@ The owner asked for a fast run ("3 to 5 minutes is way too long for a small repo | Post steps (saving the npm cache) and cleanup | 4 s | - **The second run** ([run 44863276153](https://github.com/DetweilerRyan/split/actions/runs/44863276153)), with the npm cache restored, also took 62 s: the cache made Node setup slower (6 s) and didn't shorten `npm ci` (9 s), and the container still took 23 s. Run-to-run variation of a few seconds is normal. +- **The third run** ([run 44948887831](https://github.com/DetweilerRyan/split/actions/runs/44948887831), PR #51, npm cache restored) took 58 s. The checks ran one after another for about 20 s: lint, formatting and types 1.4 s, tests 7.9 s, build 9.9 s. `oxlint` reported 4 threads on the runner. The step-by-step table is in [#52](https://github.com/DetweilerRyan/split/issues/52). - **The container image** saves downloading Chromium on each run, and its system libraries. Pulling it is now the largest step. + +### Running the checks together ([#52](https://github.com/DetweilerRyan/split/issues/52)) + +- **The five checks run at the same time in one step,** through `scripts/ci-checks.sh`. That keeps one image pull and one `npm ci`, which is what ruled out parallel jobs below. The script is plain bash, so it adds no dependency, and it can be run locally. +- **A failure still names its check.** Before #52 each check was its own step, so the failed step's name was the check's name. The script prints each check's output in its own `::group::`, then an `::error::` annotation for each failure, so `gh run view --log-failed` still leads to the check. Tested locally with a misformatted file: exit 1, one error line titled `Formatting failed`, and the other four groups still reported. +- **The logs go to `$RUNNER_TEMP`, outside the checkout,** so oxlint and oxfmt, which walk the checkout, never read a log while it is being written. +- **Types runs before Production build, not beside it.** `tsconfig.json` includes `next-env.d.ts` and `.next/types/**/*.ts`, which `next build` writes. Measured in the sandbox on 2026-11-21 with 4 cores (`taskset -c 0-3`), from a clean state each time: + - `next build` writes all four `.next/types/` files within about 10 ms, 2.5 s into a 7 s build, and `next-env.d.ts` about 5 s in. It doesn't write `tsconfig.tsbuildinfo`. + - From a clean state `tsc` checks none of these files, so CI never type-checked them when Types ran first. After a build, it checks all five, and they pass. + - Types and build run together, with `tsc` started at 13 offsets from 0 to 6 s into the build, three times each: all 39 trials passed. + - So running them together would almost always work. The only failure is `tsc` reading a file in the 10 ms it is half-written, and on a slow runner `tsc` would sometimes check the generated files and sometimes not. Chaining them costs at most the 0.7 s Types takes, so the owner chose determinism over that 0.7 s in the session on 2026-11-21. +- **Measured locally, 4 cores, from a clean state each time:** one after another (two runs) the checks took 11.8 to 12.4 s (tests 4.3 to 5.0 s, build 6.6 s). Together (five runs) they took 10.2 to 10.5 s: tests and build slow each other, to 6.2 to 7.0 s and 9.4 to 9.7 s, and Types then Build is the longest path. The saving is about 2 s locally, less than #52's estimate of 8 to 10 s in CI. All 83 tests passed in every run, and no test took 1 s, against Vitest's default limit of 5 s. +- **Not taken: limiting Vitest's workers** to give the build more CPU. Three runs each on 4 cores: `--maxWorkers=2` changed nothing (tests 7.0 to 7.3 s, build 9.4 to 9.5 s, total 10.2 to 10.3 s). `--maxWorkers=1` sped the build to 8.7 to 8.9 s but slowed tests to 9.9 to 10.5 s, so the total stayed at 9.9 to 10.5 s. +- **Not taken: dropping `npm run typecheck` because `next build` also type-checks.** Next's `runTypeCheck.js` hides errors in `*.test.*`, `*.spec.*`, `__tests__/` and `__mocks__/` files, and stops at the first error, so the tests would no longer be type-checked. +- **Not taken: `typescript.ignoreBuildErrors`.** It saves 1.4 s of build, but a local `next build` would then succeed with type errors. +- **Not taken: a Chromium-only image** to shorten the 17 s pull. It would be a new dependency to maintain, for perhaps 8 s. + +### npm + +- **No npm cache** (`cache: npm` removed from `actions/setup-node` in #52). `npm ci` deletes `node_modules` and unpacks every package again, so a restored cache didn't make it faster in any measured run: 6 s with the cache empty (run 44863104339), 9 s and 9.3 s with it restored (runs 44863276153 and 44948887831). Restoring the 140 MB archive cost 1.2 s, plus a cache check in the post step. Reopen if `npm ci` starts downloading slowly enough that a cache would pay for itself. +- **`npm ci --no-audit --no-fund`.** The audit is a network call, and neither it nor the funding message is part of the definition of done. + +### Other speed decisions + - **Not taken: caching the browsers.** Playwright's [CI docs](https://playwright.dev/docs/ci) say "Caching browser binaries is not recommended, since the amount of time it takes to restore the cache is comparable" to downloading them, and that the Linux system dependencies "are not cacheable". -- **Not taken: parallel jobs.** Each job would pull the image and run `npm ci` again, about 30 s, to save at most the 15 s the checks take after setup. Reopen if a check grows slow enough to dominate. +- **Not taken: parallel jobs.** Each job would pull the image and run `npm ci` again, about 30 s, to save at most the 15 s the checks take after setup. The checks run in parallel inside the one job instead, as above. Reopen if a check grows slow enough to dominate. - **Not taken: caching `.next/cache`.** It saves about 2 s of build. - **Not taken: `microsoft/playwright-github-action`.** Its README marks it deprecated, and the repository was archived on 2025-01-23. - **`concurrency` with `cancel-in-progress`** stops a run when a newer push to the same branch arrives, so nobody waits on an outdated run. diff --git a/scripts/ci-checks.sh b/scripts/ci-checks.sh new file mode 100644 index 0000000..233005c --- /dev/null +++ b/scripts/ci-checks.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +# Runs AGENTS.md's definition-of-done checks at the same time, for .github/workflows/ci.yml. +# Each check's output goes to its own log, printed afterwards in a group named for the check, +# with an error annotation for each check that failed. Types runs before Production build, not +# beside it. Reasons for both are in docs/engineering/ci.meta.md. +set -u + +if [ ! -f package.json ]; then + echo "ERROR: Run this script from the SplitSmart repository root." >&2 + exit 1 +fi + +# Outside the checkout, so lint and formatting never read a log while it is being written. +logs=$(mktemp -d "${RUNNER_TEMP:-${TMPDIR:-/tmp}}/ci-checks.XXXXXX") + +names=('Lint' 'Formatting' 'Types' 'Tests' 'Production build') +scripts=('lint' 'format:check' 'typecheck' 'test' 'build') + +# Runs check $1 and records its exit code and duration in tenths of a second. +check() { + local start end code + start=$(date +%s%N) + npm run "${scripts[$1]}" >"$logs/$1.log" 2>&1 + code=$? + end=$(date +%s%N) + echo "$code $(((end - start) / 100000000))" >"$logs/$1.status" +} + +check 0 & +check 1 & +check 3 & +{ + check 2 + check 4 +} & +wait + +failed=0 +for i in "${!names[@]}"; do + name=${names[$i]} + code=1 tenths=0 + [ -f "$logs/$i.status" ] && read -r code tenths <"$logs/$i.status" + echo "::group::$name (npm run ${scripts[$i]}): exit $code, $((tenths / 10)).$((tenths % 10)) s" + cat "$logs/$i.log" 2>/dev/null + echo "::endgroup::" + if [ "$code" != 0 ]; then + echo "::error title=$name failed::npm run ${scripts[$i]} exited with code $code. Its output is in the '$name' group above." + failed=1 + fi +done +exit $failed From 8b5f28b4c6f8d49fe5659c8322252f87afc12405 Mon Sep 17 00:00:00 2001 From: agent Date: Sat, 21 Nov 2026 17:20:14 -0500 Subject: [PATCH 2/2] Keep CI's steps as they were, and record what #52's changes measured Three CI runs of 200c39c took 64, 58 and 60 s, against 62, 62 and 58 s before. On the runner, tests and build slow each other enough that running the checks together saves little, and run-to-run variation in the image pull and npm ci swamps the cache and audit changes. This restores ci.yml and ci.md, removes scripts/ci-checks.sh, and records the measurements in ci.meta.md as tried and not taken. Closes #52 Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 15 ++++++++--- docs/engineering/ci.md | 5 ++-- docs/engineering/ci.meta.md | 42 ++++++++++++++++-------------- scripts/ci-checks.sh | 51 ------------------------------------- 4 files changed, 37 insertions(+), 76 deletions(-) delete mode 100644 scripts/ci-checks.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d31dea4..4d55349 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,6 +30,15 @@ jobs: - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 26 - - run: npm ci --no-audit --no-fund - - name: Lint, formatting, types, tests, build - run: bash scripts/ci-checks.sh + cache: npm + - run: npm ci + - name: Lint + run: npm run lint + - name: Formatting + run: npm run format:check + - name: Types + run: npm run typecheck + - name: Tests + run: npm test + - name: Production build + run: npm run build diff --git a/docs/engineering/ci.md b/docs/engineering/ci.md index 9861aaf..df5883b 100644 --- a/docs/engineering/ci.md +++ b/docs/engineering/ci.md @@ -4,14 +4,14 @@ ## When a run fails -1. **Find the failed check.** All five checks run in one step, `Lint, formatting, types, tests, build`. Its log has a group for each check, named as in the definition of done with its `npm run` command and exit code, and an `error` line naming each check that failed, right after that check's group. +1. **Find the failed step.** Each check is its own step, named as in the definition of done. ```bash gh pr checks gh run view --log-failed ``` -2. **Reproduce it locally** with the `npm run` command the group names, or run all five as CI does with `bash scripts/ci-checks.sh`, fix it, and push. Don't re-run a failed job hoping it passes; if a check fails in CI and passes locally, find out why. +2. **Reproduce it locally** with the same `npm run` command, fix it, and push. Don't re-run a failed job hoping it passes; if a check fails in CI and passes locally, find out why. 3. **Put a ready pull request back to draft** while CI fails, as [Submitting work](workflow/submitting-work.md#draft-until-done) says. ## Updating what CI runs @@ -24,7 +24,6 @@ - **Pin each action to a full commit SHA,** with its release tag in a comment: `uses: actions/checkout@ # v7.0.1`. Choose a release published at least two weeks earlier, as [dependencies](dependencies.md#after-approval) says for packages. Resolve the SHA with `gh api repos///commits/ -q .sha`. - **Use the standard `ubuntu-latest` runner,** never a larger runner. Larger runners are billed even on a public repository. -- **The checks CI runs are listed in [`scripts/ci-checks.sh`](../../scripts/ci-checks.sh).** When the definition of done changes, change the script in the same commit: its `names` and `scripts` lists, and the `check ` lines that start each one. Keep Types running before Production build, not beside it. - **Keep the checks in one job.** Split them into parallel jobs only when a measured run shows one check holding the others up, and say which in the pull request. - **Report the run time** in the pull request that changes `ci.yml`: the total, and the steps that changed. - **A new action or image is a new dependency.** It needs the owner's approval, as [dependencies](dependencies.md) says. diff --git a/docs/engineering/ci.meta.md b/docs/engineering/ci.meta.md index 2bb526d..ed2d94a 100644 --- a/docs/engineering/ci.meta.md +++ b/docs/engineering/ci.meta.md @@ -37,31 +37,35 @@ The owner asked for a fast run ("3 to 5 minutes is way too long for a small repo - **The third run** ([run 44948887831](https://github.com/DetweilerRyan/split/actions/runs/44948887831), PR #51, npm cache restored) took 58 s. The checks ran one after another for about 20 s: lint, formatting and types 1.4 s, tests 7.9 s, build 9.9 s. `oxlint` reported 4 threads on the runner. The step-by-step table is in [#52](https://github.com/DetweilerRyan/split/issues/52). - **The container image** saves downloading Chromium on each run, and its system libraries. Pulling it is now the largest step. -### Running the checks together ([#52](https://github.com/DetweilerRyan/split/issues/52)) - -- **The five checks run at the same time in one step,** through `scripts/ci-checks.sh`. That keeps one image pull and one `npm ci`, which is what ruled out parallel jobs below. The script is plain bash, so it adds no dependency, and it can be run locally. -- **A failure still names its check.** Before #52 each check was its own step, so the failed step's name was the check's name. The script prints each check's output in its own `::group::`, then an `::error::` annotation for each failure, so `gh run view --log-failed` still leads to the check. Tested locally with a misformatted file: exit 1, one error line titled `Formatting failed`, and the other four groups still reported. -- **The logs go to `$RUNNER_TEMP`, outside the checkout,** so oxlint and oxfmt, which walk the checkout, never read a log while it is being written. -- **Types runs before Production build, not beside it.** `tsconfig.json` includes `next-env.d.ts` and `.next/types/**/*.ts`, which `next build` writes. Measured in the sandbox on 2026-11-21 with 4 cores (`taskset -c 0-3`), from a clean state each time: - - `next build` writes all four `.next/types/` files within about 10 ms, 2.5 s into a 7 s build, and `next-env.d.ts` about 5 s in. It doesn't write `tsconfig.tsbuildinfo`. - - From a clean state `tsc` checks none of these files, so CI never type-checked them when Types ran first. After a build, it checks all five, and they pass. - - Types and build run together, with `tsc` started at 13 offsets from 0 to 6 s into the build, three times each: all 39 trials passed. - - So running them together would almost always work. The only failure is `tsc` reading a file in the 10 ms it is half-written, and on a slow runner `tsc` would sometimes check the generated files and sometimes not. Chaining them costs at most the 0.7 s Types takes, so the owner chose determinism over that 0.7 s in the session on 2026-11-21. -- **Measured locally, 4 cores, from a clean state each time:** one after another (two runs) the checks took 11.8 to 12.4 s (tests 4.3 to 5.0 s, build 6.6 s). Together (five runs) they took 10.2 to 10.5 s: tests and build slow each other, to 6.2 to 7.0 s and 9.4 to 9.7 s, and Types then Build is the longest path. The saving is about 2 s locally, less than #52's estimate of 8 to 10 s in CI. All 83 tests passed in every run, and no test took 1 s, against Vitest's default limit of 5 s. -- **Not taken: limiting Vitest's workers** to give the build more CPU. Three runs each on 4 cores: `--maxWorkers=2` changed nothing (tests 7.0 to 7.3 s, build 9.4 to 9.5 s, total 10.2 to 10.3 s). `--maxWorkers=1` sped the build to 8.7 to 8.9 s but slowed tests to 9.9 to 10.5 s, so the total stayed at 9.9 to 10.5 s. -- **Not taken: dropping `npm run typecheck` because `next build` also type-checks.** Next's `runTypeCheck.js` hides errors in `*.test.*`, `*.spec.*`, `__tests__/` and `__mocks__/` files, and stops at the first error, so the tests would no longer be type-checked. -- **Not taken: `typescript.ignoreBuildErrors`.** It saves 1.4 s of build, but a local `next build` would then succeed with type errors. -- **Not taken: a Chromium-only image** to shorten the 17 s pull. It would be a new dependency to maintain, for perhaps 8 s. +### Tried in [#52](https://github.com/DetweilerRyan/split/issues/52), not taken + +#52 proposed three changes to cut 10 to 13 s: run the five checks at the same time in one step, drop `cache: npm`, and run `npm ci --no-audit --no-fund`. All three were tried in [PR #53](https://github.com/DetweilerRyan/split/pull/53) and none saved measurable time, so the owner chose on 2026-11-21 to keep `ci.yml` as it was and record the results here, since the app may be too small to gain much from tuning CI yet. + +- **Measured in CI.** Commit 200c39c of #53 made all three changes. Three attempts of [run 44955290713](https://github.com/DetweilerRyan/split/actions/runs/44955290713), against the three runs above: -### npm + | Step | Before (3 runs) | All three changes (3 attempts) | + | :-------------------- | --------------: | -----------------------------: | + | Total | 62, 62, 58 s | 64, 58, 60 s | + | Initialize containers | 21, 23, 20 s | 24, 27, 22 s | + | Set up Node 26 | 4, 6, 6 s | 5, 4, 5 s | + | `npm ci` | 6, 9, 9.3 s | 11, 7, 11 s | + | The checks | 15, –, 19 s | 19, 13, 17 s | -- **No npm cache** (`cache: npm` removed from `actions/setup-node` in #52). `npm ci` deletes `node_modules` and unpacks every package again, so a restored cache didn't make it faster in any measured run: 6 s with the cache empty (run 44863104339), 9 s and 9.3 s with it restored (runs 44863276153 and 44948887831). Restoring the 140 MB archive cost 1.2 s, plus a cache check in the post step. Reopen if `npm ci` starts downloading slowly enough that a cache would pay for itself. -- **`npm ci --no-audit --no-fund`.** The audit is a network call, and neither it nor the funding message is part of the definition of done. + The second run's log has no per-check times, so it has no figure for the checks. Run-to-run variation in the container step (7 s) and `npm ci` (5 s) is larger than any of the three changes could save. + +- **Running the checks together.** Each check's output went to its own log, printed afterwards in a `::group::` named for the check, with an `::error::` annotation for each failure. Run together in CI, tests took 9.3 to 14.0 s (7.9 s alone) and the build 11.8 to 17.3 s (9.9 s alone). The 4 threads `oxlint` reports behave like about 2 cores, so the checks mostly took turns. Locally, limited to 4 cores (`taskset -c 0-3`), they went from 11.8–12.4 s to 10.2–10.5 s. Reopen if the checks grow long enough that the runner's cores sit idle while one of them runs. +- **Types beside Production build would almost always work, if it is tried again.** `tsconfig.json` includes `next-env.d.ts` and `.next/types/**/*.ts`, which `next build` writes. Measured locally on 4 cores from a clean state on 2026-11-21: `next build` writes the four `.next/types/` files within about 10 ms, 2.5 s into a 7 s build, and `next-env.d.ts` about 5 s in. It doesn't write `tsconfig.tsbuildinfo`. From a clean state `tsc` checks none of these files, so CI doesn't type-check them; after a build it checks all five, and they pass. With `tsc` started at 13 offsets from 0 to 6 s into the build, three times each, all 39 trials passed. The only failure would be `tsc` reading a file in the 10 ms it is half-written. #53 ran Types before Production build, for a result that doesn't depend on timing, at a cost of at most 0.7 s. +- **Limiting Vitest's workers did nothing.** Locally on 4 cores, running all checks together, three runs each: `--maxWorkers=2` left the total at 10.2–10.3 s. `--maxWorkers=1` sped the build to 8.7–8.9 s but slowed tests to 9.9–10.5 s, for 9.9–10.5 s in total. No test took 1 s in any run, against Vitest's default limit of 5 s. +- **Dropping the npm cache.** `npm ci` deletes `node_modules` and unpacks every package again, so a restored cache never made it faster: 6 s with the cache empty, 9 s and 9.3 s restored. Without the cache it took 7 to 11 s, which may be the registry downloads it now makes, or noise. Restoring the 140 MB archive costs about 1.2 s. +- **`npm ci --no-audit --no-fund`.** The audit is a network call and neither it nor the funding message is part of the definition of done, but the saving was too small to see. +- **Not taken: dropping `npm run typecheck` because `next build` also type-checks.** Next's `runTypeCheck.js` hides errors in `*.test.*`, `*.spec.*`, `__tests__/` and `__mocks__/` files, and stops at the first error, so the tests would no longer be type-checked. +- **Not taken: `typescript.ignoreBuildErrors`.** It saves 1.4 s of build, but a local `next build` would then succeed with type errors. +- **Not taken: a Chromium-only image** to shorten the image pull, the largest step. It would be a new dependency to maintain, for perhaps 8 s. ### Other speed decisions - **Not taken: caching the browsers.** Playwright's [CI docs](https://playwright.dev/docs/ci) say "Caching browser binaries is not recommended, since the amount of time it takes to restore the cache is comparable" to downloading them, and that the Linux system dependencies "are not cacheable". -- **Not taken: parallel jobs.** Each job would pull the image and run `npm ci` again, about 30 s, to save at most the 15 s the checks take after setup. The checks run in parallel inside the one job instead, as above. Reopen if a check grows slow enough to dominate. +- **Not taken: parallel jobs.** Each job would pull the image and run `npm ci` again, about 30 s, to save at most the 15 s the checks take after setup. Running them in parallel inside the one job didn't pay either, as above. Reopen if a check grows slow enough to dominate. - **Not taken: caching `.next/cache`.** It saves about 2 s of build. - **Not taken: `microsoft/playwright-github-action`.** Its README marks it deprecated, and the repository was archived on 2025-01-23. - **`concurrency` with `cancel-in-progress`** stops a run when a newer push to the same branch arrives, so nobody waits on an outdated run. diff --git a/scripts/ci-checks.sh b/scripts/ci-checks.sh deleted file mode 100644 index 233005c..0000000 --- a/scripts/ci-checks.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env bash -# Runs AGENTS.md's definition-of-done checks at the same time, for .github/workflows/ci.yml. -# Each check's output goes to its own log, printed afterwards in a group named for the check, -# with an error annotation for each check that failed. Types runs before Production build, not -# beside it. Reasons for both are in docs/engineering/ci.meta.md. -set -u - -if [ ! -f package.json ]; then - echo "ERROR: Run this script from the SplitSmart repository root." >&2 - exit 1 -fi - -# Outside the checkout, so lint and formatting never read a log while it is being written. -logs=$(mktemp -d "${RUNNER_TEMP:-${TMPDIR:-/tmp}}/ci-checks.XXXXXX") - -names=('Lint' 'Formatting' 'Types' 'Tests' 'Production build') -scripts=('lint' 'format:check' 'typecheck' 'test' 'build') - -# Runs check $1 and records its exit code and duration in tenths of a second. -check() { - local start end code - start=$(date +%s%N) - npm run "${scripts[$1]}" >"$logs/$1.log" 2>&1 - code=$? - end=$(date +%s%N) - echo "$code $(((end - start) / 100000000))" >"$logs/$1.status" -} - -check 0 & -check 1 & -check 3 & -{ - check 2 - check 4 -} & -wait - -failed=0 -for i in "${!names[@]}"; do - name=${names[$i]} - code=1 tenths=0 - [ -f "$logs/$i.status" ] && read -r code tenths <"$logs/$i.status" - echo "::group::$name (npm run ${scripts[$i]}): exit $code, $((tenths / 10)).$((tenths % 10)) s" - cat "$logs/$i.log" 2>/dev/null - echo "::endgroup::" - if [ "$code" != 0 ]; then - echo "::error title=$name failed::npm run ${scripts[$i]} exited with code $code. Its output is in the '$name' group above." - failed=1 - fi -done -exit $failed