-
Notifications
You must be signed in to change notification settings - Fork 12
169 lines (149 loc) · 4.44 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
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
name: build-and-test
on:
pull_request:
push:
branches:
- main
jobs:
npm-install-if-needed:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Node 18
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
- id: cache
name: Cache node modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json') }}
- name: NPM Install
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
build:
runs-on: ubuntu-22.04
needs: [ npm-install-if-needed ]
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Node 18
uses: actions/setup-node@v4
with:
node-version: 18
- name: Restore node modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json') }}
- name: Build
run: npm run build:ci
- name: Archive build artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: dist
lint:
runs-on: ubuntu-22.04
needs: [ npm-install-if-needed ]
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Node 18
uses: actions/setup-node@v4
with:
node-version: 18
- name: Restore node modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json') }}
- name: Lint
run: npm run lint
- name: Prettier Check
run: npm run prettier:check
test:
name: test (chunk ${{ matrix.chunk }})
runs-on: ubuntu-22.04
needs: [ npm-install-if-needed ]
strategy:
fail-fast: false
matrix:
chunk: [1, 2, 3, 4]
steps:
- name: Check out code
uses: actions/checkout@v4
# Used by CCI uploader to detect base commit
with:
fetch-depth: 0
- name: Restore node modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json') }}
- name: Test
run: npm run test:ci -- --shard=${{ matrix.chunk }}/${{ strategy.job-total }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
- name: Upload Unit Test Results
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: Unit Test Results (chunk ${{ matrix.chunk }})
path: test-results/**/*.xml
validate-helm-charts:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v4
- name: validate charts
uses: hypertrace/github-actions/validate-charts@main
publish-test-results:
name: "Publish Unit Tests Results"
needs: test
runs-on: ubuntu-22.04
# Only run if prereq jobs completed - successfully or not
if: success() || failure()
steps:
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
continue-on-error: true
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
files: artifacts/**/*.xml
merge-publish:
if: github.event_name == 'push'
runs-on: ubuntu-22.04
needs: [ npm-install-if-needed, build, lint, test, validate-helm-charts ]
steps:
- name: Check out code
uses: actions/checkout@v4
# Used by gradle version calculation
with:
fetch-depth: 0
- name: Download build results
uses: actions/download-artifact@v3
with:
name: dist
path: dist
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_READ_USER }}
password: ${{ secrets.DOCKERHUB_READ_TOKEN }}
- name: Push docker image
uses: hypertrace/github-actions/gradle@main
with:
args: dockerPushImages
env:
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_PUBLISH_USER }}
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_PUBLISH_TOKEN }}