-
Notifications
You must be signed in to change notification settings - Fork 63
149 lines (127 loc) · 4.63 KB
/
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
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_IEM_DATA }}) Test Web (${{ matrix.TEST_WEB }})
runs-on: ubuntu-latest
strategy:
matrix:
PYTHON_VERSION: ["3.11"]
WITH_IEM_DATA: ["YES", "NO"]
TEST_WEB: ["YES", "NO"]
exclude:
- PYTHON_VERSION: "3.11"
TEST_WEB: "NO"
WITH_IEM_DATA: "NO"
env:
PYTHON_VERSION: ${{ matrix.PYTHON_VERSION }}
WITH_IEM_DATA: ${{ matrix.WITH_IEM_DATA }}
TEST_WEB: ${{ matrix.TEST_WEB }}
steps:
- uses: actions/checkout@v4
# 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
- name: Run IEM Database Container
run: |
IMAGE_TAG=$([[ ${{ matrix.WITH_IEM_DATA }} == 'YES' ]] && echo "test_data" || echo "no_test_data")
docker run -d --name iem_database -p 5432:5432 ghcr.io/akrherz/iem_database:$IMAGE_TAG
until docker exec iem_database pg_isready -h localhost; do
sleep 6
done
- name: Run Memcached container
run: |
docker run -d --name iem_memcached -p 11211:11211 memcached:1.6.9
# setup conda-forge with micromamba
- name: Setup Python
uses: mamba-org/setup-micromamba@v2
with:
environment-file: environment.yml
condarc: |
channels:
- conda-forge
- defaults
create-args: >-
python=${{ env.PYTHON_VERSION }}
environment-name: prod
cache-environment: true
- name: Clone ci_tooling
run: |
git clone --depth 1 https://github.com/akrherz/ci_tooling.git .ci_tooling
# 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
# conda-forge does not have everything we need, yet
- name: Install Python requirements from pip
run: |
python -m pip install -r pip_requirements.txt
- name: Setup Directory Paths
run: sh .github/setuppaths.sh
- name: Setup IEM Data
if: ${{ matrix.WITH_IEM_DATA == 'YES' }}
run: sh .github/setupdata.sh
# Get apache running, which is needed to build mod_wsgi
- name: Configure IEM Webfarm Server
run: |
cd .ci_tooling
. iemwebfarm.sh
- name: Configure Webfarm Server
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: Smoke Test mod_wsgi_startup.py
if: ${{ matrix.TEST_WEB == 'YES' }}
run: |
python /opt/iem/deployment/mod_wsgi_startup.py
- 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: Setup upterm session
# if: ${{ matrix.TEST_WEB == 'NO' && matrix.WITH_IEM_DATA == 'YES' }}
# uses: lhotari/action-upterm@v1
# with:
# limit-access-to-actor: true
- name: Run IEMWeb Python Check
if: ${{ matrix.TEST_WEB == 'NO' && matrix.WITH_IEM_DATA == 'YES' }}
run: |
export PYTHONPATH=/opt/iem/pylib
python -m pytest --mpl --cov=iemweb -n 4 tests/iemweb/
python -m coverage xml
- name: Upload to Codecov
if: ${{ matrix.TEST_WEB == 'NO' && matrix.WITH_IEM_DATA == 'YES' }}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
- name: View Apache Logs
if: ${{ failure() }}
run: |
sudo systemctl status apache2 -l
sudo cat /var/log/apache2/error.log
- name: View PHP-FPM Logs
if: ${{ failure() }}
run: |
sudo cat /var/log/php*-fpm.log