13
13
14
14
jobs :
15
15
prevent-double-run :
16
+ # skip 'push' event when an open PR exists
16
17
name : Prevent double run
17
18
runs-on : ubuntu-latest
18
- # Run 'pull-request' event only on external PRs from forked repos.
19
- if : github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
19
+ outputs :
20
+ pr-id : ${{ steps.findPr.outputs.number }}
20
21
steps :
21
- - run : ' echo run Tests'
22
+ - name : Check event pull_request
23
+ if : github.event_name == 'pull_request'
24
+ run : ' echo pull_request: run workflow'
25
+ - uses : actions/checkout@v2
26
+ if : github.event_name == 'push'
27
+ - name : Check event push
28
+ id : findPr
29
+ if : github.event_name == 'push'
30
+ uses : jwalton/gh-find-current-pr@v1
31
+ with :
32
+ state : open
22
33
23
34
smoke :
24
35
name : ' Smoke [Node.js v${{ matrix.node }} / ${{ matrix.os }}]'
25
36
needs : prevent-double-run
37
+ if : needs.prevent-double-run.outputs.pr-id == ''
26
38
runs-on : ' ${{ matrix.os }}'
27
39
strategy :
28
40
matrix :
89
101
- uses : actions/checkout@v2
90
102
- name : Get npm cache directory in Windows
91
103
id : npm-cache
92
- if : " ${{ matrix.os == 'windows-2019' }}"
104
+ if : ${{ matrix.os == 'windows-2019' }}
93
105
run : |
94
106
echo "::set-output name=dir::$(npm config get cache)"
95
107
- name : ' Cache node_modules'
@@ -111,22 +123,21 @@ jobs:
111
123
# this is so mocha-github-actions-reporter can find mocha
112
124
NODE_PATH : lib
113
125
- name : Generate Coverage Report (Linux + Node.js latest)
114
- if : ' ${{ matrix.env.COVERAGE }}'
126
+ if : ${{ matrix.env.COVERAGE }}
115
127
run : npm start coverage-report-lcov
116
128
- name : Upload Coverage to Coveralls (Linux + Node.js latest)
117
- if : ' ${{ matrix.env.COVERAGE }}'
129
+ if : ${{ matrix.env.COVERAGE }}
118
130
uses : coverallsapp/github-action@master
119
131
with :
120
132
github-token : ' ${{ secrets.GITHUB_TOKEN }}'
121
133
122
134
test-browser :
123
- # TODO: configure to retain build artifacts in `.karma/` dir
124
135
name : ' Browser Tests'
125
136
needs : smoke
126
- timeout-minutes : 20
127
137
runs-on : ubuntu-latest
128
- # Run 'push' event only because of sauce labs token
129
- if : github.event_name == 'push'
138
+ timeout-minutes : 20
139
+ # Don't run forked 'pull_request' without saucelabs token
140
+ if : github.event_name == 'push' || !github.event.pull_request.head.repo.fork
130
141
steps :
131
142
- uses : actions/setup-node@v2
132
143
with :
@@ -146,5 +157,5 @@ jobs:
146
157
- name : Run Browser Tests
147
158
run : npm start test.browser
148
159
env :
149
- SAUCE_USERNAME : ' ${{secrets.SAUCE_USERNAME}} '
150
- SAUCE_ACCESS_KEY : ' ${{secrets.SAUCE_ACCESS_KEY}} '
160
+ SAUCE_USERNAME : ${{ secrets.SAUCE_USERNAME }}
161
+ SAUCE_ACCESS_KEY : ${{ secrets.SAUCE_ACCESS_KEY }}
0 commit comments