Skip to content

Commit 251c7bf

Browse files
committed
chore: simplify CI and vitest workflows
1 parent 4e64d0a commit 251c7bf

17 files changed

Lines changed: 678 additions & 650 deletions

.github/workflows/ci.yml

Lines changed: 28 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,52 @@
11
name: CI
2-
32
on:
43
push:
54
branches: ["**"]
65
pull_request:
76
branches: ["main"]
8-
97
concurrency:
108
group: ci-${{ github.ref }}
119
cancel-in-progress: true
12-
1310
permissions:
1411
contents: read
15-
16-
env:
17-
DENO_VERSION: latest
18-
NPM_ARTIFACT_NAME: npm-package
19-
NPM_DIR: ./npm
20-
2112
jobs:
22-
validate-deno:
13+
validate:
2314
runs-on: ubuntu-latest
2415
steps:
2516
- uses: actions/checkout@v6
26-
27-
- uses: denoland/setup-deno@v2
17+
- uses: actions/setup-node@v6
2818
with:
29-
deno-version: ${{ env.DENO_VERSION }}
30-
31-
- run: deno run -A scripts/pipeline.ts validate-deno
32-
33-
- uses: actions/upload-artifact@v4
19+
node-version: 24
20+
- run: npm install --no-package-lock --ignore-scripts
21+
- uses: denoland/setup-deno@v2
3422
with:
35-
name: ${{ env.NPM_ARTIFACT_NAME }}
36-
path: ${{ env.NPM_DIR }}
37-
if-no-files-found: error
38-
39-
test-js-engines:
23+
deno-version: latest
24+
- name: Validate source and package outputs
25+
run: deno task validate
26+
test-node:
4027
runs-on: ubuntu-latest
41-
needs: validate-deno
28+
needs: validate
4229
strategy:
4330
fail-fast: false
4431
matrix:
45-
include:
46-
- runtime: node
47-
version: 22
48-
- runtime: node
49-
version: 24
50-
- runtime: bun
51-
version: latest
52-
32+
node-version: [22, 24]
5333
steps:
54-
- if: matrix.runtime == 'node'
55-
uses: actions/setup-node@v6
34+
- uses: actions/checkout@v6
35+
- uses: actions/setup-node@v6
36+
with:
37+
node-version: ${{ matrix.node-version }}
38+
- run: npm install --no-package-lock --ignore-scripts
39+
- run: npm x vitest run
40+
test-bun:
41+
runs-on: ubuntu-latest
42+
needs: validate
43+
steps:
44+
- uses: actions/checkout@v6
45+
- uses: actions/setup-node@v6
5646
with:
57-
node-version: ${{ matrix.version }}
58-
59-
- if: matrix.runtime == 'bun'
60-
uses: oven-sh/setup-bun@v2
61-
62-
- uses: actions/download-artifact@v5
47+
node-version: 24
48+
- run: npm install --no-package-lock --ignore-scripts
49+
- uses: oven-sh/setup-bun@v2
6350
with:
64-
name: ${{ env.NPM_ARTIFACT_NAME }}
65-
path: ${{ env.NPM_DIR }}
66-
67-
- run: deno run -A scripts/pipeline.ts test-runtime
68-
env:
69-
CI_RUNTIME: ${{ matrix.runtime }}
70-
NPM_DIR: ${{ env.NPM_DIR }}
51+
bun-version: latest
52+
- run: bun x vitest run

.github/workflows/release.yml

Lines changed: 77 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,32 +30,93 @@ permissions:
3030
contents: write
3131
id-token: write
3232

33-
env:
34-
DENO_VERSION: latest
35-
NPM_DIR: ./npm
36-
3733
jobs:
3834
release:
3935
runs-on: ubuntu-latest
36+
env:
37+
RELEASE_BUMP: ${{ inputs.bump }}
38+
RELEASE_VERSION: ${{ inputs.version }}
39+
RELEASE_PUBLISH: ${{ inputs.publish }}
4040
steps:
4141
- uses: actions/checkout@v6
4242
with:
4343
fetch-depth: 0
4444

