-
Notifications
You must be signed in to change notification settings - Fork 25
181 lines (161 loc) · 5.81 KB
/
ci.yml
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
name: CI
on: push
env:
# Creates and uploads sourcemaps to Application error telemetry, and save the built extension as an artifact
PUBLIC_RELEASE: ${{ github.ref == 'refs/heads/main' }}
# Staging URL, also directly used by webpack
SERVICE_URL: https://app-stg.pixiebrix.com/
jobs:
test:
runs-on: ubuntu-latest
# The tests currently take ~16 minutes to run. Anything longer is probably due to a flaky test.
timeout-minutes: 25
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: npm
- run: npm ci
- run: npm run test -- --coverage
- uses: actions/upload-artifact@v4
with:
name: extension-test-coverage
path: coverage/coverage-final.json
upload-to-codecov:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: extension-test-coverage
- name: Upload coverage to Codecov
uses: Wandalen/[email protected]
with:
action: codecov/codecov-action@v3
with: |
fail_ci_if_error: true
verbose: true
# This upload endpoint from CodeCov is very flaky
# Retry every 15 seconds, for up to 10 minutes
attempt_delay: 15000
attempt_limit: 40
build:
runs-on: ubuntu-latest
env:
SOURCE_MAP_URL_BASE: https://pixiebrix-extension-source-maps.s3.amazonaws.com
SOURCE_MAP_PATH: sourcemaps/${{ github.job }}/${{ github.sha }}/mv${{ matrix.MV }}
strategy:
matrix:
include:
- MV: 2
PUBLIC_NAME: ""
- MV: 3
PUBLIC_NAME: "-mv3"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: npm
- run: npm ci
- run: npm run build:webpack
env:
MV: ${{ matrix.MV }}
ENVIRONMENT: staging
EXTERNALLY_CONNECTABLE: "${{ env.SERVICE_URL }}*"
MARKETPLACE_URL: ${{ secrets.STAGING_MARKETPLACE_URL }}
CHROME_EXTENSION_ID: kkomancachnjkdalpcokenmjlimmbaog
CHROME_MANIFEST_KEY: ${{ secrets.CHROME_MANIFEST_STAGING_PUBLIC_KEY }}
DATADOG_APPLICATION_ID: ${{ secrets.DATADOG_APPLICATION_ID }}
DATADOG_CLIENT_TOKEN: ${{ secrets.DATADOG_CLIENT_TOKEN }}
- name: Save extension
uses: actions/upload-artifact@v4
if: ${{ fromJSON(env.PUBLIC_RELEASE)}}
with:
name: build-staging${{ matrix.PUBLIC_NAME }}
path: |
dist
!dist/**/*.map
retention-days: 5
if-no-files-found: error
# The polyfill cannot be used outside the extension context
- run: "! grep 'loaded in a browser extension' dist/pageScript.js --files-with-matches"
name: Detect browser-polyfill in pageScript.js
# The messenger cannot be executed twice; only load it in contentScriptCore
# https://github.com/pixiebrix/webext-messenger/issues/88
# - contentScript.js can't have it because the file could be injected multiple times, guarding contentScriptCore
# - loadActivationEnhancements.js can't have it because it's always loaded alongside contentScript.js
- run: "! grep '__getTabData' dist/loadActivationEnhancements.js dist/contentScript.js dist/setExtensionIdInApp.js --files-with-matches"
name: Detect webext-messenger unwanted bundles
- uses: actions/upload-artifact@v4
# TODO: Eventually upload the MV3 report instead
if: matrix.MV == 2
name: Save report.html
with:
name: build-staging-bundle-dependency-report
path: report.html
retention-days: 5
if-no-files-found: error
generate-headers:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: npm
- run: npm ci
- run: npm run generate:headers
- uses: actions/upload-artifact@v4
name: Save headers.json
with:
name: brick-headers
path: headers.json
retention-days: 5
if-no-files-found: error
types:
# Surface type errors in GitHub’s UI faster and outside webpack
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: npm
- run: npm ci
- run: npm run build:typescript
# Prevent regressions in the files that have already been made strictNullCheck-compliant
- run: npm run build:strictNullChecks
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: npm
- run: npm ci
- run: npm run lint:full
dead-code:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: npm
- run: npm ci
# https://knip.dev/overview/getting-started#without-installation
- run: npm install -D knip@4
# Do a run without an exit code. Knip's "warn" setting is not working for files and devDependencies.
- run: npm run dead-code -- --config knip.mjs --no-exit-code
- run: npm run dead-code -- --config knip.mjs --include files,duplicates,dependencies,classMembers,binaries,enumMembers,nsTypes,exports,nsExports
# https://pre-commit.com/#usage-in-continuous-integration
prettier:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: pre-commit/[email protected]