-
-
Notifications
You must be signed in to change notification settings - Fork 50
145 lines (128 loc) · 6.02 KB
/
Copy pathci.yml
File metadata and controls
145 lines (128 loc) · 6.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: CI
# One workflow, two concerns:
# - `check` runs on pull requests: the PR gate (tests + fmt blocking; lint +
# typecheck advisory).
# - `deploy` runs on push to main: deploys to Void via GitHub OIDC (no stored
# VOID_TOKEN secret).
#
# WHY the deploy lives HERE (not a separate void-deploy.yml): Void's OIDC
# exchange validates the deploy token's `job_workflow_ref` against the
# connection's pinned `workflow_path`. That pin is one-time set to THIS file:
# npx void@latest github update napi-rs --workflow .github/workflows/ci.yml
# (the pin defaults to `.github/workflows/void-deploy.yml`; the `--workflow`
# flag needs void >= 0.10.3). Only ONE workflow path can be authorized per
# connection, so this must be the sole deploy workflow — do not re-add
# void-deploy.yml.
on:
pull_request:
push:
branches: [main]
# Cancel any in-flight run for the same ref when a new push lands. A PR run
# (`check`) and a main run (`deploy`) never share a group (distinct refs), so
# this cancels stale PR checks and supersedes an older main deploy.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Restrictive default; the deploy job widens to id-token below.
permissions:
contents: read
jobs:
# ---------------------------------------------------------------------------
# PR gate: tests + formatting are blocking; lint + typecheck are advisory.
# ---------------------------------------------------------------------------
check:
name: Check (tests, fmt, lint, typecheck)
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
# setup-vp is the canonical Void/Vite+ CI action (see
# node_modules/void/skills/void/docs/guide/deployment.md). It installs the
# `vp` toolchain, selects Node via `vp env use`, auto-detects the Yarn
# lockfile, and runs an immutable `vp install` (run-install defaults to
# true). `vp install` is frozen-lockfile in CI, satisfying the
# immutable-install requirement.
- name: Setup Vite+ toolchain (Node 24 + Yarn install)
uses: voidzero-dev/setup-vp@v1
with:
node-version: '24'
cache: true
# `void prepare` generates .void/*.d.ts (routes, db, queues, env) WITHOUT
# booting Vite. This MUST run before typecheck, otherwise `tsc` cannot
# resolve the `void/*` and `@schema` virtual modules and the typecheck
# fails on missing generated types.
- name: Generate Void types
run: yarn prepare
# Tests are BLOCKING. VITEST=1 mirrors the local convention for enabling
# the test environment.
- name: Run tests
env:
VITEST: '1'
run: npx vitest run
# Formatting is BLOCKING: `vp fmt --check` fails the job if anything is
# unformatted.
- name: Check formatting (blocking)
run: npx vp fmt --check
# Lint is ADVISORY: surfaced in logs but does not fail the job.
- name: Lint (advisory)
continue-on-error: true
run: npx vp lint
# Typecheck is ADVISORY. Depends on the `yarn prepare` step above for the
# generated .void types. `tsc --noEmit` is type-only (no output).
- name: Typecheck (advisory)
continue-on-error: true
run: npx tsc --noEmit
# ---------------------------------------------------------------------------
# Deploy: push to main only, via GitHub OIDC (no stored VOID_TOKEN). `void
# deploy` (>= 0.10.2) detects GitHub Actions, mints a short-lived OIDC token
# (audience "void"), exchanges it at $VOID_API_URL/auth/github-oidc for a
# short-lived, project-scoped deploy token, and ships dist/ — a single step.
# ---------------------------------------------------------------------------
deploy:
name: Deploy to Void
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
# id-token: write is what lets the job (and thus `void deploy`) mint the
# GitHub OIDC token. No stored VOID_TOKEN secret.
permissions:
id-token: write
contents: read
env:
# Read by `void deploy` for the OIDC exchange endpoint. Override with a
# VOID_API_URL repo variable to target staging.
VOID_API_URL: ${{ vars.VOID_API_URL || 'https://api.void.cloud' }}
VOID_PROJECT: napi-rs # prod slug (napi-rs.void.app), NOT napi-rs-website
steps:
- uses: actions/checkout@v7
- name: Setup Vite+ toolchain (Node 24 + Yarn install)
uses: voidzero-dev/setup-vp@v1
with:
node-version: '24'
cache: true
# Generate .void types before build so the production build resolves
# generated virtual modules cleanly.
- name: Generate Void types
run: yarn prepare
# Build first: `vite build` writes the client bundle to dist/client/ and
# the worker bundle to dist/.
#
# GITHUB_TOKEN is consumed by the changelog Vite plugin
# (lib/changelog/plugin.ts), which fetches the napi-rs release history at
# BUILD time. napi-rs/napi-rs is PUBLIC, so the auto-provided Actions token
# can read its releases (authenticated → 5000 req/hr; anonymous is 60/hr
# and flakes on shared runner IPs → the plugin throws and fails the build).
- name: Build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: yarn build
# Sitemap MUST run AFTER build: scripts/generate-sitemap.mjs emits
# sitemap.xml and the raw .md files INTO dist/client/. If it ran before
# build, `vite build` would wipe dist/client and discard these files.
- name: Generate sitemap (post-build, writes into dist/client)
run: yarn sitemap
# Single step: `void deploy` self-authenticates via GitHub OIDC (see
# header). --skip-build ships the dist/ built above instead of triggering
# its own `vite build`, which would clobber dist/client and drop the
# sitemap.xml + raw .md emitted by the sitemap step.
- name: Deploy
run: npx void deploy --project "$VOID_PROJECT" --skip-build