@haatlabs-core/templates 0.12.1 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/files/.github/workflows/ci.yml +19 -0
- package/files/infra/scripts/check-pages.mjs +210 -0
- package/files/make/platform.mk +20 -0
- package/package.json +4 -3
- package/standalone/dot-github/workflows/ci.yml +11 -0
- package/standalone/make/standalone.mk +10 -3
- package/starter/README.md +1 -0
- package/starter/package.json.tmpl +1 -0
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export interface TemplateFile {
|
|
|
8
8
|
/** 'file': the whole file. 'block': the lines between the platform markers. */
|
|
9
9
|
mode?: 'file' | 'block';
|
|
10
10
|
/** How a comment starts in this file; null where the format has none (JSON). */
|
|
11
|
-
comment: '#' | null;
|
|
11
|
+
comment: '#' | '//' | null;
|
|
12
12
|
executable?: boolean;
|
|
13
13
|
}
|
|
14
14
|
export declare const templatesRoot: string;
|
package/dist/index.js
CHANGED
|
@@ -51,6 +51,12 @@ export const TEMPLATES = [
|
|
|
51
51
|
{ path: 'infra/scripts/build-images.sh', comment: '#', executable: true },
|
|
52
52
|
{ path: 'infra/scripts/pages.sh', comment: '#', executable: true, when: 'dashboards' },
|
|
53
53
|
{ path: 'infra/scripts/check-infra.sh', comment: '#', executable: true },
|
|
54
|
+
{
|
|
55
|
+
path: 'infra/scripts/check-pages.mjs',
|
|
56
|
+
comment: '//',
|
|
57
|
+
executable: true,
|
|
58
|
+
when: 'dashboards',
|
|
59
|
+
},
|
|
54
60
|
{ path: '.github/workflows/ci.yml', comment: '#' },
|
|
55
61
|
{ path: '.github/workflows/images.yml', comment: '#' },
|
|
56
62
|
{ path: '.github/workflows/deploy.yml', comment: '#' },
|
|
@@ -91,6 +97,7 @@ export const STANDALONE_SHARED = [
|
|
|
91
97
|
'infra/ansible/ansible.cfg',
|
|
92
98
|
'infra/ansible/playbooks/setup.yml',
|
|
93
99
|
'infra/scripts/with-env.sh',
|
|
100
|
+
'infra/scripts/check-pages.mjs',
|
|
94
101
|
];
|
|
95
102
|
/** Whether a starter file (its path in the starter) is written for a project with these conditions. */
|
|
96
103
|
export function starterFileWanted(path, conditions) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,KAAK;IACL,SAAS;IACT,OAAO;IACP,qCAAqC;IACrC,YAAY;IACZ,gBAAgB;IAChB,aAAa;IACb,UAAU;IACV,gBAAgB;IAChB,+EAA+E;IAC/E,gBAAgB;IAChB,mBAAmB;IACnB,OAAO;IACP,8EAA8E;IAC9E,YAAY;IACZ,4DAA4D;IAC5D,aAAa;CACL,CAAC;AAeX,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAClF,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAClF,wFAAwF;AACxF,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,gBAAgB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACxF,0EAA0E;AAC1E,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAC/C,IAAI,GAAG,CAAC,uBAAuB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAClD,CAAC;AACF,MAAM,CAAC,MAAM,g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AC;QACjC,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC;IACxD,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -10,7 +10,13 @@
|
|
|
10
10
|
#@end
|
|
11
11
|
# Deploying is a separate workflow, started by hand: deploy.yml.
|
|
12
12
|
#
|
|
13
|
+
#@if dashboards
|
|
14
|
+
# checks the managed files, type check, lint, format, unit tests, and the dashboards
|
|
15
|
+
# loaded in headless Chromium (make check-pages)
|
|
16
|
+
#@end
|
|
17
|
+
#@if !dashboards
|
|
13
18
|
# checks the managed files, type check, lint, format, unit tests
|
|
19
|
+
#@end
|
|
14
20
|
# integration the integration and end-to-end suites; each test file starts its own
|
|
15
21
|
# Postgres and Redis containers, so no env file is involved
|
|
16
22
|
# infra the deploy files: compose files resolve, scripts parse, playbooks pass
|
|
@@ -75,6 +81,19 @@ jobs:
|
|
|
75
81
|
- run: make lint
|
|
76
82
|
- run: make format-check
|
|
77
83
|
- run: make test
|
|
84
|
+
#@if dashboards
|
|
85
|
+
# The page check's browser: the headless shell of the Chromium that the installed
|
|
86
|
+
# playwright-core drives, cached by its version; --with-deps adds the system libraries.
|
|
87
|
+
- name: The page check's browser version
|
|
88
|
+
id: playwright
|
|
89
|
+
run: echo "version=$(pnpm exec playwright-core --version | awk '{print $2}')" >> "$GITHUB_OUTPUT"
|
|
90
|
+
- uses: actions/cache@v4
|
|
91
|
+
with:
|
|
92
|
+
path: ~/.cache/ms-playwright
|
|
93
|
+
key: playwright-shell-${{ runner.os }}-${{ steps.playwright.outputs.version }}
|
|
94
|
+
- run: pnpm exec playwright-core install --with-deps --only-shell chromium
|
|
95
|
+
- run: make check-pages
|
|
96
|
+
#@end
|
|
78
97
|
|
|
79
98
|
integration:
|
|
80
99
|
runs-on: ubuntu-latest
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The dashboards, loaded in a real browser: each one is built as it is deployed, served from
|
|
3
|
+
// this machine and opened in headless Chromium. A page fails when it throws an uncaught error
|
|
4
|
+
// while it loads, or when it shows no text at all. HTTP status codes cannot see either: a
|
|
5
|
+
// bundle that throws at its first line (server-only code in the browser, say) still answers
|
|
6
|
+
// 200 with an empty page.
|
|
7
|
+
//
|
|
8
|
+
// node infra/scripts/check-pages.mjs build apps/web, apps/shopify-app and
|
|
9
|
+
// apps/admin (those there are), check each
|
|
10
|
+
// node infra/scripts/check-pages.mjs --dist web=<dir> check pages already built; repeatable
|
|
11
|
+
//
|
|
12
|
+
// The build needs no secrets: the API address is left empty, so the pages call /api on the
|
|
13
|
+
// server here, which answers 401 to everything (a signed-out visitor), and the Shopify client
|
|
14
|
+
// ID is a placeholder. Console warnings are fine; only uncaught errors count, apart from App
|
|
15
|
+
// Bridge's complaint that the embedded app was opened outside Shopify, with no shop.
|
|
16
|
+
//
|
|
17
|
+
// Needs playwright-core (a devDependency of the project) and its Chromium:
|
|
18
|
+
// pnpm exec playwright-core install --only-shell chromium
|
|
19
|
+
// CHECK_PAGES_SETTLE_MS: how long to wait after the load event (default 2000).
|
|
20
|
+
import { spawnSync } from 'node:child_process';
|
|
21
|
+
import { existsSync, mkdtempSync, readFileSync, rmSync, statSync } from 'node:fs';
|
|
22
|
+
import { createServer } from 'node:http';
|
|
23
|
+
import { tmpdir } from 'node:os';
|
|
24
|
+
import { extname, join, resolve, sep } from 'node:path';
|
|
25
|
+
|
|
26
|
+
const APPS = [
|
|
27
|
+
{ name: 'web', dir: 'apps/web' },
|
|
28
|
+
{ name: 'shopify', dir: 'apps/shopify-app' },
|
|
29
|
+
{ name: 'admin', dir: 'apps/admin' },
|
|
30
|
+
];
|
|
31
|
+
// What the pages are built with: nothing secret, nothing that reaches a real service.
|
|
32
|
+
const BUILD_ENV = {
|
|
33
|
+
VITE_API_BASE_URL: '',
|
|
34
|
+
VITE_SHOPIFY_API_KEY: 'check-pages-placeholder',
|
|
35
|
+
VITE_SHOPIFY_LISTING_URL: '',
|
|
36
|
+
};
|
|
37
|
+
// Uncaught errors that are not the page's fault.
|
|
38
|
+
const ALLOWED_ERRORS = [/missing required configuration fields: shop/];
|
|
39
|
+
const SETTLE_MS = Number(process.env.CHECK_PAGES_SETTLE_MS ?? 2000);
|
|
40
|
+
const LOAD_TIMEOUT_MS = 30_000;
|
|
41
|
+
const TYPES = {
|
|
42
|
+
'.html': 'text/html; charset=utf-8',
|
|
43
|
+
'.js': 'text/javascript; charset=utf-8',
|
|
44
|
+
'.mjs': 'text/javascript; charset=utf-8',
|
|
45
|
+
'.css': 'text/css; charset=utf-8',
|
|
46
|
+
'.json': 'application/json',
|
|
47
|
+
'.svg': 'image/svg+xml',
|
|
48
|
+
'.png': 'image/png',
|
|
49
|
+
'.jpg': 'image/jpeg',
|
|
50
|
+
'.webp': 'image/webp',
|
|
51
|
+
'.ico': 'image/x-icon',
|
|
52
|
+
'.woff2': 'font/woff2',
|
|
53
|
+
'.txt': 'text/plain; charset=utf-8',
|
|
54
|
+
'.webmanifest': 'application/manifest+json',
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/** The pages to check: [name, dist directory] pairs, and the directory to remove after. */
|
|
58
|
+
function pagesToCheck(args) {
|
|
59
|
+
const given = [];
|
|
60
|
+
for (let i = 0; i < args.length; i++) {
|
|
61
|
+
if (args[i] !== '--dist') throw new Error(`unknown argument ${args[i]}: --dist <name>=<dir>`);
|
|
62
|
+
const value = args[++i] ?? '';
|
|
63
|
+
const at = value.indexOf('=');
|
|
64
|
+
if (at < 1) throw new Error(`--dist needs <name>=<dir>, not "${value}"`);
|
|
65
|
+
given.push({ name: value.slice(0, at), dist: resolve(value.slice(at + 1)) });
|
|
66
|
+
}
|
|
67
|
+
if (given.length > 0) return { pages: given, temporary: null };
|
|
68
|
+
|
|
69
|
+
const apps = APPS.filter((app) => existsSync(join(app.dir, 'package.json')));
|
|
70
|
+
if (apps.length === 0) {
|
|
71
|
+
console.log('no dashboards here (apps/web, apps/shopify-app, apps/admin): nothing to check');
|
|
72
|
+
return { pages: [], temporary: null };
|
|
73
|
+
}
|
|
74
|
+
const temporary = mkdtempSync(join(tmpdir(), 'check-pages-'));
|
|
75
|
+
const pages = [];
|
|
76
|
+
for (const app of apps) {
|
|
77
|
+
const { name: pkg } = JSON.parse(readFileSync(join(app.dir, 'package.json'), 'utf8'));
|
|
78
|
+
const dist = join(temporary, app.name);
|
|
79
|
+
const started = Date.now();
|
|
80
|
+
const built = spawnSync(
|
|
81
|
+
'pnpm',
|
|
82
|
+
[
|
|
83
|
+
'--filter',
|
|
84
|
+
pkg,
|
|
85
|
+
'exec',
|
|
86
|
+
'vite',
|
|
87
|
+
'build',
|
|
88
|
+
'--outDir',
|
|
89
|
+
dist,
|
|
90
|
+
'--emptyOutDir',
|
|
91
|
+
'--logLevel',
|
|
92
|
+
'warn',
|
|
93
|
+
],
|
|
94
|
+
{ stdio: 'inherit', env: { ...process.env, ...BUILD_ENV } },
|
|
95
|
+
);
|
|
96
|
+
if (built.status !== 0) {
|
|
97
|
+
rmSync(temporary, { recursive: true, force: true });
|
|
98
|
+
throw new Error(`${app.name}: vite build failed (${pkg})`);
|
|
99
|
+
}
|
|
100
|
+
console.log(`built ${app.name} in ${seconds(Date.now() - started)}`);
|
|
101
|
+
pages.push({ name: app.name, dist });
|
|
102
|
+
}
|
|
103
|
+
return { pages, temporary };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** The built files, any other path as index.html (client-side routes), /api as signed out. */
|
|
107
|
+
function serve(dist) {
|
|
108
|
+
const server = createServer((req, res) => {
|
|
109
|
+
const path = decodeURIComponent(new URL(req.url ?? '/', 'http://here').pathname);
|
|
110
|
+
if (path === '/api' || path.startsWith('/api/')) {
|
|
111
|
+
res.writeHead(401, { 'content-type': 'application/json' });
|
|
112
|
+
res.end(JSON.stringify({ error: { code: 'unauthenticated', message: 'not signed in' } }));
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
let file = resolve(dist, `.${path}`);
|
|
116
|
+
if (file !== dist && !file.startsWith(dist + sep)) file = join(dist, 'index.html');
|
|
117
|
+
if (!existsSync(file) || !statSync(file).isFile()) file = join(dist, 'index.html');
|
|
118
|
+
if (!existsSync(file)) {
|
|
119
|
+
res.writeHead(404).end();
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
res.writeHead(200, { 'content-type': TYPES[extname(file)] ?? 'application/octet-stream' });
|
|
123
|
+
res.end(readFileSync(file));
|
|
124
|
+
});
|
|
125
|
+
return new Promise((done, fail) => {
|
|
126
|
+
server.once('error', fail);
|
|
127
|
+
server.listen(0, '127.0.0.1', () => done(server));
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** What went wrong with one page: an empty list when nothing did. */
|
|
132
|
+
async function checkPage(browser, url) {
|
|
133
|
+
const page = await browser.newPage();
|
|
134
|
+
const problems = [];
|
|
135
|
+
page.on('pageerror', (error) => {
|
|
136
|
+
const message = error.message || String(error);
|
|
137
|
+
if (!ALLOWED_ERRORS.some((allowed) => allowed.test(message)))
|
|
138
|
+
problems.push(`uncaught error: ${message.split('\n')[0]}`);
|
|
139
|
+
});
|
|
140
|
+
let text = '';
|
|
141
|
+
try {
|
|
142
|
+
await page.goto(url, { waitUntil: 'load', timeout: LOAD_TIMEOUT_MS });
|
|
143
|
+
await page.waitForTimeout(SETTLE_MS);
|
|
144
|
+
text = (await page.evaluate(() => document.body?.innerText ?? '')).trim();
|
|
145
|
+
if (text === '') problems.push('blank: the page shows no text');
|
|
146
|
+
} catch (error) {
|
|
147
|
+
problems.push(`did not load: ${String(error.message ?? error).split('\n')[0]}`);
|
|
148
|
+
} finally {
|
|
149
|
+
await page.close();
|
|
150
|
+
}
|
|
151
|
+
return { problems, text };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const seconds = (ms) => `${(ms / 1000).toFixed(1)} s`;
|
|
155
|
+
|
|
156
|
+
async function loadChromium() {
|
|
157
|
+
try {
|
|
158
|
+
return (await import('playwright-core')).chromium;
|
|
159
|
+
} catch {
|
|
160
|
+
throw new Error('playwright-core is not installed: pnpm add -Dw playwright-core');
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
async function main() {
|
|
165
|
+
const chromium = await loadChromium();
|
|
166
|
+
const { pages, temporary } = pagesToCheck(process.argv.slice(2));
|
|
167
|
+
if (pages.length === 0) return 0;
|
|
168
|
+
let browser;
|
|
169
|
+
try {
|
|
170
|
+
browser = await chromium.launch().catch((error) => {
|
|
171
|
+
const missing = /Executable doesn't exist|playwright-core install/.test(error.message);
|
|
172
|
+
throw missing
|
|
173
|
+
? new Error(
|
|
174
|
+
'Chromium is not installed: pnpm exec playwright-core install --only-shell chromium',
|
|
175
|
+
)
|
|
176
|
+
: error;
|
|
177
|
+
});
|
|
178
|
+
let failed = 0;
|
|
179
|
+
for (const { name, dist } of pages) {
|
|
180
|
+
const server = await serve(dist);
|
|
181
|
+
const started = Date.now();
|
|
182
|
+
try {
|
|
183
|
+
const { port } = server.address();
|
|
184
|
+
const { problems, text } = await checkPage(browser, `http://127.0.0.1:${port}/`);
|
|
185
|
+
const took = seconds(Date.now() - started);
|
|
186
|
+
if (problems.length === 0) {
|
|
187
|
+
console.log(`ok ${name} (${took}): "${text.replace(/\s+/g, ' ').slice(0, 60)}"`);
|
|
188
|
+
} else {
|
|
189
|
+
failed++;
|
|
190
|
+
console.error(`FAIL ${name} (${took})`);
|
|
191
|
+
for (const problem of problems) console.error(` ${problem}`);
|
|
192
|
+
}
|
|
193
|
+
} finally {
|
|
194
|
+
server.close();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return failed === 0 ? 0 : 1;
|
|
198
|
+
} finally {
|
|
199
|
+
await browser?.close();
|
|
200
|
+
if (temporary) rmSync(temporary, { recursive: true, force: true });
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
main().then(
|
|
205
|
+
(status) => process.exit(status),
|
|
206
|
+
(error) => {
|
|
207
|
+
console.error(`check-pages: ${error.message}`);
|
|
208
|
+
process.exit(1);
|
|
209
|
+
},
|
|
210
|
+
);
|
package/files/make/platform.mk
CHANGED
|
@@ -87,7 +87,12 @@ refuse_production = @if grep -Eq "^NODE_ENV=[\"']?production" $(ENV_PATH); then
|
|
|
87
87
|
.PHONY: help
|
|
88
88
|
help: ## this list
|
|
89
89
|
@echo "make <target> Env=<name> reads .env.<name>. No default: local is this machine."
|
|
90
|
+
#@if dashboards
|
|
91
|
+
@echo "(install, build, typecheck, lint, format, test, test-int, sync, check-infra, check-pages and ci take no Env.)"
|
|
92
|
+
#@end
|
|
93
|
+
#@if !dashboards
|
|
90
94
|
@echo "(install, build, typecheck, lint, format, test, test-int, sync, check-infra and ci take no Env.)"
|
|
95
|
+
#@end
|
|
91
96
|
@echo
|
|
92
97
|
@awk 'BEGIN { FS = ":.*## " } /^[a-zA-Z0-9_-]+:.*## / { printf " %-26s %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
|
|
93
98
|
@echo
|
|
@@ -420,6 +425,16 @@ endif
|
|
|
420
425
|
# pass ansible's syntax check.
|
|
421
426
|
check-infra: ## the deploy files, without deploying
|
|
422
427
|
@infra/scripts/check-infra.sh
|
|
428
|
+
#@if dashboards
|
|
429
|
+
|
|
430
|
+
# The dashboards in a real browser: each built as it is deployed (with no secrets), served
|
|
431
|
+
# from this machine and opened in headless Chromium. Fails on an uncaught error while a page
|
|
432
|
+
# loads, or a page with no text: what a status code cannot see. Chromium, once a machine:
|
|
433
|
+
# pnpm exec playwright-core install --only-shell chromium
|
|
434
|
+
.PHONY: check-pages
|
|
435
|
+
check-pages: ## the dashboards load in a browser: no uncaught error, no blank page
|
|
436
|
+
node infra/scripts/check-pages.mjs
|
|
437
|
+
#@end
|
|
423
438
|
|
|
424
439
|
# The files this one comes from: the platform's templates, at the platform version in
|
|
425
440
|
# package.json, for what platform.json says.
|
|
@@ -430,7 +445,12 @@ sync-check: ## fails when a managed file differs from the templates
|
|
|
430
445
|
pnpm exec haatlabs sync --check
|
|
431
446
|
|
|
432
447
|
# Cheapest first. What .github/workflows/ci.yml runs, apart from building the images.
|
|
448
|
+
#@if dashboards
|
|
449
|
+
ci: typecheck lint format-check test sync-check check-infra check-pages test-int ## everything CI checks
|
|
450
|
+
#@end
|
|
451
|
+
#@if !dashboards
|
|
433
452
|
ci: typecheck lint format-check test sync-check check-infra test-int ## everything CI checks
|
|
453
|
+
#@end
|
|
434
454
|
|
|
435
455
|
# ---------------------------------------------------------------- deployed --
|
|
436
456
|
#
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haatlabs-core/templates",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.2",
|
|
4
4
|
"description": "The starter files and shared project files that @haatlabs-core/cli writes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"haatlabs"
|
|
@@ -35,8 +35,9 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"
|
|
39
|
-
"@haatlabs-core/
|
|
38
|
+
"playwright-core": "1.63.0",
|
|
39
|
+
"@haatlabs-core/tsconfig": "0.12.2",
|
|
40
|
+
"@haatlabs-core/vitest-config": "0.12.2"
|
|
40
41
|
},
|
|
41
42
|
"scripts": {
|
|
42
43
|
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
@@ -25,5 +25,16 @@ jobs:
|
|
|
25
25
|
cache: pnpm
|
|
26
26
|
- run: pnpm install --frozen-lockfile
|
|
27
27
|
- run: make typecheck lint format-check test
|
|
28
|
+
# The page check's browser: the headless shell of the Chromium that the installed
|
|
29
|
+
# playwright-core drives, cached by its version; --with-deps adds the system libraries.
|
|
30
|
+
- name: The page check's browser version
|
|
31
|
+
id: playwright
|
|
32
|
+
run: echo "version=$(pnpm exec playwright-core --version | awk '{print $2}')" >> "$GITHUB_OUTPUT"
|
|
33
|
+
- uses: actions/cache@v4
|
|
34
|
+
with:
|
|
35
|
+
path: ~/.cache/ms-playwright
|
|
36
|
+
key: playwright-shell-${{ runner.os }}-${{ steps.playwright.outputs.version }}
|
|
37
|
+
- run: pnpm exec playwright-core install --with-deps --only-shell chromium
|
|
38
|
+
- run: make check-pages
|
|
28
39
|
- run: make check-infra
|
|
29
40
|
- run: make test-int
|
|
@@ -40,7 +40,7 @@ refuse_production = @if grep -Eq "^NODE_ENV=[\"']?production" $(ENV_PATH); then
|
|
|
40
40
|
.PHONY: help
|
|
41
41
|
help: ## this list
|
|
42
42
|
@echo "make <target> Env=<name> reads .env.<name>. No default: local is this machine."
|
|
43
|
-
@echo "(install, typecheck, lint, format, test, test-int, check-infra and ci take no Env.)"
|
|
43
|
+
@echo "(install, typecheck, lint, format, test, test-int, check-infra, check-pages and ci take no Env.)"
|
|
44
44
|
@echo
|
|
45
45
|
@awk 'BEGIN { FS = ":.*## " } /^[a-zA-Z0-9_-]+:.*## / { printf " %-22s %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
|
|
46
46
|
|
|
@@ -107,7 +107,7 @@ set-price: $(ENV_PATH) ## a plan's gateway price, ARGS="<planCode> <gateway> <pr
|
|
|
107
107
|
|
|
108
108
|
# ------------------------------------------------------------- verification --
|
|
109
109
|
|
|
110
|
-
.PHONY: typecheck lint format format-check test test-int check-infra ci
|
|
110
|
+
.PHONY: typecheck lint format format-check test test-int check-infra check-pages ci
|
|
111
111
|
|
|
112
112
|
typecheck: ## types
|
|
113
113
|
pnpm typecheck
|
|
@@ -130,7 +130,14 @@ test-int: ## the integration suites (their own containers)
|
|
|
130
130
|
check-infra: ## the deploy files, without deploying
|
|
131
131
|
@infra/scripts/check-infra.sh
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
# The dashboards in a real browser: each built as it is deployed (with no secrets), served
|
|
134
|
+
# from this machine and opened in headless Chromium. Fails on an uncaught error while a page
|
|
135
|
+
# loads, or a page with no text. Chromium, once a machine:
|
|
136
|
+
# pnpm exec playwright-core install --only-shell chromium
|
|
137
|
+
check-pages: ## the dashboards load in a browser: no uncaught error, no blank page
|
|
138
|
+
node infra/scripts/check-pages.mjs
|
|
139
|
+
|
|
140
|
+
ci: typecheck lint format-check test check-infra check-pages test-int ## everything CI checks
|
|
134
141
|
|
|
135
142
|
# ---------------------------------------------------------------- deployed --
|
|
136
143
|
#
|
package/starter/README.md
CHANGED
|
@@ -112,6 +112,7 @@ Licence: Apache-2.0 (`LICENSE`, `NOTICE`).
|
|
|
112
112
|
make typecheck lint format-check test # no services needed
|
|
113
113
|
make test-int # starts its own Postgres and Redis in Docker
|
|
114
114
|
make check-infra # the compose files, scripts and playbooks
|
|
115
|
+
make check-pages # the dashboards load in headless Chromium
|
|
115
116
|
#@if kindShopify
|
|
116
117
|
make ci # all of the above, with sync-check
|
|
117
118
|
#@end
|