-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (55 loc) · 2.11 KB
/
Copy pathci.yml
File metadata and controls
63 lines (55 loc) · 2.11 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
name: CI
on:
push:
branches: [main]
pull_request:
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# 18 is the floor declared in package.json `engines`; 22 is current LTS.
node-version: ["18", "22"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
# No dependencies by design — the CLI is standard-library only, so there
# is nothing to install and `npm ci` would fail on the absent lockfile.
- name: Syntax-check every module
run: node --check bin/styleref.mjs && for f in lib/*.mjs; do node --check "$f"; done
- name: Test
run: node --test
- name: Smoke-test the entry point
# Catches an import that resolves at parse time but explodes on run.
run: node bin/styleref.mjs --help
package:
# The published tarball is what users actually get; `files` in package.json
# is easy to get wrong and invisible until someone installs a broken build.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22"
- name: Verify the package contents
run: |
npm pack --dry-run
npm pack --dry-run --json > pack.json
# A file, not `node -`: stdin is parsed as CommonJS, so ESM here would
# fail on the import rather than on a genuinely broken tarball.
cat > check-pack.mjs <<'JS'
import { readFileSync } from 'node:fs';
const [pack] = JSON.parse(readFileSync('pack.json', 'utf8'));
const files = pack.files.map((f) => f.path);
const required = ['bin/styleref.mjs', 'lib/core.mjs', 'README.md', 'LICENSE'];
const missing = required.filter((f) => !files.includes(f));
if (missing.length) {
console.error(`::error::missing from the tarball: ${missing.join(', ')}`);
process.exit(1);
}
console.log(`ok: ${files.length} files`);
JS
node check-pack.mjs