-
-
Notifications
You must be signed in to change notification settings - Fork 210
174 lines (168 loc) · 5.71 KB
/
ci.yml
File metadata and controls
174 lines (168 loc) · 5.71 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
name: ci
on:
push:
branches: [master]
pull_request:
types: [opened, synchronize, reopened, labeled]
workflow_dispatch:
inputs:
release_type:
description: 'Release type'
required: true
default: 'beta'
type: choice
options: [beta, graduate]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
if: github.event_name == 'workflow_dispatch' || (!contains(github.event.head_commit.message, 'ci(release)'))
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.discover.outputs.matrix }}
has_tests: ${{ steps.discover.outputs.has_tests }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- run: git fetch origin master:master || true
- uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
- run: corepack enable
- uses: actions/cache@v5
id: deps-cache
with:
path: |
node_modules
.yarn
~/.cache/Cypress
~/.cache/puppeteer
key: deps-${{ runner.os }}-node${{ hashFiles('.nvmrc') }}-${{ hashFiles('yarn.lock') }}
restore-keys: deps-${{ runner.os }}-node${{ hashFiles('.nvmrc') }}-
- uses: actions/cache@v5
if: steps.deps-cache.outputs.cache-hit != 'true'
with:
path: ~/.cache
key: yarn-dl-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
restore-keys: yarn-dl-${{ runner.os }}-
- run: yarn --immutable
# Ensure Puppeteer Chrome binary is downloaded (needed for Karma tests in integration jobs)
# Puppeteer downloads Chrome on first use, so we trigger it here to include it in cache
- run: |
for app in examples/custom-webpack/*/; do
if [ -f "$app/package.json" ] && grep -q "puppeteer" "$app/package.json"; then
(cd "$app" && node -e "try { require('puppeteer').executablePath(); } catch(e) {}" || true)
fi
done
# On PRs, build only affected packages unless 'ci:full' label is present.
# On master events (push/workflow_dispatch), build all packages. (see #2026)
- run: |
if [ "${{ github.event_name }}" == "pull_request" ] && [ "${{ contains(github.event.pull_request.labels.*.name, 'ci:full') }}" != "true" ]; then
yarn build:packages
else
yarn build:packages:all
fi
- id: discover
run: |
MATRIX=$(node scripts/discover-tests.js)
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
TEST_COUNT=$(echo "$MATRIX" | jq '.include | length')
if [ "$TEST_COUNT" -gt 0 ]; then
echo "has_tests=true" >> $GITHUB_OUTPUT
else
echo "has_tests=false" >> $GITHUB_OUTPUT
fi
echo "Test count: $TEST_COUNT"
- uses: actions/upload-artifact@v7
with:
name: dist
path: packages/*/dist
integration:
needs: build
if: needs.build.outputs.has_tests == 'true'
name: ${{ matrix.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.build.outputs.matrix) }}
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
- run: corepack enable
- uses: actions/cache/restore@v5
with:
path: |
node_modules
.yarn
~/.cache/Cypress
~/.cache/puppeteer
key: deps-${{ runner.os }}-node${{ hashFiles('.nvmrc') }}-${{ hashFiles('yarn.lock') }}
fail-on-cache-miss: true
- uses: actions/download-artifact@v8
with:
name: dist
path: packages
- run: sudo apt-get update && sudo apt-get install -y xvfb
- name: ${{ matrix.purpose }}
run: |
Xvfb :99 &
export DISPLAY=:99
cd ${{ matrix.app }}
${{ matrix.command }}
ci-pass:
needs: [build, integration]
if: always()
runs-on: ubuntu-latest
steps:
- run: |
if [ "${{ needs.build.result }}" != "success" ]; then
echo "Build failed or was cancelled"
exit 1
fi
if [ "${{ needs.integration.result }}" != "success" ] && [ "${{ needs.integration.result }}" != "skipped" ]; then
echo "Integration tests failed or were cancelled"
exit 1
fi
publish:
needs: [build, integration]
if: github.ref == 'refs/heads/master' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v6
with:
token: ${{ secrets.GH_PERSONAL_TOKEN }}
fetch-depth: 0
- uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
- run: corepack enable
- uses: actions/cache/restore@v5
with:
path: |
node_modules
.yarn
~/.cache/Cypress
~/.cache/puppeteer
key: deps-${{ runner.os }}-node${{ hashFiles('.nvmrc') }}-${{ hashFiles('yarn.lock') }}
fail-on-cache-miss: true
- uses: actions/download-artifact@v8
with:
name: dist
path: packages
- name: Publish
run: |
git config --global user.name ${{ secrets.GIT_USER }}
git config --global user.email ${{ secrets.GIT_EMAIL }}
if [ "${{ github.event.inputs.release_type }}" == "graduate" ]; then
npm run graduate -- --yes
else
bash scripts/default-registry.sh
fi