Repository navigation
207 lines (194 loc) · 6.73 KB
/
Copy pathjavascript.yml
File metadata and controls
207 lines (194 loc) · 6.73 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
name: Javascript
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
# Every job installs and builds with the Node version in .nvmrc and npm 12 from
# .github/actions/setup-node-npm, which also applies the .npmrc supply-chain
# settings. Jobs that test other Node versions switch Node only to
# run the tests.
#
# Checkouts use persist-credentials: false so the token isn't left on disk for
# later steps. No job runs authenticated git commands after checkout.
jobs:
lint_markdown_files:
uses: optimizely/javascript-sdk/.github/workflows/lint_markdown.yml@master
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: ./.github/actions/setup-node-npm
- name: Install dependencies
run: npm ci
- name: Run linting
run: npm run lint
typescript_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: ./.github/actions/setup-node-npm
with:
cache-dependency-path: |
package-lock.json
examples/typescript/package-lock.json
- name: Install dependencies
run: npm ci
- name: Run TypeScript example
run: npm run test-typescript
commonjs_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: ./.github/actions/setup-node-npm
- name: Build, pack, and install the SDK in the example
run: |
npm ci
npm pack
npm run test-commonjs -- --skip-build --skip-run
- name: Set up Node 18 (runtime test)
uses: actions/setup-node@v7
with:
node-version: 18
- name: Run CommonJS example
working-directory: examples/node-commonjs
run: npm start
react_native_metro_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: ./.github/actions/setup-node-npm
with:
cache-dependency-path: |
package-lock.json
tests/react-native-metro/fixtures/*/package-lock.json
- name: Install dependencies
run: npm ci
- name: Run React Native Metro tests
run: npm run test-rn-metro
integration_tests:
uses: optimizely/javascript-sdk/.github/workflows/integration_test.yml@master
secrets:
CI_USER_TOKEN: ${{ secrets.CI_USER_TOKEN }}
TRAVIS_COM_TOKEN: ${{ secrets.TRAVIS_COM_TOKEN }}
fullstack_production_suite:
uses: optimizely/javascript-sdk/.github/workflows/integration_test.yml@master
with:
FULLSTACK_TEST_REPO: ProdTesting
secrets:
CI_USER_TOKEN: ${{ secrets.CI_USER_TOKEN }}
TRAVIS_COM_TOKEN: ${{ secrets.TRAVIS_COM_TOKEN }}
browser_tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
browser: ['chrome', 'firefox', 'edge', 'safari']
env:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
USE_LOCAL_BROWSER: 'false'
TEST_BROWSER: ${{ matrix.browser }}
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
# Browser and UMD tests run from tests/browser (see its README), which needs Node 22.23.4+.
- uses: ./.github/actions/setup-node-npm
with:
cache-dependency-path: |
package-lock.json
tests/browser/package-lock.json
- name: Install SDK dependencies
run: npm ci
- name: Install browser test dependencies
id: browser-deps
working-directory: ./tests/browser
run: npm ci
- name: Browser tests - ${{ matrix.browser }}
working-directory: ./tests/browser
run: npm run test-browser
# Builds the UMD bundle (root build-browser-umd) and tests it in the same browsers.
# Runs even if the browser tests failed, so both results are reported, but not
# if installing dependencies failed (browser-deps is skipped if the SDK install fails).
- name: UMD tests - ${{ matrix.browser }}
if: ${{ !cancelled() && steps.browser-deps.outcome == 'success' }}
working-directory: ./tests/browser
run: npm run test-umd
generate_messages_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: ./.github/actions/setup-node-npm
- name: Install dependencies
run: npm ci
- name: Test generate-messages script
run: node scripts/test-generate-messages.js
unit_tests:
runs-on: ubuntu-latest
strategy:
matrix:
node: ['18', '20', '22', '24']
env:
# The Coveralls action, for the Coveralls Parallel step below and the
# finish job. It's a third-party action, so it's pinned to a full commit
# SHA: a tag can be moved to other code (as in the 2025
# tj-actions/changed-files attack), and both steps get the GITHUB_TOKEN.
# GitHub's own actions (actions/*) use tags. Nothing updates the pin
# automatically. To upgrade, use the commit SHA of the new release tag and
# update the version comment.
# `uses:` doesn't accept ${{ }} expressions, so the steps can't read this
# env var. They reuse the value through the YAML anchor &coveralls-action.
COVERALLS_ACTION: &coveralls-action coverallsapp/github-action@8d6379e14d29928660c4ba802d8e85393440b329 # v2.3.8
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
# Install with the Node version in .nvmrc and npm 12, then run the tests on
# the matrix version.
- uses: ./.github/actions/setup-node-npm
- name: Install dependencies
run: npm ci
- name: Set up Node ${{ matrix.node }}
uses: actions/setup-node@v7
with:
node-version: ${{ matrix.node }}
check-latest: true
- name: Unit tests
run: npm run coveralls
# The pinned Coveralls action from this job's env (see the comment there).
- name: Coveralls Parallel
uses: *coveralls-action
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./coverage/lcov.info
flag-name: run-${{ matrix.node }}
# This is a parallel build so need this
parallel: true
base-path: .
# As testing against multiple versions need this to
# finish the parallel build
finish:
name: Coveralls coverage
needs: unit_tests
runs-on: ubuntu-latest
steps:
# The pinned Coveralls action from the unit_tests job's env (see the
# comment there).
- name: Coveralls Finished
uses: *coveralls-action
with:
github-token: ${{ secrets.github_token }}
path-to-lcov: ./coverage/lcov.info
parallel-finished: true
base-path: .