-
Notifications
You must be signed in to change notification settings - Fork 71
185 lines (160 loc) · 6.02 KB
/
build.yml
File metadata and controls
185 lines (160 loc) · 6.02 KB
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
name: IEM CI
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
build:
defaults:
run:
# Ensures environment gets sourced right
shell: bash -l -e {0}
name: Python (${{ matrix.PYTHON_VERSION }}) Data (${{ matrix.WITH_TEST_DATA }}) Test Web (${{ matrix.TEST_WEB }})
runs-on: ubuntu-latest
strategy:
matrix:
PYTHON_VERSION: ["3.14"]
WITH_TEST_DATA: ["test_data", "no_test_data"]
TEST_WEB: ["YES", "NO"]
exclude:
# This combination is not all that useful
- PYTHON_VERSION: "3.14"
TEST_WEB: "NO"
WITH_TEST_DATA: "no_test_data"
env:
PYTHON_VERSION: ${{ matrix.PYTHON_VERSION }}
WITH_TEST_DATA: ${{ matrix.WITH_TEST_DATA }}
TEST_WEB: ${{ matrix.TEST_WEB }}
steps:
- uses: actions/checkout@v6
# Lots of daryl's codes use aliases defined in /etc/hosts
- name: Add /etc/hosts entries
run: |
cat .github/workflows/etchosts.txt | sudo tee -a /etc/hosts
# Required for all matrix jobs
- name: Create Docker Network
run: docker network create iem_network
# Required for all matrix jobs
- name: Run IEM Database Container label:${{ env.WITH_TEST_DATA }}
run: |
docker run -d --name iem_database --network iem_network -p 5432:5432 ghcr.io/akrherz/iem_database:${{ env.WITH_TEST_DATA }}
n=0
until docker exec iem_database pg_isready -h localhost; do
n=$((n+1))
if [ $n -ge 10 ]; then
echo "iem_database did not become ready in time"
docker logs iem_database
exit 1
fi
sleep 6
done
# Required for all matrix jobs
- name: Run IEM Web Services Container
run: |
docker run -d --name iem_web_services --network iem_network -p 8080:8000 -e IEMWS_DBHOST=iem_database -e IEMWS_DBUSER=mesonet ghcr.io/akrherz/iem-web-services:latest
n=0
# Test something that does a db query
until curl -sf http://localhost:8080/networks.geojson; do
n=$((n+1))
if [ $n -ge 10 ]; then
echo "iem-web-services did not become ready in time"
docker logs iem_web_services
exit 1
fi
sleep 1
done
# Required for all matrix jobs
- name: Run Memcached container
run: |
docker run -d --name iem_memcached -p 11211:11211 memcached:1.6.9
- uses: akrherz/ci_tooling/actions/iemwebfarm@main
with:
environment-file: environment.yml
python-version: ${{ matrix.PYTHON_VERSION }}
environment-name: prod
# Copy repo's default settings into the real position
- name: Copy PHP Setting Defaults
run: |
cp config/settings.inc.php.in config/settings.inc.php
# All jobs need to have directories laid out
- name: Setup Directory Paths
run: sh .github/setuppaths.sh
# Only one job needs to load the test data
- name: Setup IEM Data
if: ${{ matrix.WITH_TEST_DATA == 'test_data' }}
run: sh .github/setupdata.sh
- name: IEM TileCache Backend
if: ${{ matrix.TEST_WEB == 'YES' }}
run: |
nohup bash deployment/start_tc_wsgi.sh > /tmp/iem-tilecache.log 2>&1 &
echo $! > /tmp/iem-tilecache.pid
n=0
until curl -sS -o /dev/null http://127.0.0.1:9081/; do
n=$((n+1))
if [ $n -ge 30 ]; then
echo "iem-tilecache did not become ready in time"
cat /tmp/iem-tilecache.log
exit 1
fi
sleep 1
done
- name: Configure Webfarm Server
if: ${{ matrix.TEST_WEB == 'YES' }}
run: |
echo '<VirtualHost *:80>' | sudo tee /etc/apache2/sites-enabled/iem.conf > /dev/null
cat config/mesonet.inc | sudo tee -a /etc/apache2/sites-enabled/iem.conf > /dev/null
echo '</VirtualHost>' | sudo tee -a /etc/apache2/sites-enabled/iem.conf > /dev/null
# ci_tooling places a mod_wsgi conf with startup disabled, we enable it
sudo sed -i 's/# WSGIImportScript/WSGIImportScript/' /etc/apache2/sites-enabled/mod_wsgi.conf
# restart apache
sudo service apache2 restart
sudo systemctl status apache2.service -l
- name: Run IEM Production checks
if: ${{ matrix.TEST_WEB == 'YES' }}
run: |
git clone --depth 1 https://github.com/akrherz/iem-production-checks.git .ipc
SERVICE=http://iem.local pytest -n 4 .ipc/tests/test_*.py
- name: Run mod_wsgi smoke test
if: ${{ matrix.TEST_WEB == 'YES' }}
run: pytest -n 4 tests/test_mod_wsgi.py
- name: Test PHP webscripts
if: ${{ matrix.TEST_WEB == 'YES' }}
run: pytest -n 4 tests/test_php.py
# - name: Setup upterm session
# if: ${{ matrix.TEST_WEB == 'NO' && matrix.WITH_TEST_DATA == 'test_data' }}
# uses: owenthereal/action-upterm@v1
# with:
# limit-access-to-actor: true
- name: Run IEMWeb Python Check
if: ${{ matrix.TEST_WEB == 'NO' && matrix.WITH_TEST_DATA == 'test_data' }}
run: |
export PYTHONPATH=/opt/iem/pylib
python -m pytest --mpl --cov=iemweb --durations=10 -n 4 -W error::FutureWarning tests/iemweb/
python -m coverage xml
- name: Upload to Codecov
if: ${{ matrix.TEST_WEB == 'NO' && matrix.WITH_TEST_DATA == 'test_data' }}
uses: codecov/codecov-action@v5
with:
files: coverage.xml
fail_ci_if_error: true
- name: View Apache Logs
if: ${{ failure() && matrix.TEST_WEB == 'YES' }}
run: |
sudo systemctl status apache2 -l
sudo cat /var/log/apache2/error.log
- name: View TileCache Logs
if: ${{ failure() && matrix.TEST_WEB == 'YES' }}
run: |
if [ -f /tmp/iem-tilecache.pid ]; then
ps -fp "$(cat /tmp/iem-tilecache.pid)" || true
fi
if [ -f /tmp/iem-tilecache.log ]; then
cat /tmp/iem-tilecache.log
fi
- name: View PHP-FPM Logs
if: ${{ failure() && matrix.TEST_WEB == 'YES' }}
run: |
sudo cat /var/log/php*-fpm.log