Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit 69e4764

Browse files
authored
Use different matrices for PR and push. (#490)
Run small matrix for PR and full matrix for push to reduce the resources used by CI.
1 parent 7b2527e commit 69e4764

File tree

4 files changed

+63
-23
lines changed

4 files changed

+63
-23
lines changed

.github/workflows/ci.yaml

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,35 @@ jobs:
66
lint:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v2
10-
- uses: actions/setup-node@v2
11-
with:
12-
node-version: '14'
13-
- run: npm install
14-
- run: grunt check
15-
working-directory: ./scripts
9+
- uses: actions/checkout@v2
10+
- uses: actions/setup-node@v2
11+
with:
12+
node-version: "14"
13+
- run: npm install
14+
- run: grunt check
15+
working-directory: ./scripts
16+
build-matrix:
17+
name: Build matrix for unit test
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v2
21+
- id: read-matrix
22+
name: Read build matrix
23+
run: echo "::set-output name=matrix::`jq -c . test/unit/config/run_matrix.json`"
24+
outputs:
25+
matrix: ${{ steps.read-matrix.outputs.matrix }}
1626
unit-test:
27+
needs: build-matrix
1728
runs-on: ${{ matrix.os }}
1829
strategy:
19-
matrix:
20-
os: [ubuntu-latest, windows-latest, macos-latest]
21-
browser: [ChromeWithFlags, FirefoxWithFlags]
22-
include:
23-
- os: windows-latest
24-
browser: EdgeWithFlags
30+
matrix: ${{ fromJSON(needs.build-matrix.outputs.matrix)[github.event_name] }}
2531
steps:
26-
- uses: actions/checkout@v2
27-
- uses: actions/setup-node@v2
28-
with:
29-
node-version: '14'
30-
- run: npm install
31-
- name: Run test cases
32-
env:
33-
BROWSER: ${{matrix.browser}}
34-
run: npm run unittest
32+
- uses: actions/checkout@v2
33+
- uses: actions/setup-node@v2
34+
with:
35+
node-version: "14"
36+
- run: npm install
37+
- name: Run test cases
38+
env:
39+
BROWSER: ${{ matrix.browser }}
40+
run: npm run unittest

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@
5757
},
5858
"scripts": {
5959
"postinstall": "cd scripts && grunt prepare",
60-
"unittest": "node ./node_modules/karma/bin/karma start test/unit/karma/ci.config.js"
60+
"unittest": "node ./node_modules/karma/bin/karma start test/unit/config/karma.config.js"
6161
}
6262
}
File renamed without changes.

test/unit/config/run_matrix.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"push": {
3+
"os": [
4+
"ubuntu-latest",
5+
"windows-latest",
6+
"macos-latest"
7+
],
8+
"browser": [
9+
"ChromeWithFlags",
10+
"FirefoxWithFlags"
11+
],
12+
"include": [
13+
{
14+
"os": "windows-latest",
15+
"browser": "EdgeWithFlags"
16+
}
17+
]
18+
},
19+
"pull_request": {
20+
"os": [
21+
"ubuntu-latest"
22+
],
23+
"browser": [
24+
"ChromeWithFlags",
25+
"FirefoxWithFlags"
26+
],
27+
"include": [
28+
{
29+
"os": "windows-latest",
30+
"browser": "EdgeWithFlags"
31+
}
32+
]
33+
}
34+
}

0 commit comments

Comments
 (0)