This repository has been archived by the owner on Apr 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
170 lines (166 loc) · 4.86 KB
/
ci-cd.yaml
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
---
name: CI & CD
on:
push:
branches:
- main
paths-ignore:
- '**.md'
- 'docs/swagger.json'
pull_request:
paths-ignore:
- '**.md'
- 'docs/swagger.json'
concurrency:
group: ci-${{ github.head_ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
env:
GRAILS_WAR_ENV: 'test'
GRAILS_VERSION: '2.5.6'
jobs:
test:
name: Build, lint and test
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '8.0.282'
distribution: 'zulu'
- uses: sdkman/sdkman-action@master
id: sdkman-grails
with:
candidate: grails
version: ${{ env.GRAILS_VERSION }}
- name: Install Grails
run: |
unzip ${{ steps.sdkman-grails.outputs.file }} -d "$HOME"
echo "$HOME/grails-$GRAILS_VERSION/bin" >> $GITHUB_PATH
- name: Build
run: |
make -f Makefile.ci compile
- name: Unit Test
run: |
make -f Makefile.ci test-unit
- name: Start Streamr Docker Stack
uses: streamr-dev/[email protected]
with:
services-to-start: "mysql redis"
- name: Integration test
run: |
make -f Makefile.ci test-integration
- name: Stop Streamr Docker Stack
if: always()
run: |
docker kill $(docker ps -q)
docker rm $(docker ps -a -q)
e2e:
name: End to end test
runs-on: ubuntu-20.04
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/[email protected]
with:
driver-opts: |
network=host
- name: Cache Docker layers
uses: actions/[email protected]
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-v1-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-v1-
- name: Build
uses: docker/[email protected]
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: false
load: true
tags: streamr/core-api:dev
build-args: |
GRAILS_WAR_ENV=${{ env.GRAILS_WAR_ENV }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Start Streamr Docker Stack
uses: streamr-dev/[email protected]
with:
services-to-start: "mysql redis cassandra parity-node0 parity-sidechain-node0 bridge broker-node-no-storage-1 broker-node-storage-1 nginx smtp"
- name: Install Node
uses: actions/setup-node@v3
with:
node-version-file: 'rest-e2e-tests/.nvmrc'
- name: Setup End to End tests
run: |
streamr-docker-dev start core-api
streamr-docker-dev wait
cd rest-e2e-tests
npm ci
- name: Run End to End tests
run: |
cd rest-e2e-tests
npm run test:e2e
- name: Stop Streamr Docker Stack
if: always()
run: |
docker kill $(docker ps -q)
docker rm $(docker ps -a -q)
build-docker:
name: Build Docker and push to Docker Hub
needs:
- test
- e2e
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Docker meta
id: docker_meta
uses: docker/[email protected]
with:
images: streamr/core-api
tags: |
type=sha
type=ref,event=pr
type=semver,pattern=v{{version}}
type=raw,value=dev
flavor: |
latest=auto
- name: Set up Docker Buildx
uses: docker/[email protected]
with:
driver-opts: |
network=host
- name: Cache Docker layers
uses: actions/[email protected]
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-v1-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-v1-
- name: Login to DockerHub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/[email protected]
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: true
load: false
build-args: |
GRAILS_WAR_ENV=${{ env.GRAILS_WAR_ENV }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}