-
Notifications
You must be signed in to change notification settings - Fork 46
210 lines (170 loc) · 6.19 KB
/
ci.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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
name: CI
on:
push:
branches:
- '**'
tags-ignore:
- '**'
jobs:
build_ilc:
name: Build ILC
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: benjlevesque/[email protected]
id: sha7
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Docker ILC auth
run: echo "${{ secrets.DOCKER_HUB_BROTHERS_TOKEN }}" | docker login --username brothers --password-stdin
- name: Build the Docker image
uses: docker/build-push-action@v2
with:
context: "{{defaultContext}}:ilc"
platforms: linux/amd64,linux/arm64
push: true
cache-from: |
type=registry,ref=namecheap/ilc_tmp:buildcache
cache-to: |
type=registry,ref=namecheap/ilc_tmp:buildcache,mode=max
tags: |
namecheap/ilc_tmp:${{ env.SHA }}
namecheap/ilc_tmp:latest
- name: Run server-side tests
run: docker run namecheap/ilc_tmp:$SHA npm run test:ci
- name: Run server-side tests coverage
run: docker run --volume /artifacts/ilc/.test_output/server:/temporary namecheap/ilc_tmp:$SHA bash -c "npm run test:coverage && mv .nyc_output/* /temporary"
- uses: actions/upload-artifact@v2
with:
name: server-side-tests-artifacts
path: /artifacts/ilc/.test_output/server/
- name: Code Coverage Report
uses: irongut/[email protected]
with:
filename: /artifacts/ilc/.test_output/server/**/cobertura-coverage.xml
badge: true
format: markdown
indicators: true
output: both
thresholds: '80 95'
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md
- name: Build the Docker image to test client-side
run: |
cd ./ilc/
DOCKER_BUILDKIT=1 docker build . --file ./Test.Dockerfile --tag ilc:tmp-test-client --build-arg BASE_IMAGE=namecheap/ilc_tmp:$SHA
- name: Run client-side tests
run: |
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
docker run --volume /artifacts/ilc/.test_output/client:/temporary ilc:tmp-test-client bash -c "npm run test:client -- --browsers ChromeHeadlessWithoutSecurity && mv .karma_output/* /temporary"
- uses: actions/upload-artifact@v2
with:
name: client-side-tests-artifacts
path: /artifacts/ilc/.test_output/client/
build_registry:
name: Build Registry
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: benjlevesque/[email protected]
id: sha7
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
buildkitd-flags: --debug
- name: Docker registry auth
run: echo "${{ secrets.DOCKER_HUB_BROTHERS_TOKEN }}" | docker login --username brothers --password-stdin
- name: Build the Docker image
uses: docker/build-push-action@v3
with:
context: "{{defaultContext}}:registry"
platforms: linux/amd64,linux/arm64
push: true
cache-from: |
type=registry,ref=namecheap/ilc_tmp:buildcache_registry
cache-to: |
type=registry,ref=namecheap/ilc_tmp:buildcache_registry,mode=max
tags: |
namecheap/ilc_tmp:reg_${{ env.SHA }}
namecheap/ilc_tmp:reg_latest
- name: Run tests
run: docker run namecheap/ilc_tmp:reg_$SHA npm run test:ci
e2e_tests:
name: Run E2E tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Use Node.js 16
uses: actions/setup-node@v1
with:
node-version: 16
- name: Install Chrome deps
run: sudo apt-get update && sudo apt-get install -y libgbm-dev
- name: Cache node modules
uses: actions/cache@v1
env:
cache-name: cache-node-modules
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.os }}-build
- name: Install dependencies
run: npm i
- name: Build ILC & Registry
run: npm run build
- name: Run E2E tests
run: cd e2e && npm run start
- uses: actions/upload-artifact@v2
if: failure()
with:
name: e2e-tests-artifacts
path: e2e/.codecept_output
push_images:
needs: [build_ilc, build_registry, e2e_tests]
name: Push images to registry
runs-on: ubuntu-latest
steps:
- name: Docker registry auth
run: echo "${{ secrets.DOCKER_HUB_BROTHERS_TOKEN }}" | docker login --username brothers --password-stdin
- name: Calculate tags
id: tags
run: |
BRANCH=$(echo ${GITHUB_REF} | cut -d '/' -f 3-99)
LATEST=$([ "$BRANCH" == "master" ] && echo "latest,${GITHUB_SHA:0:7}," || echo "")
DOCKER_TAGS="$LATEST${BRANCH//\//_}"
echo "Tags that will be used: $DOCKER_TAGS"
echo ::set-output name=docker_tags::$DOCKER_TAGS
- name: Install regctl
run: |
curl -L https://github.com/regclient/regclient/releases/download/v0.3.10/regctl-linux-amd64 > ./regctl
chmod 755 ./regctl
- name: Push images
run: |
TAGS="${{ steps.tags.outputs.docker_tags }}"
for i in ${TAGS//,/ }
do
./regctl image copy namecheap/ilc_tmp:reg_${GITHUB_SHA:0:7} namecheap/ilc_registry:$i
./regctl image copy namecheap/ilc_tmp:${GITHUB_SHA:0:7} namecheap/ilc:$i
done
build_docs:
needs: [push_images]
name: Build documentation
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v2
- name: Build the Docker image
run: |
docker build -t ilc-mkdocs - < ./.mkdocs/Dockerfile
- name: Generate docs and publish to GitHub Pages
run: docker run --rm -v ${PWD}:/docs ilc-mkdocs gh-deploy --force