forked from isomorphic-git/isomorphic-git
-
Notifications
You must be signed in to change notification settings - Fork 2
230 lines (189 loc) · 6.75 KB
/
ci.yml
File metadata and controls
230 lines (189 loc) · 6.75 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
name: Build
on:
pull_request:
workflow_dispatch:
# Cancel in-progress runs for the current workflow
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build (Node.js v14)
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 14
cache: npm
- name: Install dependencies
run: npm ci
env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
PUPPETEER_SKIP_DOWNLOAD: true
- name: Run lint
run: |
npx nps lint
- name: Run build
run: |
# Run the subset of the `build` necessary to run the tests.
npx nps \
build.rollup \
build.typings \
build.webpack \
build.indexjson \
build.treeshake \
build.size
env:
BUNDLEWATCH_GITHUB_TOKEN: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}
- name: Run tests (CLI)
run: |
# `test.typecheck` must be run after `build.rollup` and `build.typings`
npx nps \
test.typecheck \
test.setup \
test.jest
- name: Save test results
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: test-results-jest
path: junit/*.xml
# Problem: GitHub does not support Code Coverage reports like Azure Pipelines.
# TODO: Update the workflow to "Publish code coverage" somewhere.
- name: Save code coverage
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork }}
uses: actions/upload-artifact@v4
with:
name: code-coverage-results
path: coverage/
- name: Build artifacts
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork }}
run: |
# Run the subset of the `test` necessary to test from the CLI.
npx nps \
build.docs \
build.pack
# Warn when there are uncommitted changes to documentation
if ! git diff --quiet --exit-code; then
echo "::warning title=Uncommitted Changes to Documentation::There are uncommitted changes to the documentation. Please run \`nps build.docs\` and commit the changes."
fi
- name: Save npm-tarball.tgz
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork }}
uses: actions/upload-artifact@v4
with:
name: npm-tarball.tgz
path: isomorphic-git-0.0.0-development.tgz
- name: Save index.umd.min.js
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork }}
uses: actions/upload-artifact@v4
with:
name: index.umd.min.js
path: index.umd.min.js
test-in-browser:
name: Test (${{ matrix.karma-launcher }})
needs: build
runs-on: ubuntu-latest
# The BrowserStack test running Android 10 on a Pixel 4 timed out after 15 minutes.
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
# This is a comma-separated list of Karma launchers
karma-launcher: ${{ fromJSON(format('[{0}]', '"ChromeHeadlessNoSandbox","FirefoxHeadless","sl_edge","sl_safari","sl_ios_safari","bs_android_chrome"')) }}
# Our BrowserStack plan allows up to 5 parallel tests. We limit each workflow to 2 to avoid the limit.
max-parallel: 2
steps:
- uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 14
cache: npm
- name: Install dependencies
run: |
# Only install Chromium when we are running a test using the Chrome browser.
# Otherwise, do not install it to save ~10 seconds.
if [[ "${{ matrix.karma-launcher }}" != "ChromeHeadlessNoSandbox" ]]; then
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
export PUPPETEER_SKIP_DOWNLOAD=true
fi
npm ci
- name: Run build
run: |
# Run the subset of the `build` necessary to run the tests.
npx nps \
build.rollup \
build.webpack \
build.indexjson \
build.treeshake
- name: Run tests (${{ matrix.karma-launcher }})
run: |
# Run the subset of the `test` necessary to test from the browser.
# Use X Virtual Frame Buffer (xvfb) to run the browser with no display (headless).
xvfb-run --auto-servernum --server-args='-screen 0, 1920x1080x24' npx nps \
test.setup \
test.karma
env:
BROWSER_STACK_USERNAME: ${{ secrets.BROWSER_STACK_USERNAME }}
BROWSER_STACK_ACCESS_KEY: ${{ secrets.BROWSER_STACK_ACCESS_KEY }}
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
TEST_BROWSERS: ${{ matrix.karma-launcher }}
- name: Save test results
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.karma-launcher }}
path: junit/*.xml
publish-test-results:
name: Publish Test Results
needs: test-in-browser
runs-on: ubuntu-latest
if: ${{ !cancelled() }}
timeout-minutes: 5
steps:
- name: Download test results
if: ${{ !cancelled() }}
uses: actions/download-artifact@v4
# Problem: GitHub does not support Test Results reports like Azure Pipelines.
# TODO: Update the workflow to combine and "Publish test results" somewhere.
- name: Publish test results
if: ${{ !cancelled() }}
run: |
# List the test results
echo test-results-*/*.xml
# TODO: Combine and publish the test results
publish-artifacts:
name: Publish
needs: test-in-browser
runs-on: ubuntu-latest
if: ${{ github.ref == 'main' || github.ref_name == 'beta' }}
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 14
cache: npm
- name: Install dependencies
run: npm ci
env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
PUPPETEER_SKIP_DOWNLOAD: true
- name: Publish to npm
run: |
npm run semantic-release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Update website
if: ${{ github.ref == 'main' }}
run: |
npm run publish-website
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}