45-
- uses: denoland/setup-deno@v2
46-
with:
47-
deno-version: ${{ env.DENO_VERSION }}
48-
4945
- uses: actions/setup-node@v6
5046
with:
51-
node-version: 24
47+
node-version: lts
5248
registry-url: https://registry.npmjs.org
5349

54-
- run: deno run -A scripts/pipeline.ts release
50+
- uses: denoland/setup-deno@v2
51+
with:
52+
deno-version: lts
53+
54+
- name: Resolve release version
55+
id: version
56+
run: deno run -A scripts/release-helper.ts resolve >> "$GITHUB_OUTPUT"
57+
58+
- name: Ensure release tag does not already exist
59+
shell: bash
60+
run: |
61+
set -euo pipefail
62+
git fetch --tags --force
63+
if git rev-parse --verify "refs/tags/${{ steps.version.outputs.tag }}" >/dev/null 2>&1; then
64+
echo "::error::Tag already exists: ${{ steps.version.outputs.tag }}"
65+
exit 1
66+
fi
67+
68+
- name: Extract release notes from changelog
5569
env:
56-
RELEASE_BUMP: ${{ inputs.bump }}
57-
RELEASE_VERSION: ${{ inputs.version }}
58-
RELEASE_PUBLISH: ${{ inputs.publish }}
59-
NPM_DIR: ${{ env.NPM_DIR }}
60-
GITHUB_TOKEN: ${{ github.token }}
61-
NODE_AUTH_TOKEN: ""
70+
RELEASE_VERSION: ${{ steps.version.outputs.version }}
71+
run: |
72+
export RELEASE_NOTES_FILE="$RUNNER_TEMP/release-notes.md"
73+
deno run -A scripts/release-helper.ts notes
74+
75+
- name: Sync version files
76+
env:
77+
RELEASE_VERSION: ${{ steps.version.outputs.version }}
78+
run: |
79+
npm version "$RELEASE_VERSION" --no-git-tag-version --allow-same-version
80+
deno run -A scripts/sync-package-metadata.ts
81+
82+
- name: Validate npm package contents
83+
run: npm pack --dry-run
84+
85+
- if: env.RELEASE_PUBLISH != 'true'
86+
name: Run publish dry-runs
87+
run: |
88+
set -euo pipefail
89+
deno publish --dry-run --allow-dirty
90+
npm publish --provenance --dry-run
91+
92+
- if: env.RELEASE_PUBLISH == 'true'
93+
name: Commit and tag release
94+
shell: bash
95+
run: |
96+
set -euo pipefail
97+
git config user.name github-actions[bot]
98+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
99+
git add package.json deno.json
100+
101+
if git diff --cached --quiet; then
102+
echo "::error::No version changes to commit"
103+
exit 1
104+
fi
105+
106+
git commit -m "chore(release): ${{ steps.version.outputs.tag }}"
107+
git tag -a "${{ steps.version.outputs.tag }}" -m "Release ${{ steps.version.outputs.tag }}"
108+
git push origin HEAD
109+
git push origin "${{ steps.version.outputs.tag }}"
110+
111+
- if: env.RELEASE_PUBLISH == 'true'
112+
name: Create GitHub release
113+
env:
114+
GH_TOKEN: ${{ github.token }}
115+
run: gh release create "${{ steps.version.outputs.tag }}" --notes-file "$RUNNER_TEMP/release-notes.md"
116+
117+
- if: env.RELEASE_PUBLISH == 'true'
118+
name: Publish to JSR and npm
119+
run: |
120+
set -euo pipefail
121+
deno publish
122+
npm publish --provenance

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
npm/
1+
node_modules/

