Repository navigation
159 lines (149 loc) · 5.89 KB
/
Copy pathci.yml
File metadata and controls
159 lines (149 loc) · 5.89 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: CI
on:
pull_request:
permissions:
contents: read
concurrency:
group: ci-${{ github.event.pull_request.number }}
cancel-in-progress: true
# The ruleset of main requires every job by its name, so rename it there too.
jobs:
format:
name: 🎨 Format
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v7
- name: Set up the workspace
uses: ./.github/actions/setup
- name: Check the formatting with Prettier
run: pnpm format:check
lint:
name: 🧹 Lint
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v7
- name: Set up the workspace
uses: ./.github/actions/setup
- name: Lint with ESLint
run: pnpm lint
typecheck:
name: 🔷 Typecheck
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v7
- name: Set up the workspace
uses: ./.github/actions/setup
- name: Typecheck every package
run: pnpm typecheck
unit-tests:
name: 🧪 Unit tests
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v7
- name: Set up the workspace
uses: ./.github/actions/setup
- name: Run the unit tests of every package
run: pnpm test
website:
name: 🌐 Website build
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v7
- name: Set up the workspace
uses: ./.github/actions/setup
- name: Build the demo website
run: pnpm --filter website build
npm-package:
name: 📦 npm package
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v7
- name: Set up the workspace
uses: ./.github/actions/setup
- name: Build and pack the CLI
run: |
tarball="$RUNNER_TEMP/kombinat.tgz"
pnpm --filter kombinat pack --out "$tarball"
echo "TARBALL=$tarball" >> "$GITHUB_ENV"
- name: Check that the package ships bin, dist, README and LICENSE but not src
run: |
contents="$(tar -tzf "$TARBALL")"
for file in bin/kombinat.js dist/cli.js dist/web-app/index.html README.md LICENSE; do
grep -qxF "package/$file" <<< "$contents" || { echo "$file is not packed"; exit 1; }
done
if grep -q '^package/src/' <<< "$contents"; then echo 'src/ is packed'; exit 1; fi
- name: Check that package.json has no devDependencies or workspace specifiers
run: |
tar -xzOf "$TARBALL" package/package.json | node -e '
const manifest = JSON.parse(require("node:fs").readFileSync(0, "utf8"));
if ("devDependencies" in manifest) throw new Error("devDependencies are packed");
if (/"(workspace|catalog):/.test(JSON.stringify(manifest))) {
throw new Error("workspace: or catalog: specifiers are packed");
}
'
- name: Check that dist/cli.js imports only node, zod and ts-pattern
run: |
tar -xzOf "$TARBALL" package/dist/cli.js | node -e '
const code = require("node:fs").readFileSync(0, "utf8");
const specifiers = [
...code.matchAll(/^(?:import|export)\s[^"]*"([^"]+)";$/gm),
...code.matchAll(/\b(?:import|require)\(\s*"([^"]+)"\s*\)/g),
].map(([, specifier]) => specifier);
const unexpected = specifiers.filter(
specifier => !/^(node:|(zod|ts-pattern)(\/|$))/.test(specifier),
);
if (unexpected.length > 0) {
throw new Error(`dist/cli.js imports ${[...new Set(unexpected)].join(", ")}`);
}
'
- name: Install the package in an empty project with the example routines
run: |
project="$RUNNER_TEMP/project"
mkdir -p "$project/routines"
cp example/routines/*.md "$project/routines/"
cd "$project"
npm init -y > /dev/null
npm install --no-audit --no-fund --loglevel=error "$TARBALL"
- name: Validate the routines with the installed CLI
working-directory: ${{ runner.temp }}/project
run: npx kombinat validate
- name: Serve the API and the dashboard from the installed daemon
working-directory: ${{ runner.temp }}/project
run: |
port="$(node -e 'const server = require("node:net").createServer().listen(0, () => { console.log(server.address().port); server.close(); })')"
KOMBINAT_PORT="$port" KOMBINAT_STATE_DIR="$RUNNER_TEMP/state" \
node node_modules/kombinat/bin/kombinat.js serve --no-scheduler --no-watch > serve.log 2>&1 &
daemon=$!
for _ in $(seq 50); do grep -q 'ui at ' serve.log && break; sleep 0.2; done
cat serve.log
status="$(curl --fail --silent "http://127.0.0.1:$port/api/status")"
page="$(curl --fail --silent "http://127.0.0.1:$port/")"
kill "$daemon"
version="$(node -p 'require("./node_modules/kombinat/package.json").version')"
grep -q '"pid":' <<< "$status"
grep -qF "\"version\":\"$version\"" <<< "$status"
grep -qF '<div id="root"></div>' <<< "$page"
e2e:
name: 🎭 E2E tests
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v7
- name: Set up the workspace
uses: ./.github/actions/setup
- name: Install Chromium for Playwright
run: pnpm --filter e2e exec playwright install --with-deps chromium
- name: Build the dashboard and run the Playwright tests against a real daemon
run: pnpm test:e2e
- name: Upload the Playwright traces
if: failure()
uses: actions/upload-artifact@v7
with:
name: playwright-traces
path: packages/e2e/web-app/test-results/