Skip to content

Commit 0b79aa6

Browse files
authored
Split examples test for speed (#10271)
* SPlit examples test for speed * Split SWC plugin test * Merge examples test * Clean up and simplify split logic
1 parent 8737dd8 commit 0b79aa6

File tree

2 files changed

+44
-5
lines changed

2 files changed

+44
-5
lines changed

.github/workflows/main.yml

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,31 @@ jobs:
5656
yarn run generate:examples:${{matrix.method}}
5757
git diff --exit-code -- dev-test/
5858
dev-tests:
59-
name: Examples
59+
name: Examples - Normal
60+
runs-on: ubuntu-latest
61+
steps:
62+
- name: Checkout
63+
uses: actions/checkout@v4
64+
- name: Setup env
65+
uses: the-guild-org/shared-config/setup@main
66+
with:
67+
nodeVersion: 18
68+
- name: Build
69+
run: yarn build
70+
env:
71+
CI: true
72+
- name: Generate and Diff Codegen Artifacts
73+
run: |
74+
EXAMPLE_TYPE=normal yarn examples:codegen
75+
git diff --exit-code -- examples/
76+
- name: Build Examples
77+
run: |
78+
EXAMPLE_TYPE=normal yarn examples:build
79+
- name: End2End Test Examples
80+
run: |
81+
EXAMPLE_TYPE=normal yarn examples:test:end2end
82+
dev-tests-swc:
83+
name: Examples - SWC
6084
runs-on: ubuntu-latest
6185
steps:
6286
- name: Checkout
@@ -80,14 +104,14 @@ jobs:
80104
CI: true
81105
- name: Generate and Diff Codegen Artifacts
82106
run: |
83-
yarn examples:codegen
107+
EXAMPLE_TYPE=swc yarn examples:codegen
84108
git diff --exit-code -- examples/
85109
- name: Build Examples
86110
run: |
87-
yarn examples:build
111+
EXAMPLE_TYPE=swc yarn examples:build
88112
- name: End2End Test Examples
89113
run: |
90-
yarn examples:test:end2end
114+
EXAMPLE_TYPE=swc yarn examples:test:end2end
91115
esm:
92116
name: Testing exports integrity
93117
runs-on: ubuntu-latest

scripts/print-example-ci-command.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,30 @@ const packageJSON = fg.sync(['examples/**/package.json'], { ignore: ['**/node_mo
66

77
const ignoredPackages = [];
88

9+
const exampleTypeMap = {
10+
all: 'all',
11+
swc: 'swc',
12+
normal: 'normal',
13+
};
14+
const exampleType = exampleTypeMap[process.env.EXAMPLE_TYPE] || 'all';
15+
916
const result = packageJSON.reduce(
1017
(res, packageJSONPath) => {
11-
const { name } = fs.readJSONSync(packageJSONPath);
18+
const { name, devDependencies } = fs.readJSONSync(packageJSONPath);
1219

1320
if (ignoredPackages.includes(name)) {
1421
res.ignored.push(name);
1522
return res;
1623
}
1724

25+
if (
26+
(exampleType === 'swc' && !devDependencies['@graphql-codegen/client-preset-swc-plugin']) ||
27+
(exampleType === 'normal' && devDependencies['@graphql-codegen/client-preset-swc-plugin'])
28+
) {
29+
res.ignored.push(name);
30+
return res;
31+
}
32+
1833
res.commands.push(`yarn workspace ${name} run ${process.argv[2]}`);
1934
return res;
2035
},

0 commit comments

Comments
 (0)