Merge pull request #977 from akrherz/bump #1646
This file contains 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: CI | |
on: | |
pull_request: | |
branches: [ main ] | |
push: | |
branches: [ main ] | |
jobs: | |
build-and-deploy: | |
defaults: | |
run: | |
# Ensures environment gets sourced right | |
shell: bash -l -e {0} | |
name: Python (${{ matrix.PYTHON_VERSION }}) | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
PYTHON_VERSION: ["3.9", "3.11", "3.12"] | |
env: | |
PYTHON_VERSION: ${{ matrix.PYTHON_VERSION }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# we need a reasonable depth so that the most recent tag is available | |
fetch-depth: 500 | |
- name: Add /etc/hosts entries | |
run: | | |
cat .github/workflows/etchosts.txt | sudo tee -a /etc/hosts | |
# setup conda-forge with micromamba | |
- name: Setup Python | |
uses: mamba-org/setup-micromamba@v1 | |
with: | |
environment-file: environment.yml | |
condarc: | | |
channels: | |
- conda-forge | |
- defaults | |
create-args: >- | |
python=${{ env.PYTHON_VERSION }} | |
environment-name: prod | |
cache-environment: true | |
- name: Setup Postgres | |
run: | | |
git clone --depth 1 https://github.com/akrherz/iem-database.git database | |
git clone --depth 1 https://github.com/akrherz/ci_tooling.git .ci_tooling | |
. .ci_tooling/postgres.sh | |
cd database; sh bootstrap.sh | |
python schema_manager.py | |
python store_test_data.py $(which psql) | |
psql -f data/postgis/cwsu.db -U mesonet postgis | |
- name: Setup Memcached | |
run: | | |
. .ci_tooling/memcached.sh | |
- name: Install pyiem | |
run: | | |
python -m pip install . --upgrade --no-deps | |
- name: Populate Data | |
run: | | |
sudo ln -s /home/runner/micromamba /opt/miniconda3 | |
python util/create_transformed_parquet.py --justgeodf | |
python util/insert_testing_data.py | |
sudo mkdir -p /opt/iem/config | |
sudo wget -q -O /opt/iem/config/navbar.json https://raw.githubusercontent.com/akrherz/iem/main/config/navbar.json | |
- name: Run Tests | |
run: | | |
# get pqinsert available as a dummy command | |
export PATH=$PATH:$(pwd)/tests/bin | |
# xdist and coverage seems to necessitate this | |
python -m pytest --cov=pyiem -n 4 --mpl --mpl-generate-summary=html \ | |
--mpl-results-path=mplresults-${{ matrix.PYTHON_VERSION }} | |
python -m coverage xml | |
- name: Upload Test Results, if failed | |
if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: mplresults-${{ matrix.PYTHON_VERSION }} | |
path: mplresults-${{ matrix.PYTHON_VERSION }} | |
retention-days: 1 | |
- name: Code coverage | |
if: ${{ matrix.PYTHON_VERSION == '3.12' }} | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: coverage.xml | |
- name: Build Docs | |
if: ${{ matrix.PYTHON_VERSION == '3.12' }} | |
run: | | |
cd docs | |
make html | |
touch build/html/.nojekyll | |
- name: Deploy Docs | |
if: ${{ matrix.PYTHON_VERSION == '3.12' && github.event_name == 'push' && github.ref == 'refs/heads/main'}} | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
branch: gh-pages # The branch the action should deploy to. | |
folder: docs/build/html # The folder the action should deploy. This example folder is generated by Sphinx |