Skip to content

Commit 2688196

Browse files
authored
ci(.github/workflows/): split mise task steps to several steps (#183)
* ci(.github/workflows/e2e.yml): split fixtures build to several steps * ci(.github/workflows/): explicitly install package.json dependencies * style(mise.toml): format with taplo
1 parent cf20b4d commit 2688196

File tree

8 files changed

+88
-43
lines changed

8 files changed

+88
-43
lines changed

.github/workflows/e2e.yml

+29-9
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,20 @@ jobs:
2929
with:
3030
experimental: true
3131

32+
- name: Install package.json dependencies
33+
run: mise run buni
34+
35+
- name: Build Package
36+
run: mise run build
37+
38+
- name: Install E2E Test Fixtures Dependencies
39+
run: bun install --frozen-lockfile
40+
working-directory: tests/e2e/fixtures
41+
42+
- name: Build E2E Test Fixtures with astro-better-image-service
43+
run: bun run build
44+
working-directory: tests/e2e/fixtures
45+
3246
- name: Store Dependency Versions
3347
id: dependency-versions
3448
run: |
@@ -42,9 +56,6 @@ jobs:
4256
path: ~/.cache/ms-playwright
4357
key: playwright-browsers-${{ runner.os }}-${{ steps.dependency-versions.outputs.playwright }}
4458

45-
- name: Install package.json dependencies
46-
run: mise run buni
47-
4859
- name: Install Playwright Browsers and Dependencies
4960
id: playwright-install
5061
if: steps.restore-browsers-cache.outputs.cache-hit != 'true'
@@ -89,6 +100,12 @@ jobs:
89100
with:
90101
experimental: true
91102

103+
- name: Install package.json dependencies
104+
run: mise run buni
105+
106+
- name: Build Package
107+
run: mise run build
108+
92109
- name: Store Dependency Versions
93110
id: dependency-versions
94111
run: |
@@ -104,9 +121,6 @@ jobs:
104121
path: ~/.cache/ms-playwright
105122
key: playwright-browsers-${{ runner.os }}-${{ steps.dependency-versions.outputs.playwright }}
106123

107-
- name: Install package.json dependencies
108-
run: mise run buni
109-
110124
- name: Install Playwright Browsers and Dependencies
111125
id: playwright-install
112126
if: steps.restore-browsers-cache.outputs.cache-hit != 'true'
@@ -127,16 +141,21 @@ jobs:
127141
id: fixtures-hash
128142
run: echo "hash=${{ hashFiles('tests/e2e/fixtures/**/*', 'tests/e2e/conversion.test.ts') }}" >> "$GITHUB_OUTPUT"
129143

144+
- name: Install E2E Test Fixtures Dependencies
145+
run: bun install --frozen-lockfile
146+
working-directory: tests/e2e/fixtures
147+
130148
- name: Restore Snapshots Cache
131149
id: restore-snapshots-cache
132150
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
133151
with:
134152
path: tests/e2e/conversion.test.ts-snapshots
135-
key: "default-service-snapshots-${{ runner.os }}-${{ steps.dependency-versions.outputs.astro }}-${{ steps.dependency-versions.outputs.playwright }}-${{ steps.fixtures-hash.outputs.hash }} "
153+
key: "default-service-snapshots-${{ runner.os }}-${{ steps.dependency-versions.outputs.astro }}-${{ steps.dependency-versions.outputs.playwright }}-${{ steps.fixtures-hash.outputs.hash }}"
136154

137155
- name: Build E2E Test Fixtures with the Default Image Service
138156
if: steps.restore-snapshots-cache.outputs.cache-hit != 'true'
139-
run: mise run test:e2e:fixtures:build
157+
run: bun run build
158+
working-directory: tests/e2e/fixtures
140159
env:
141160
USE_DEFAULT_IMAGE_SERVICE: true
142161

@@ -154,7 +173,8 @@ jobs:
154173
key: ${{ steps.restore-snapshots-cache.outputs.cache-primary-key }}
155174

156175
- name: Build E2E Test Fixtures with astro-better-image-service
157-
run: mise run test:e2e:fixtures:build
176+
run: bun run build
177+
working-directory: tests/e2e/fixtures
158178

159179
- name: Playwright Image Services Consistency Test
160180
id: playwright-test-conversion

.github/workflows/lint.yml

+4
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ jobs:
6666
with:
6767
experimental: true
6868

69+
- name: Install package.json dependencies
70+
if: matrix.buni
71+
run: mise run buni
72+
6973
- name: Run ${{ matrix.name }}
7074
run: mise run ${{ matrix.task }}
7175

.github/workflows/release.yml

+3
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ jobs:
5858
with:
5959
experimental: true
6060

61+
- name: Install Dependencies
62+
run: mise run buni
63+
6164
- name: Build
6265
run: mise run build
6366

.github/workflows/scripts/list-mise-tasks.ts

+39-23
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
// biome-ignore lint/nursery/noUndeclaredDependencies:
22
import { $ } from "bun";
3-
import {
4-
type EdgeModel,
5-
type NodeModel,
6-
type NodeRef,
7-
fromDot,
8-
} from "ts-graphviz";
3+
import { type EdgeModel, type NodeRef, fromDot } from "ts-graphviz";
94

105
$.throws(true);
116

@@ -38,36 +33,57 @@ const getEdgeTargets = ({ targets }: EdgeModel) => {
3833
};
3934
};
4035

