-
Notifications
You must be signed in to change notification settings - Fork 0
207 lines (169 loc) · 6.65 KB
/
main.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
name: CI
on:
# push: -- just run on PRs for now
pull_request:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgis/postgis:13-3.0
env:
POSTGRES_PASSWORD: postgis
POSTGRES_DB: ${{ github.event.repository.name }}
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
strategy:
fail-fast: false
matrix:
# python-version: ["3.10", "3.11", "3.12"]
python-version: ["3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
check-latest: true
- name: Install Java, GDAL, and other system dependencies
run: |
sudo apt update
sudo apt-get install libxml2-dev libpq-dev openjdk-8-jdk libgdal-dev libxslt-dev
echo Postgres and ES dependencies installed
- name: Install python packages
run: |
python -m pip install --upgrade pip
pip install .
pip install -r ${{ github.event.repository.name }}/install/requirements.txt
pip install -r ${{ github.event.repository.name }}/install/requirements_dev.txt
echo Python packages installed
- uses: ankane/setup-elasticsearch@v1
with:
elasticsearch-version: 8
- name: Webpack frontend files
run: |
echo "Removing yarn.lock due to yarn v1 package resolution issues"
echo "https://github.com/iarna/wide-align/issues/63"
rm yarn.lock
yarn && yarn build_test
- name: Check for missing migrations
run: |
python manage.py makemigrations --check
- name: Ensure previous coverage data is erased
run: |
coverage erase
- name: Run unit tests
run: |
python -W default::DeprecationWarning -m coverage run manage.py test tests --settings="tests.test_settings"
- name: Generate report coverage
run: |
coverage json
cat coverage.json
- name: Upload coverage report as artifact
uses: actions/upload-artifact@v4
with:
name: current-coverage-report
path: coverage.json
overwrite: true
check_target_branch_coverage:
runs-on: ubuntu-latest
services:
postgres:
image: postgis/postgis:13-3.0
env:
POSTGRES_PASSWORD: postgis
POSTGRES_DB: ${{ github.event.repository.name }}
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
strategy:
fail-fast: false
matrix:
# python-version: ["3.10", "3.11", "3.12"]
python-version: ["3.12"]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.ref }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
check-latest: true
- name: Install Java, GDAL, and other system dependencies
run: |
sudo apt update
sudo apt-get install libxml2-dev libpq-dev openjdk-8-jdk libgdal-dev libxslt-dev
echo Postgres and ES dependencies installed
- name: Install python packages
run: |
python -m pip install --upgrade pip
pip install .
pip install -r ${{ github.event.repository.name }}/install/requirements.txt
pip install -r ${{ github.event.repository.name }}/install/requirements_dev.txt
echo Python packages installed
- uses: ankane/setup-elasticsearch@v1
with:
elasticsearch-version: 8
- name: Ensure previous coverage data is erased
run: |
coverage erase
- name: Run unit tests
run: |
python -W default::DeprecationWarning -m coverage run manage.py test tests --settings="tests.test_settings"
- name: Generate report coverage
run: |
coverage json
cat coverage.json
- name: Upload coverage report as artifact
uses: actions/upload-artifact@v4
with:
name: target-coverage-report
path: coverage.json
overwrite: true
# check-coverage:
# runs-on: ubuntu-latest
# needs: [build]
# steps:
# - uses: actions/checkout@v4
# - name: Set up Python
# uses: actions/setup-python@v5
# with:
# python-version: '3.x' # Use the latest available version
# check-latest: true
# - name: Download coverage report artifact
# uses: actions/download-artifact@v4
# with:
# name: coverage-report
# path: .
# - name: Report coverage
# run: |
# cat coverage.json
# - name: Retrieve baseline coverage
# run: |
# git fetch origin ${{ github.event.pull_request.base.ref }}:${{ github.event.pull_request.base.ref }}
# if ! git show ${{ github.event.pull_request.base.ref }}:coverage.json > /dev/null; then
# echo "Error: coverage.json does not exist in the branch."
# exit 1
# fi
# baseline_coverage=$(git show ${{ github.event.pull_request.base.ref }}:coverage.json | grep -o '"totals": {[^}]*' | grep -o '"percent_covered": [0-9.]*' | awk -F ': ' '{print $2}')
# echo "$baseline_coverage" > .coverage_baseline
# - name: Compare coverage with baseline
# if: github.event_name == 'pull_request'
# run: |
# current_coverage=$(cat coverage.json | grep -o '"totals": {[^}]*' | grep -o '"percent_covered": [0-9.]*' | awk -F ': ' '{print $2}')
# baseline_coverage=$(cat .coverage_baseline)
# # Compare current coverage with baseline coverage using floating-point comparison
# if awk -v current="$current_coverage" -v baseline="$baseline_coverage" 'BEGIN { exit (current < baseline) ? 0 : 1 }'; then
# echo "Coverage decreased from $baseline_coverage% to $current_coverage%"
# exit 1
# else
# echo "Current branch coverage ($current_coverage%) >= Target branch coverage ($baseline_coverage%). Committing new coverage.json."
# git config user.name github-actions
# git config user.email [email protected]
# git add -f coverage.json
# git commit -m "automatically update coverage.json"
# git push -f origin HEAD:${{ github.head_ref }}
# fi