.vscode/settings.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,20 @@
66
"approve": true,
77
"matchCommandLine": true
88
}
9+
},
10+
"[javascript]": {
11+
"editor.defaultFormatter": "denoland.vscode-deno"
12+
},
13+
"[typescript]": {
14+
"editor.defaultFormatter": "denoland.vscode-deno"
15+
},
16+
"[json]": {
17+
"editor.defaultFormatter": "denoland.vscode-deno"
18+
},
19+
"[jsonc]": {
20+
"editor.defaultFormatter": "denoland.vscode-deno"
21+
},
22+
"[markdown]": {
23+
"editor.defaultFormatter": "denoland.vscode-deno"
924
}
1025
}

AGENTS.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# structview agent and developer notes
2+
3+
This file holds repository workflow documentation that is mainly useful for
4+
contributors and coding agents.
5+
6+
## Local git hooks
7+
8+
Install repository hooks with:
9+
10+
```sh
11+
git config core.hooksPath .githooks
12+
```
13+
14+
This enables the hooks in `.githooks/`.
15+
16+
1. `pre-commit`: runs `deno fmt --check` and `deno lint`.
17+
18+
## Fixups
19+
20+
Run these after changing package metadata or CI/package validation behavior.
21+
22+
1. `deno run -A scripts/sync-package-metadata.ts`: rewrite `deno.json` from
23+
`package.json` metadata.
24+
2. `deno task validate`: verify formatting, lint, tests, JSR dry-run, and npm
25+
pack dry-run.
26+
3. `npm install --no-package-lock --ignore-scripts`: refresh local dev
27+
dependencies without introducing a lockfile. This is required before local
28+
`deno task validate`, `npm x vitest run`, and `bun x vitest run` commands.
29+
30+
## Commands
31+
32+
Operational commands are documented here so `deno.json` only carries the main
33+
aggregate validation entrypoint.
34+
35+
1. `deno task validate`: verify metadata sync, format, lint, tests, JSR dry-run,
36+
and npm pack dry-run.
37+
2. `deno x vitest run`: run the Vitest suite through Deno.
38+
3. `npm x vitest run`: run the Vitest suite in Node.
39+
4. `bun x vitest run`: run the Vitest suite in Bun.
40+
5. `deno x vitest bench --run`: run the Vitest benchmark suite.
41+
6. `act -W .github/workflows/ci.yml`: run the CI workflow locally when `act` is
42+
installed.
43+
44+
## Releases
45+
46+
Use the manual GitHub Actions workflow `Release` to cut a release.
47+
48+
1. Choose a version bump (`patch`, `minor`, `major`) or provide an explicit
49+
version.
50+
2. Ensure `CHANGELOG.md` includes a matching `## X.Y.Z` section.
51+
3. Run with `publish=true` to publish to JSR and npm, or `publish=false` for
52+
dry-run publish checks without pushing a tag or creating a GitHub release.
53+
4. The release workflow uses `package.json` as the version source of truth and
54+
syncs `deno.json` from it before publishing.

README.md

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,10 @@ data in a typesafe, declarative, object-oriented way.
1414
[![JSR Version](https://img.shields.io/jsr/v/@rotu/structview)](https://jsr.io/@rotu/structview)
1515
[![NPM Version](https://img.shields.io/npm/v/@rotu/structview)](https://www.npmjs.com/package/@rotu/structview)
1616

17-
# Local git hooks
17+
# Development
1818

19-
To catch formatting and linting failures before CI:
20-
21-
```sh
22-
deno task hooks:install
23-
```
24-
25-
This enables repository hooks in `.githooks/`:
26-
27-
1. `pre-commit`: runs `deno fmt --check` and `deno lint`.
28-
29-
# Releases
30-
31-
Use the manual GitHub Actions workflow `Release` to cut a release.
32-
33-
1. Choose a version bump (`patch`, `minor`, `major`) or provide an explicit
34-
version.
35-
2. Ensure `CHANGELOG.md` includes a matching `## X.Y.Z` section.
36-
3. Run with `publish=true` to publish to JSR and npm, or `publish=false` for
37-
dry-run publish checks.
19+
Contributor workflow notes, local commands, hooks, and release steps live in
20+
`AGENTS.md`.
3821

3922
# example
4023

0 commit comments

Comments
 (0)