-
Notifications
You must be signed in to change notification settings - Fork 0
219 lines (187 loc) · 6.69 KB
/
ci-cd.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
211
212
213
214
215
216
217
218
219
name: CI/CD
on:
push:
tags: [v*]
branches:
- main
pull_request:
# By default, a workflow only runs when a pull_request event's activity type is opened,
# synchronize, or reopened.
types: [opened, synchronize, reopened, edited]
branches:
- main
permissions: read-all
jobs:
check-auto-tagging-will-work:
if: |
github.event_name == 'pull_request' &&
(! startsWith(github.ref, 'refs/tags') && ! startsWith(github.ref, 'refs/heads/main'))
uses: climatepolicyradar/reusable-workflows/.github/workflows/check-auto-tagging-will-work.yml@v10
code-quality:
if: |
! cancelled() && always() &&
(needs.check-auto-tagging-will-work.result == 'skipped' || needs.check-auto-tagging-will-work.result == 'success') &&
! startsWith(github.ref, 'refs/tags')
needs:
- check-auto-tagging-will-work
permissions:
# For trunk to post annotations
checks: write
# For repo checkout
contents: read
uses: climatepolicyradar/reusable-workflows/.github/workflows/python-precommit-validator.yml@v13
with:
# These ignores are different, since for some reason, the
# specific one isn't working on this field.
# trunk-ignore-all: Sometimes the Python version is split at .'s in Actions
python-version: "3.10"
# trunk-ignore(yamllint/quoted-strings): Sometimes the Python version is split at .'s in Actions
poetry-version: "1.8.2"
non-search-tests:
if: |
! cancelled() && always() &&
(needs.check-auto-tagging-will-work.result == 'skipped' || needs.check-auto-tagging-will-work.result == 'success') &&
! startsWith(github.ref, 'refs/tags')
needs:
- check-auto-tagging-will-work
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use .env.example
run: cp .env.example .env
- name: Get python Container
run: docker pull python:3.10
- name: Build
run: |
docker compose build
docker images
- name: Build docker-compose stack
run: make start_without_vespa_setup
- name: Wait for backend to open port
run: ./wait_for_port.sh localhost 8888 60
- name: Run backend tests
run: make test_non_search
- name: Docker debug
run: |
docker compose logs
docker compose ps
docker ps -a
ls -la
- name: Log Dump
if: always() && ! cancelled()
run: docker compose logs
search-tests:
if: |
! cancelled() && always() &&
(needs.check-auto-tagging-will-work.result == 'skipped' || needs.check-auto-tagging-will-work.result == 'success') &&
! startsWith(github.ref, 'refs/tags')
needs:
- check-auto-tagging-will-work
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use .env.example
run: cp .env.example .env
- name: Get python Container
run: docker pull python:3.10
- name: Install latest Vespa CLI
env:
VESPA_CLI_VERSION: 8.250.43
run: |
mkdir -p scripts/vespa-cli
curl -fsSL https://github.com/vespa-engine/vespa/releases/download/v${VESPA_CLI_VERSION}/vespa-cli_${VESPA_CLI_VERSION}_linux_amd64.tar.gz | \
tar -zxf - -C scripts/vespa-cli --strip-component=1
echo "scripts/vespa-cli/bin" >> $GITHUB_PATH
- name: Build
run: |
docker compose build
docker images
- name: Build docker-compose stack & Setup vespa for search
run: make start
- name: Run backend search tests for vespa
run: make test_search
- name: Log Dump
if: always() && ! cancelled()
run: docker compose logs
integration-tests:
if: |
! cancelled() && always() &&
(needs.check-auto-tagging-will-work.result == 'skipped' || needs.check-auto-tagging-will-work.result == 'success') &&
! startsWith(github.ref, 'refs/tags')
needs:
- check-auto-tagging-will-work
runs-on: ubuntu-latest
steps:
- name: Run Integration Tests
run: echo TODO-TODO-TODO-TODO-TODO-TODO-TODO-TODO-TODO-TODO-TODO-TODO
build:
if: |
! cancelled() && always() &&
(needs.code-quality.result == 'success' &&
needs.non-search-tests.result == 'success' &&
needs.search-tests.result == 'success' &&
needs.integration-tests.result == 'success') &&
! startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
needs:
- code-quality
- non-search-tests
- search-tests
- integration-tests
steps:
- uses: actions/checkout@v4
- name: Use .env.example
run: cp .env.example .env
- name: Get python Container
run: docker pull python:3.10
- name: Build
run: |
docker compose build
docker images
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/[email protected]
- name: Publish initial image based on branch to ECR
id: retag_and_push_to_ecr
uses: climatepolicyradar/retag-and-push-to-ecr@v1
env:
DOCKER_REGISTRY: ${{ secrets.DOCKER_REGISTRY }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
with:
repo-name: navigator-backend
semver-tag: latest
manual-semver:
if: ${{ ! cancelled() && always() && startsWith(github.ref, 'refs/tags') }}
uses: climatepolicyradar/reusable-workflows/.github/workflows/semver.yml@v3
secrets: inherit
with:
repo-name: navigator-backend
semver-tag: main-${GITHUB_SHA::8}
tag:
if: ${{ ! cancelled() && always() && (needs.build.result == 'success')}}
needs: build
permissions:
contents: write
uses: climatepolicyradar/reusable-workflows/.github/workflows/tag.yml@v3
with:
repo-name: navigator-backend
semver-tag: main-${GITHUB_SHA::8}
secrets:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
DOCKER_REGISTRY: ${{ secrets.DOCKER_REGISTRY }}
release:
if: ${{ ! cancelled() && always() && (needs.tag.result == 'success' && needs.tag.outputs.new_tag != 'Skip')}}
needs: tag
permissions:
contents: write
uses: climatepolicyradar/reusable-workflows/.github/workflows/release.yml@v3
with:
new_tag: ${{ needs.tag.outputs.new_tag }}