forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
184 lines (166 loc) · 5.92 KB
/
test.yml
File metadata and controls
184 lines (166 loc) · 5.92 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
name: Run tests
on:
push:
branches:
- master
- '*-legacy'
pull_request_target:
types: [opened, synchronize, reopened]
concurrency:
group: test-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
checkout:
name: "Check out source and install dependencies"
timeout-minutes: 2
runs-on: ubuntu-latest
outputs:
ref: ${{ steps.info.outputs.ref }}
commit: ${{ steps.info.outputs.commit }}
branch: ${{ steps.info.outputs.branch }}
fork: ${{ steps.info.outputs.fork }}
base-branch: ${{ steps.info.outputs.base-branch }}
base-commit: ${{ steps.info.outputs.base-commit }}
steps:
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '20'
- name: Checkout code (PR)
id: checkout-pr
if: ${{ github.event_name == 'pull_request_target' }}
uses: actions/checkout@v5
with:
ref: refs/pull/${{ github.event.pull_request.number }}/head
- name: Checkout code (push)
id: checkout-push
if: ${{ github.event_name == 'push' }}
uses: actions/checkout@v5
- name: Commit info
id: info
run: |
echo ref="${{ steps.checkout-pr.outputs.ref || steps.checkout-push.outputs.ref }}" >> $GITHUB_OUTPUT
echo commit="${{ steps.checkout-pr.outputs.commit || steps.checkout-push.outputs.commit }}" >> $GITHUB_OUTPUT
echo branch="${{ github.head_ref || github.ref }}" >> $GITHUB_OUTPUT
echo fork="${{ (github.event.pull_request && github.event.pull_request.head.repo.owner.login != github.repository_owner) && github.event.pull_request.head.repo.owner.login || null }}" >> $GITHUB_OUTPUT
echo base-branch="${{ github.event.pull_request.base.ref || github.ref }}" >> $GITHUB_OUTPUT
echo base-commit="${{ github.event.pull_request.base.sha || github.event.before }}" >> $GITHUB_OUTPUT
- name: Install dependencies
run: npm ci
- name: Cache source
uses: actions/cache/save@v4
with:
path: .
key: source-${{ github.run_id }}
- name: Verify cache
uses: actions/cache/restore@v4
with:
path: .
key: source-${{ github.run_id }}
lookup-only: true
fail-on-cache-miss: true
lint:
name: "Run linter"
needs: checkout
runs-on: ubuntu-latest
steps:
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '20'
- name: Restore source
uses: actions/cache/restore@v4
with:
path: .
key: source-${{ github.run_id }}
fail-on-cache-miss: true
- name: lint
run: |
npx eslint
test-no-features:
name: "Unit tests (all features disabled)"
needs: checkout
uses: ./.github/workflows/run-unit-tests.yml
with:
build-cmd: npx gulp precompile-all-features-disabled
test-cmd: npx gulp test-all-features-disabled-nobuild
serialize: false
secrets:
BROWSERSTACK_USER_NAME: ${{ secrets.BROWSERSTACK_USER_NAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
test:
name: "Unit tests (all features enabled + coverage)"
needs: checkout
uses: ./.github/workflows/run-unit-tests.yml
with:
build-cmd: npx gulp precompile
test-cmd: npx gulp test-only-nobuild --browserstack
serialize: true
secrets:
BROWSERSTACK_USER_NAME: ${{ secrets.BROWSERSTACK_USER_NAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
test-e2e:
name: "End-to-end tests"
needs: checkout
runs-on: ubuntu-latest
concurrency:
# see test-chunk.yml for notes on concurrency groups
group: browserstack-${{ github.run_id }}
cancel-in-progress: false
env:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USER_NAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
steps:
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '20'
- name: Restore source
uses: actions/cache/restore@v4
with:
path: .
key: source-${{ github.run_id }}
fail-on-cache-miss: true
- name: 'BrowserStack Env Setup'
uses: 'browserstack/github-actions/setup-env@master'
with:
username: ${{ secrets.BROWSERSTACK_USER_NAME}}
access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
- name: 'BrowserStackLocal Setup'
uses: 'browserstack/github-actions/setup-local@master'
with:
local-testing: start
local-identifier: random
- name: 'Wait for browserstack'
uses: ./.github/actions/wait-for-browserstack
with:
BROWSERSTACK_USER_NAME: ${{ secrets.BROWSERSTACK_USER_NAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
- name: Run tests
uses: nick-fields/retry@v3
with:
timeout_minutes: 20
max_attempts: 3
command: npx gulp e2e-test
- name: 'BrowserStackLocal Stop'
uses: 'browserstack/github-actions/setup-local@master'
with:
local-testing: stop
coveralls:
name: Update coveralls
needs: [checkout, test]
runs-on: ubuntu-latest
steps:
- name: Restore working directory
uses: actions/cache/restore@v4
with:
path: .
key: ${{ needs.test.outputs.wdir }}
fail-on-cache-miss: true
- name: Coveralls
uses: coverallsapp/github-action@v2
with:
git-branch: ${{ needs.checkout.outputs.fork && format('{0}:{1}', needs.checkout.outputs.fork, needs.checkout.outputs.branch) || needs.checkout.outputs.branch }}
git-commit: ${{ needs.checkout.outputs.commit }}
compare-ref: ${{ needs.checkout.outputs.base-branch }}
compare-sha: ${{ needs.checkout.outputs.base-commit }}