41-
const getNodeFromRef = ({ id }: NodeRef) => {
36+
const getChildNodes = (
37+
node: NodeRef,
38+
edges: ReturnType<typeof getEdgeTargets>[],
39+
recursive = false,
40+
): NodeRef[] => {
41+
const children = edges
42+
.filter(({ from }) => from.id === node.id)
43+
.map(({ to }) => to);
44+
45+
if (recursive) {
46+
return children.flatMap((child) => [
47+
child,
48+
...getChildNodes(child, edges, true),
49+
]);
50+
}
51+
52+
return children;
53+
};
54+
55+
const getNodeLabel = ({ id }: NodeRef) => {
4256
const node = ciTasks.nodes.find((node) => node.id === id);
4357
if (!node) {
4458
throw new Error(`node with id ${id} not found`);
4559
}
46-
return node;
47-
};
48-
49-
const getNodeLabel = (node: NodeModel) => {
5060
const label = node.attributes.get("label");
5161
if (!label) {
5262
throw new Error("missing label in node");
5363
}
5464
return label;
5565
};
5666

67+
const edges = ciTasks.edges.map(getEdgeTargets);
68+
5769
const tasks: {
5870
name: string;
5971
task: string;
60-
}[] = ciTasks.edges
61-
.map(getEdgeTargets)
62-
.filter(({ from }) => from.id === rootNode.id)
63-
.map(({ to }) => {
64-
const taskName = getNodeLabel(getNodeFromRef(to));
65-
// remove prefix if exists
66-
const name = taskName.split(":")[1] ?? taskName;
67-
return {
68-
name: name,
69-
task: taskName,
70-
};
71-
});
72+
buni: boolean;
73+
}[] = getChildNodes(rootNode, edges).map((to) => {
74+
const taskName = getNodeLabel(to);
75+
// remove prefix if exists
76+
const name = taskName.split(":")[1] ?? taskName;
77+
78+
const depends = getChildNodes(to, edges, true).map((node) =>
79+
getNodeLabel(node),
80+
);
81+
82+
return {
83+
name: name,
84+
task: taskName,
85+
buni: depends.some((dep) => dep === "buni"),
86+
};
87+
});
7288

7389
console.write(JSON.stringify(tasks));

.github/workflows/unit.yml

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ jobs:
2929
with:
3030
experimental: true
3131

32+
- name: Install Dependencies
33+
run: mise run buni
34+
3235
- name: Test
3336
run: mise run test:unit
3437

mise.toml

+3-10
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,10 @@ run = "bun run playwright test vrt format"
5757
depends = ["buni"]
5858
run = "bun run playwright test vrt --update-snapshots"
5959

60-
[tasks."test:e2e:fixtures:install"]
61-
depends = ["build"]
62-
run = "bun install --frozen-lockfile --cwd tests/e2e/fixtures"
63-
64-
[tasks."test:e2e:fixtures:build"]
65-
depends = ["test:e2e:fixtures:install"]
66-
run = "bun run --cwd tests/e2e/fixtures astro build"
67-
6860
[tasks."test:e2e:fixtures:server"]
69-
depends = ["test:e2e:fixtures:build"]
70-
run = "bun run --cwd tests/e2e/fixtures astro preview"
61+
depends = ["build"]
62+
run = ["bun install --frozen-lockfile", "bun run build", "bun run preview"]
63+
dir = "tests/e2e/fixtures"
7164

7265
[tasks."test:e2e:fixtures:remove-symlinks"]
7366
# remove before some checks to avoid symlink loops

playwright.config.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ export default defineConfig({
1414
},
1515

1616
webServer: {
17-
command: "mise run test:e2e:fixtures:server",
17+
command: process.env["CI"]
18+
? "bun run --cwd tests/e2e/fixtures preview"
19+
: "mise run test:e2e:fixtures:server",
1820
url: "http://localhost:4321",
1921
// set to 5 minutes because image optimization can take a while
2022
timeout: 5 * 60 * 1000,

tests/e2e/fixtures/package.json

+4
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@
44
"type": "module",
55
"dependencies": {
66
"astro-better-image-service": "link:astro-better-image-service"
7+
},
8+
"scripts": {
9+
"build": "astro build",
10+
"preview": "astro preview"
711
}
812
}

0 commit comments

Comments
 (0)