-
Notifications
You must be signed in to change notification settings - Fork 1
200 lines (172 loc) · 5.72 KB
/
pr-build.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
name: pr-build
on:
pull_request:
types: ['opened', 'reopened', 'synchronize']
branches:
- 'main'
jobs:
detect-change-scope:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
backend-etl: ${{ steps.filter.outputs.backend-etl }}
backend-api: ${{ steps.filter.outputs.backend-api }}
backend-shared: ${{ steps.filter.outputs.backend-shared }}
ui: ${{ steps.filter.outputs.ui }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: dorny/paths-filter@v3.0.2
id: filter
with:
filters: |
backend-etl:
- 'air-quality-backend/etl/**'
backend-api:
- 'air-quality-backend/api/**'
backend-shared:
- 'air-quality-backend/shared/**'
ui:
- 'air-quality-ui/**'
pr-checks-backend-etl:
needs: detect-change-scope
if: ${{ needs.detect-change-scope.outputs.backend-etl == 'true' }}
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
sparse-checkout: 'air-quality-backend'
sparse-checkout-cone-mode: false
- name: Setup miniconda
uses: conda-incubator/setup-miniconda@v3
with:
channels: conda-forge
environment-file: air-quality-backend/etl/conda/environment.yml
auto-activate-base: false
activate-environment: pr-env
- name: Get Dependencies
run: poetry install
working-directory: ./air-quality-backend/etl
- name: Run lint check
run: python -m flake8 --append-config .flake8
working-directory: ./air-quality-backend/etl
- name: Run unit tests
run: python -m pytest --cov=etl --cov-report= etl/tests
working-directory: ./air-quality-backend/
- name: Convert to report
run: coverage xml
working-directory: ./air-quality-backend/
- name: Code Coverage Report
uses: orgoro/coverage@v3.1
with:
coverageFile: ./air-quality-backend/coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
thresholdAll: 0.8
thresholdModified: 0
pr-checks-backend-api:
needs: detect-change-scope
if: ${{ needs.detect-change-scope.outputs.backend-api == 'true' }}
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
sparse-checkout: 'air-quality-backend'
sparse-checkout-cone-mode: false
- name: Setup Python
uses: actions/setup-python@v5.1.0
with:
python-version: '3.11'
cache: 'pip'
- name: Get Dependencies
run: pip install -r requirements-dev.txt
working-directory: ./air-quality-backend/api
- name: Run lint check
run: python -m flake8 --append-config .flake8
working-directory: ./air-quality-backend/api
- name: Run unit tests
run: python -m pytest --cov=api/src --cov-report= api/tests
working-directory: ./air-quality-backend/
- name: Convert to report
run: coverage xml
working-directory: ./air-quality-backend/
- name: Code Coverage Report
uses: orgoro/coverage@v3.1
with:
coverageFile: ./air-quality-backend/coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
thresholdAll: 0.8
thresholdModified: 0.9
thresholdNew: 1
pr-checks-backend-shared:
needs: detect-change-scope
if: ${{ needs.detect-change-scope.outputs.backend-shared == 'true' }}
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
sparse-checkout: 'air-quality-backend'
sparse-checkout-cone-mode: false
- name: Setup Python
uses: actions/setup-python@v5.1.0
with:
python-version: '3.11'
cache: 'pip'
- name: Get Dependencies
run: pip install -r requirements-test.txt
working-directory: ./air-quality-backend/shared
- name: Run lint check
run: python -m flake8 --append-config .flake8
working-directory: ./air-quality-backend/shared
- name: Run unit tests
run: python -m pytest --cov=shared/src --cov-report= shared/tests
working-directory: ./air-quality-backend/
- name: Convert to report
run: coverage xml
working-directory: ./air-quality-backend/
- name: Code Coverage Report
uses: orgoro/coverage@v3.1
with:
coverageFile: ./air-quality-backend/coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
thresholdAll: 0.8
thresholdModified: 0.9
thresholdNew: 1
pr-checks-ui:
runs-on: ubuntu-latest
needs: detect-change-scope
if: ${{ needs.detect-change-scope.outputs.ui == 'true' }}
defaults:
run:
shell: bash -el {0}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
sparse-checkout: 'air-quality-ui'
sparse-checkout-cone-mode: false
- name: Install
run: npm ci
working-directory: 'air-quality-ui'
- name: Run lint check
run: npm run lint
working-directory: 'air-quality-ui'
- name: Run tests with coverage
uses: ArtiomTr/jest-coverage-report-action@v2.0-rc.6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
working-directory: 'air-quality-ui'
threshold: 90
test-script: npm run test:ci