-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (107 loc) · 3.41 KB
/
build-and-test.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
name: Build and Test
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
- name: Install Dependencies
run: npm ci
- name: Set Build Version
uses: ./.github/actions/set-package-version
id: version
- name: Build
env:
NODE_ENV: production
run: npm run build
- name: Clean Dev Dependencies
run: |2
rm -rf node_modules/
npm ci --production
mkdir -p node_modules/
mkdir -p dist/
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: package
path: |2
package.json
dist/
check:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
- name: Download package
uses: actions/download-artifact@v2
with:
name: package
- name: Install dev dependencies
run: npm ci
- name: Check Code
run: npm run check
test:
runs-on: ubuntu-latest
needs: build
steps:
- name: Add status
id: add-status
uses: LouisBrunner/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Unit Tests
status: in_progress
output: |2
{
"summary": "Unit tests are currently being run"
}
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
- name: Download package
uses: actions/download-artifact@v2
with:
name: package
- name: Install dev dependencies
run: npm ci
- name: Run tests
run: npm run test
- name: Summarize tests
uses: sergeysova/jq-action@v2
id: summary
with:
cmd: |2
cat reports/unit-tests/data.json | jq --raw-output '
"Test suites: "
+ "<span style=\"color:green\">" + (.numPassedTestSuites|tostring) + " passed</span> | "
+ "<span style=\"color:red\">" + ((.numFailedTestSuites + .numRuntimeErrorTestSuites)|tostring) + " failed</span> | "
+ "<span style=\"color:yellow\">" + (.numPendingTestSuites|tostring) + " incomplete</span>\n"
+ "\n"
+ "Tests: "
+ "<span style=\"color:green\">" + (.numPassedTests|tostring) + " passed</span> | "
+ "<span style=\"color:red\">" + (.numFailedTests|tostring) + " failed</span> | "
+ "<span style=\"color:yellow\">" + ((.numPendingTests + .numTodoTests)|tostring) + " incomplete</span>\n"
' | sed -e 's/"/\\"/g'
- name: Successful status
uses: LouisBrunner/[email protected]
if: ${{ success() }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
check_id: ${{ steps.add-status.outputs.check_id }}
status: completed
conclusion: success
output: |2
{
"summary": "Unit tests completed successfully",
"text_description": "${{ steps.summary.outputs.value }}"
}