-
Notifications
You must be signed in to change notification settings - Fork 2
178 lines (165 loc) · 6.05 KB
/
run-tests.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
name: Run Tests
on:
workflow_call:
inputs:
run_integration:
required: false
type: boolean
default: true
repo:
type: string
required: true
flag_prefix:
type: string
default: ''
working_directory:
type: string
default: .
outputs:
tests_passed:
# Silly issue with returning job results as workflow outputs
# https://github.com/actions/runner/issues/2495
value: ${{ fromJSON(toJSON(jobs.test)).result }}
env:
AR_REPO: ${{ inputs.repo }}
jobs:
test:
name: Test
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ inputs.working_directory }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'
- name: Cache App
id: cache-app
uses: actions/cache@v4
env:
cache-name: ${{ inputs.repo }}-app
with:
path: |
${{ inputs.working_directory }}/app.tar
key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.run_id }}
- name: Load built image
run: |
docker load --input app.tar
- name: Install docker compose
run: |
sudo curl -SL https://github.com/docker/compose/releases/download/v2.20.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
- name: Bring test env up
run: |
make test_env.up
- name: Prepare for tests
run: |
make test_env.prepare
make test_env.check_db
- name: Run unit tests
run: |
make test_env.run_unit
- name: Run integration tests
if: ${{ !cancelled() && inputs.run_integration == true }}
run: |
make test_env.run_integration
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: ${{ inputs.flag_prefix }}-coveragefiles
path: ${{ inputs.working_directory }}/*.coverage.xml
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: ${{ inputs.flag_prefix }}-junitfiles
path: ${{ inputs.working_directory }}/*junit*.xml
upload:
name: Upload to Codecov
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ inputs.working_directory }}
needs: [test]
strategy:
matrix:
include:
- codecov_url_secret: CODECOV_URL
codecov_token_secret: CODECOV_ORG_TOKEN
name: prod
- codecov_url_secret: CODECOV_STAGING_URL
codecov_token_secret: CODECOV_ORG_TOKEN_STAGING
name: staging
- codecov_url_secret: CODECOV_QA_URL
codecov_token_secret: CODECOV_QA_ORG
name: qa
- codecov_url_secret: CODECOV_PUBLIC_QA_URL
codecov_token_secret: CODECOV_PUBLIC_QA_TOKEN
name: public qa
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'
- name: Download coverage
id: download_coverage
uses: actions/download-artifact@v4
with:
name: ${{ inputs.flag_prefix }}-coveragefiles
- name: Download test results
id: download_test_results
uses: actions/download-artifact@v4
with:
name: ${{ inputs.flag_prefix }}-junitfiles
- name: Uploading unit test coverage (${{ matrix.name }})
uses: codecov/codecov-action@v5
with:
files: ${{ steps.download_coverage.outputs.download-path }}/unit.coverage.xml
flags: ${{ format('{0}unit', inputs.flag_prefix) }}
disable_search: true
# Strange workaround: API has a `codecov` directory in the repo root
# which conflicts with the action's `codecov` binary
use_pypi: true
token: ${{ secrets[matrix.codecov_token_secret] }}
url: ${{ secrets[matrix.codecov_url_secret] }}
recurse_submodules: true
- name: Uploading integration test coverage (${{ matrix.name }})
if: ${{ inputs.run_integration == true }}
uses: codecov/codecov-action@v5
with:
files: ${{ steps.download_coverage.outputs.download-path }}/integration.coverage.xml
flags: ${{ format('{0}integration', inputs.flag_prefix) }}
disable_search: true
# Strange workaround: API has a `codecov` directory in the repo root
# which conflicts with the action's `codecov` binary
use_pypi: true
token: ${{ secrets[matrix.codecov_token_secret] }}
url: ${{ secrets[matrix.codecov_url_secret] }}
recurse_submodules: true
- name: Uploading unit test results (${{ matrix.name }})
uses: codecov/test-results-action@v1
with:
files: ${{ steps.download_test_results.outputs.download-path }}/unit.junit.xml
flags: ${{ format('{0}unit', inputs.flag_prefix) }}
disable_search: true
token: ${{ secrets[matrix.codecov_token_secret] }}
url: ${{ secrets[matrix.codecov_url_secret] }}
# The coverage action will have installed codecovcli with pip. The
# actual binary will be found in $PATH.
binary: codecovcli
working-directory: ${{ inputs.working_directory }}
- name: Uploading integration test results (${{ matrix.name }})
if: ${{ inputs.run_integration == true }}
uses: codecov/test-results-action@v1
with:
files: ${{ steps.download_test_results.outputs.download-path }}/integration.junit.xml
flags: ${{ format('{0}integration', inputs.flag_prefix) }}
disable_search: true
token: ${{ secrets[matrix.codecov_token_secret] }}
url: ${{ secrets[matrix.codecov_url_secret] }}
# The coverage action will have installed codecovcli with pip. The
# actual binary will be found in $PATH.
binary: codecovcli
working-directory: ${{ inputs.working_directory }}