Skip to content

Commit 4dec841

Browse files
chore: Fix CI script for PUSH events (#345)
1 parent e3aedb0 commit 4dec841

6 files changed

Lines changed: 81 additions & 47 deletions

File tree

.github/workflows/ci.yml

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,27 +55,68 @@ jobs:
5555
${{ runner.os }}-turbo-
5656
path: .turbo
5757

58-
- name: Lint packages & sample
59-
# Only execute for the packages that are diverging from the pull request original baseline.
60-
run: pnpm lint --filter=...[${{ github.event.pull_request.base.sha }}]
61-
6258
- name: Build packages
63-
run: pnpm build-pkg
59+
# For a PR, only build the packages that are diverging from the pull request original baseline.
60+
run: |
61+
if [ "${{ github.event_name }}" == "pull_request" ]; then
62+
pnpm turbo run build --filter={./packages/*}...[${{ github.event.pull_request.base.sha }}]
63+
else
64+
pnpm build-pkg
65+
fi
66+
67+
- name: Lint packages & sample
68+
# For a PR, only lint the packages that are diverging from the pull request original baseline.
69+
run: |
70+
if [ "${{ github.event_name }}" == "pull_request" ]; then
71+
pnpm lint --filter=...[${{ github.event.pull_request.base.sha }}]
72+
else
73+
pnpm lint
74+
fi
6475
6576
- name: Build webpack sample
66-
run: pnpm build-webpack
77+
# For a PR, only build the sample if it's diverging from the pull request original baseline.
78+
run: |
79+
if [ "${{ github.event_name }}" == "pull_request" ]; then
80+
pnpm turbo run build --filter={./samples/webpack/*}...[${{ github.event.pull_request.base.sha }}]
81+
else
82+
pnpm build-webpack
83+
fi
6784
6885
- name: Build Rsbuild sample
69-
run: pnpm build-rsbuild
86+
# For a PR, only build the sample if it's diverging from the pull request original baseline.
87+
run: |
88+
if [ "${{ github.event_name }}" == "pull_request" ]; then
89+
pnpm turbo run build --filter={./samples/rsbuild/*}...[${{ github.event.pull_request.base.sha }}]
90+
else
91+
pnpm build-rsbuild
92+
fi
7093
7194
- name: Build Storybook Rsbuild sample
72-
run: pnpm build-storybook-rsbuild
95+
# For a PR, only build the sample if it's diverging from the pull request original baseline.
96+
run: |
97+
if [ "${{ github.event_name }}" == "pull_request" ]; then
98+
pnpm turbo run build --filter={./samples/storybook/rsbuild}...[${{ github.event.pull_request.base.sha }}]
99+
else
100+
pnpm build-storybook-rsbuild
101+
fi
73102
74103
- name: Build Storybook Rslib sample
75-
run: pnpm build-storybook-rslib
104+
# For a PR, only build the sample if it's diverging from the pull request original baseline.
105+
run: |
106+
if [ "${{ github.event_name }}" == "pull_request" ]; then
107+
pnpm turbo run build --filter={./samples/storybook/rslib}...[${{ github.event.pull_request.base.sha }}]
108+
else
109+
pnpm build-storybook-rslib
110+
fi
76111
77112
- name: Test packages
78-
run: pnpm test --filter=...[${{ github.event.pull_request.base.sha }}]
113+
# For a PR, only test the packages that are diverging from the pull request original baseline.
114+
run: |
115+
if [ "${{ github.event_name }}" == "pull_request" ]; then
116+
pnpm lint --filter=...[${{ github.event.pull_request.base.sha }}]
117+
else
118+
pnpm lint
119+
fi
79120
80121
- name: Save Turborepo cache
81122
id: cache-turborepo-save

packages/rslib-configs/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
},
4242
"devDependencies": {
4343
"@eslint/js": "9.39.2",
44-
"@rsbuild/core": "1.7.2",
4544
"@rslib/core": "0.19.2",
4645
"@types/node": "25.0.7",
4746
"@typescript-eslint/parser": "8.53.0",

packages/rslib-configs/tests/build.test.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type { DistPathConfig, RsbuildPlugin, SourceMap } from "@rsbuild/core";
2-
import type { RslibConfig } from "@rslib/core";
1+
import type { Rsbuild, RslibConfig } from "@rslib/core";
32
import { test, vi } from "vitest";
43
import type { RslibConfigTransformer } from "../src/applyTransformers.ts";
54
import { defineBuildConfig } from "../src/build.ts";
@@ -83,16 +82,16 @@ test.concurrent("when a dist path is provided, the output.distPath option is the
8382
tsconfigPath: "./build.json"
8483
});
8584

86-
expect((result.output?.distPath as DistPathConfig).js).toBe("./dist-path");
85+
expect((result.output?.distPath as Rsbuild.DistPathConfig).js).toBe("./dist-path");
8786
});
8887

8988
test.concurrent("when additional plugins are provided, append the provided plugins at the end of the plugins array", ({ expect }) => {
90-
const plugin1: RsbuildPlugin = {
89+
const plugin1: Rsbuild.RsbuildPlugin = {
9190
name: "plugin-1",
9291
setup: () => {}
9392
};
9493

95-
const plugin2: RsbuildPlugin = {
94+
const plugin2: Rsbuild.RsbuildPlugin = {
9695
name: "plugin-2",
9796
setup: () => {}
9897
};
@@ -121,7 +120,7 @@ test.concurrent("when sourceMap is false, the output.sourceMap option is false",
121120
});
122121

123122
test.concurrent("when sourceMap is an object, the output.sourceMap option is the object", ({ expect }) => {
124-
const sourceMap: SourceMap = {
123+
const sourceMap: Rsbuild.SourceMap = {
125124
js: false,
126125
css: false
127126
};
@@ -139,7 +138,7 @@ test.concurrent("when react is false, the react plugin is not included", ({ expe
139138
tsconfigPath: "./build.json"
140139
});
141140

142-
const plugin = result.plugins?.find(x => (x as RsbuildPlugin).name === "rsbuild:react");
141+
const plugin = result.plugins?.find(x => (x as Rsbuild.RsbuildPlugin).name === "rsbuild:react");
143142

144143
expect(plugin).toBeUndefined();
145144
});
@@ -150,7 +149,7 @@ test.concurrent("when react is true, the react plugin is included", ({ expect })
150149
tsconfigPath: "./build.json"
151150
});
152151

153-
const plugin = result.plugins?.find(x => (x as RsbuildPlugin).name === "rsbuild:react");
152+
const plugin = result.plugins?.find(x => (x as Rsbuild.RsbuildPlugin).name === "rsbuild:react");
154153

155154
expect(plugin).toBeDefined();
156155
});
@@ -171,7 +170,7 @@ test.concurrent("when svgr is false, the svgr plugin is not included", ({ expect
171170
tsconfigPath: "./build.json"
172171
});
173172

174-
const plugin = result.plugins?.find(x => (x as RsbuildPlugin).name === "rsbuild:svgr");
173+
const plugin = result.plugins?.find(x => (x as Rsbuild.RsbuildPlugin).name === "rsbuild:svgr");
175174

176175
expect(plugin).toBeUndefined();
177176
});
@@ -182,7 +181,7 @@ test.concurrent("when svgr is true, the svgr plugin is included", ({ expect }) =
182181
tsconfigPath: "./build.json"
183182
});
184183

185-
const plugin = result.plugins?.find(x => (x as RsbuildPlugin).name === "rsbuild:svgr");
184+
const plugin = result.plugins?.find(x => (x as Rsbuild.RsbuildPlugin).name === "rsbuild:svgr");
186185

187186
expect(plugin).toBeDefined();
188187
});
@@ -249,7 +248,7 @@ test.concurrent("when multiple transformers are provided, all the transformers a
249248
const distPathTransformer: RslibConfigTransformer = (config: RslibConfig) => {
250249
config.output = config.output ?? {};
251250
config.output.distPath = config.output.distPath ?? {};
252-
(config.output.distPath as DistPathConfig).js = "a-custom-dist-path-in-a-tranformer";
251+
(config.output.distPath as Rsbuild.DistPathConfig).js = "a-custom-dist-path-in-a-tranformer";
253252

254253
return config;
255254
};
@@ -260,7 +259,7 @@ test.concurrent("when multiple transformers are provided, all the transformers a
260259
});
261260

262261
expect(result.source!.entry!.index).toBe("a-custom-value-in-a-transformer");
263-
expect((result.output!.distPath as DistPathConfig).js).toBe("a-custom-dist-path-in-a-tranformer");
262+
expect((result.output!.distPath as Rsbuild.DistPathConfig).js).toBe("a-custom-dist-path-in-a-tranformer");
264263
});
265264

266265
test.concurrent("transformers context environment is \"build\"", ({ expect }) => {

packages/rslib-configs/tests/dev.test.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type { DistPathConfig, RsbuildPlugin, SourceMap } from "@rsbuild/core";
2-
import type { RslibConfig } from "@rslib/core";
1+
import type { Rsbuild, RslibConfig } from "@rslib/core";
32
import { test, vi } from "vitest";
43
import type { RslibConfigTransformer } from "../src/applyTransformers.ts";
54
import { defineDevConfig } from "../src/dev.ts";
@@ -83,16 +82,16 @@ test.concurrent("when a dist path is provided, the output.distPath option is the
8382
tsconfigPath: "./build.json"
8483
});
8584

86-
expect((result.output?.distPath as DistPathConfig).js).toBe("./dist-path");
85+
expect((result.output?.distPath as Rsbuild.DistPathConfig).js).toBe("./dist-path");
8786
});
8887

8988
test.concurrent("when additional plugins are provided, append the provided plugins at the end of the plugins array", ({ expect }) => {
90-
const plugin1: RsbuildPlugin = {
89+
const plugin1: Rsbuild.RsbuildPlugin = {
9190
name: "plugin-1",
9291
setup: () => {}
9392
};
9493

95-
const plugin2: RsbuildPlugin = {
94+
const plugin2: Rsbuild.RsbuildPlugin = {
9695
name: "plugin-2",
9796
setup: () => {}
9897
};
@@ -121,7 +120,7 @@ test.concurrent("when sourceMap is false, the output.sourceMap option is false",
121120
});
122121

123122
test.concurrent("when sourceMap is an object, the output.sourceMap option is the object", ({ expect }) => {
124-
const sourceMap: SourceMap = {
123+
const sourceMap: Rsbuild.SourceMap = {
125124
js: false,
126125
css: false
127126
};
@@ -139,7 +138,7 @@ test.concurrent("when react is false, the react plugin is not included", ({ expe
139138
tsconfigPath: "./build.json"
140139
});
141140

142-
const plugin = result.plugins?.find(x => (x as RsbuildPlugin).name === "rsbuild:react");
141+
const plugin = result.plugins?.find(x => (x as Rsbuild.RsbuildPlugin).name === "rsbuild:react");
143142

144143
expect(plugin).toBeUndefined();
145144
});
@@ -150,7 +149,7 @@ test.concurrent("when react is true, the react plugin is included", ({ expect })
150149
tsconfigPath: "./build.json"
151150
});
152151

153-
const plugin = result.plugins?.find(x => (x as RsbuildPlugin).name === "rsbuild:react");
152+
const plugin = result.plugins?.find(x => (x as Rsbuild.RsbuildPlugin).name === "rsbuild:react");
154153

155154
expect(plugin).toBeDefined();
156155
});
@@ -171,7 +170,7 @@ test.concurrent("when svgr is false, the svgr plugin is not included", ({ expect
171170
tsconfigPath: "./build.json"
172171
});
173172

174-
const plugin = result.plugins?.find(x => (x as RsbuildPlugin).name === "rsbuild:svgr");
173+
const plugin = result.plugins?.find(x => (x as Rsbuild.RsbuildPlugin).name === "rsbuild:svgr");
175174

176175
expect(plugin).toBeUndefined();
177176
});
@@ -182,7 +181,7 @@ test.concurrent("when svgr is true, the svgr plugin is included", ({ expect }) =
182181
tsconfigPath: "./build.json"
183182
});
184183

185-
const plugin = result.plugins?.find(x => (x as RsbuildPlugin).name === "rsbuild:svgr");
184+
const plugin = result.plugins?.find(x => (x as Rsbuild.RsbuildPlugin).name === "rsbuild:svgr");
186185

187186
expect(plugin).toBeDefined();
188187
});
@@ -249,7 +248,7 @@ test.concurrent("when multiple transformers are provided, all the transformers a
249248
const distPathTransformer: RslibConfigTransformer = (config: RslibConfig) => {
250249
config.output = config.output ?? {};
251250
config.output.distPath = config.output.distPath ?? {};
252-
(config.output.distPath as DistPathConfig).js = "a-custom-dist-path-in-a-tranformer";
251+
(config.output.distPath as Rsbuild.DistPathConfig).js = "a-custom-dist-path-in-a-tranformer";
253252

254253
return config;
255254
};
@@ -260,7 +259,7 @@ test.concurrent("when multiple transformers are provided, all the transformers a
260259
});
261260

262261
expect(result.source!.entry!.index).toBe("a-custom-value-in-a-transformer");
263-
expect((result.output!.distPath as DistPathConfig).js).toBe("a-custom-dist-path-in-a-tranformer");
262+
expect((result.output!.distPath as Rsbuild.DistPathConfig).js).toBe("a-custom-dist-path-in-a-tranformer");
264263
});
265264

266265
test.concurrent("transformers context environment is \"dev\"", ({ expect }) => {

packages/rslib-configs/tests/storybook.test.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
import type { DistPathConfig, RsbuildPlugin, SourceMap } from "@rsbuild/core";
2-
import type { RslibConfig } from "@rslib/core";
1+
import type { Rsbuild, RslibConfig } from "@rslib/core";
32
import { test, vi } from "vitest";
43
import type { RslibConfigTransformer } from "../src/applyTransformers.ts";
54
import { defineStorybookConfig } from "../src/storybook.ts";
65

76
test.concurrent("when additional plugins are provided, append the provided plugins at the end of the plugins array", ({ expect }) => {
8-
const plugin1: RsbuildPlugin = {
7+
const plugin1: Rsbuild.RsbuildPlugin = {
98
name: "plugin-1",
109
setup: () => {}
1110
};
1211

13-
const plugin2: RsbuildPlugin = {
12+
const plugin2: Rsbuild.RsbuildPlugin = {
1413
name: "plugin-2",
1514
setup: () => {}
1615
};
@@ -37,7 +36,7 @@ test.concurrent("when sourceMap is false, the output.sourceMap option is false",
3736
});
3837

3938
test.concurrent("when sourceMap is an object, the output.sourceMap option is the object", ({ expect }) => {
40-
const sourceMap: SourceMap = {
39+
const sourceMap: Rsbuild.SourceMap = {
4140
js: false,
4241
css: false
4342
};
@@ -54,7 +53,7 @@ test.concurrent("when react is false, the react plugin is not included", ({ expe
5453
react: false
5554
});
5655

57-
const plugin = result.plugins?.find(x => (x as RsbuildPlugin).name === "rsbuild:react");
56+
const plugin = result.plugins?.find(x => (x as Rsbuild.RsbuildPlugin).name === "rsbuild:react");
5857

5958
expect(plugin).toBeUndefined();
6059
});
@@ -74,7 +73,7 @@ test.concurrent("when svgr is false, the svgr plugin is not included", ({ expect
7473
svgr: false
7574
});
7675

77-
const plugin = result.plugins?.find(x => (x as RsbuildPlugin).name === "rsbuild:svgr");
76+
const plugin = result.plugins?.find(x => (x as Rsbuild.RsbuildPlugin).name === "rsbuild:svgr");
7877

7978
expect(plugin).toBeUndefined();
8079
});
@@ -136,7 +135,7 @@ test.concurrent("when multiple transformers are provided, all the transformers a
136135
const distPathTransformer: RslibConfigTransformer = (config: RslibConfig) => {
137136
config.output = config.output ?? {};
138137
config.output.distPath = config.output.distPath ?? {};
139-
(config.output.distPath as DistPathConfig).js = "a-custom-dist-path-in-a-tranformer";
138+
(config.output.distPath as Rsbuild.DistPathConfig).js = "a-custom-dist-path-in-a-tranformer";
140139

141140
return config;
142141
};
@@ -146,7 +145,7 @@ test.concurrent("when multiple transformers are provided, all the transformers a
146145
});
147146

148147
expect(result.source!.entry!.index).toBe("a-custom-value-in-a-transformer");
149-
expect((result.output!.distPath as DistPathConfig).js).toBe("a-custom-dist-path-in-a-tranformer");
148+
expect((result.output!.distPath as Rsbuild.DistPathConfig).js).toBe("a-custom-dist-path-in-a-tranformer");
150149
});
151150

152151
test.concurrent("transformers context environment is \"storybook\"", ({ expect }) => {

pnpm-lock.yaml

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)