Merge pull request #1572 from akrherz/260331 #4512
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |