forked from safe-global/safe-client-gateway
-
Notifications
You must be signed in to change notification settings - Fork 1
184 lines (175 loc) · 5.95 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
name: CI
on:
push:
pull_request:
release:
types: [released]
env:
DOCKER_IMAGE_REGISTRY: safeglobal
DOCKER_IMAGE_NAME: safe-client-gateway-nest
DOCKER_BUILD_IMAGE_TAG: buildcache
jobs:
prettier:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 'lts/iron'
cache: 'yarn'
- run: yarn install --immutable
- run: yarn run format-check
es-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 'lts/iron'
cache: 'yarn'
- run: yarn install --immutable
- run: yarn run lint-check
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
task: ['test:cov', 'test:e2e:cov']
env:
POSTGRES_TEST_DB: test-db
POSTGRES_TEST_USER: postgres
POSTGRES_TEST_PASSWORD: postgres
POSTGRES_TEST_PORT: 5433
services:
redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
postgres:
image: postgres:14.8
env:
# Should match the env above. "Variables in the env map cannot be defined in terms of other variables in the map."
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#env
POSTGRES_DB: test-db
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5433:5432
rabbitmq:
image: rabbitmq:alpine
ports:
- 5672:5672
options: >-
--health-cmd "rabbitmqctl await_startup"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 'lts/iron'
cache: 'yarn'
- run: yarn install --immutable
- run: yarn run build
- run: yarn run ${{matrix.task}}
env:
REDIS_HOST: localhost
REDIS_PORT: 6379
SAFE_CONFIG_BASE_URI: ${{ secrets.SAFE_CONFIG_BASE_URI }}
LOG_SILENT: true
- name: Coveralls Parallel
continue-on-error: true
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: run-${{ matrix.task }}
parallel: true
tests-finish:
needs: tests
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
docker-publish-staging:
if: (github.event_name == 'push' && github.ref == 'refs/heads/main')
needs: [prettier, es-lint, tests-finish]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
BUILD_NUMBER=${{ github.sha }}
echo "BUILD_NUMBER=${BUILD_NUMBER::7}" >> "$GITHUB_ENV"
- uses: docker/[email protected]
with:
platforms: arm64
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
push: true
build-args: |
BUILD_NUMBER=${{ env.BUILD_NUMBER }}
VERSION=${{ github.ref_name }}
tags: ${{ env.DOCKER_IMAGE_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:staging
# Use Registry cache backend https://docs.docker.com/build/cache/backends/registry/
cache-from: type=registry,ref=${{ env.DOCKER_IMAGE_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${{ env.DOCKER_BUILD_IMAGE_TAG }}
cache-to: type=registry,ref=${{ env.DOCKER_IMAGE_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${{ env.DOCKER_BUILD_IMAGE_TAG }},mode=max
docker-publish-release:
if: (github.event_name == 'release' && github.event.action == 'released')
needs: [prettier, es-lint, tests-finish]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
BUILD_NUMBER=${{ github.sha }}
echo "BUILD_NUMBER=${BUILD_NUMBER::7}" >> "$GITHUB_ENV"
- uses: docker/[email protected]
with:
platforms: arm64
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
push: true
build-args: |
BUILD_NUMBER=${{ env.BUILD_NUMBER }}
VERSION=${{ github.ref_name }}
tags: |
${{ env.DOCKER_IMAGE_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${{ github.ref_name }}
${{ env.DOCKER_IMAGE_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:latest
# Use Registry cache backend https://docs.docker.com/build/cache/backends/registry/
cache-from: type=registry,ref=${{ env.DOCKER_IMAGE_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${{ env.DOCKER_BUILD_IMAGE_TAG }}
cache-to: type=registry,ref=${{ env.DOCKER_IMAGE_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${{ env.DOCKER_BUILD_IMAGE_TAG }},mode=max
autodeploy:
runs-on: ubuntu-latest
needs: [docker-publish-staging]
steps:
- uses: actions/checkout@v4
- name: Deploy Staging
run: bash scripts/autodeploy.sh
env:
AUTODEPLOY_URL: ${{ secrets.AUTODEPLOY_URL }}
AUTODEPLOY_TOKEN: ${{ secrets.AUTODEPLOY_TOKEN }}
TARGET_ENV: 'staging'