Skip to content

switch to github actions to python 312 #251

switch to github actions to python 312

switch to github actions to python 312 #251

Workflow file for this run

name: ci-checks
on:
pull_request:
push:
branches:
- main
tags:
- '*'
workflow_dispatch:
jobs:
backend:
name: backend
runs-on: ubuntu-22.04
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: bmds
POSTGRES_PASSWORD: password
POSTGRES_DB: bmds-online-test
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
ports:
- 5432/tcp
redis:
image: redis:7-alpine
options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
ports:
- 6379:6379
steps:
- name: Checkout bmds-ui
uses: actions/checkout@v4
- name: Checkout bmds@main
uses: actions/checkout@v4
with:
repository: USEPA/bmds
path: venv
ref: main
token: ${{ secrets.USEPA_BMDS_PRIVATE_PAT }}
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
- name: loc
run: |
sudo apt-get install -y cloc
echo "# Lines of Code Report" >> $GITHUB_STEP_SUMMARY
make loc >> $GITHUB_STEP_SUMMARY
- name: Install pybmds
run: |
python -m pip install -U pip wheel setuptools
cd venv
source ./tools/linux_ci_setup.sh
source ./tools/linux_ci_env.sh
python setup.py bdist_wheel
python -m pip install "$(ls dist/*.whl | head -n 1)"
- name: Install bmds_ui
run: |
mv tests/data/ci-webpack-stats.json bmds_ui/webpack-stats.json
python -m pip install -e ".[pg,dev]"
- name: lint
run: |
make lint-py
- name: test
env:
DJANGO_DB_NAME: bmds-online-test
DJANGO_DB_USER: bmds
DJANGO_DB_PW: password
DJANGO_DB_HOST: localhost
DJANGO_DB_PORT: ${{ job.services.postgres.ports[5432] }} # get randomly assigned published port
DJANGO_CACHE_LOCATION: redis://localhost:6379/0
run: |
export "LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH"
coverage run -m pytest --record-mode=none
echo "# Python coverage report" >> $GITHUB_STEP_SUMMARY
coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
- name: Upload pybmds wheel
uses: actions/upload-artifact@v4
with:
name: pybmds
path: |
venv/dist
venv/tools
retention-days: 1
frontend:
name: frontend
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
cache-dependency-path: 'frontend/yarn.lock'
- name: install
run: |
yarn --cwd ./frontend install --frozen-lockfile
- name: lint
run: |
yarn --cwd ./frontend run lint
- name: test
run: |
npm --prefix ./frontend run test
- name: build for integration tests
run: |
npm --prefix ./frontend run build
- name: Upload webpack build
uses: actions/upload-artifact@v4
with:
name: webpack-build
path: |
bmds_ui/webpack-stats.json
bmds_ui/static/bundles/
retention-days: 1
integration:
name: integration
needs: [backend, frontend]
runs-on: ubuntu-22.04
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: bmds
POSTGRES_PASSWORD: password
POSTGRES_DB: bmds-online-test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
env:
DJANGO_DB_HOST: localhost
DJANGO_DB_NAME: bmds-online-test
DJANGO_DB_PW: password
DJANGO_DB_USER: bmds
INTEGRATION_TESTS: 1
LIVESERVER_HOST: localhost
LIVESERVER_PORT: 8000
steps:
- uses: actions/checkout@v4
- name: Checkout bmds@main
uses: actions/checkout@v4
with:
repository: USEPA/bmds-private
path: venv
ref: main
token: ${{ secrets.USEPA_BMDS_PRIVATE_PAT }}
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
- name: Download webpack build
uses: actions/download-artifact@v4
with:
name: webpack-build
path: bmds_ui
- name: Download pybmds wheel
uses: actions/download-artifact@v4
with:
name: pybmds
path: venv
- name: Install pybmds
run: |
source ./venv/tools/linux_ci_setup.sh
source ./venv/tools/linux_ci_env.sh
python -m pip install "$(ls ./venv/dist/*.whl | head -n 1)"
- name: Install bmds_ui
run: |
pip install -U pip wheel
pip install -e ".[pg,dev]"
playwright install --with-deps chromium
# https://github.community/t/how-to-retry-a-failed-step-in-github-actions-workflow/125880
- name: run integration tests
id: test
continue-on-error: true
run: |
export "LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH"
py.test -sv tests/integration/
- name: run integration tests (retry)
if: steps.test.outcome=='failure'
id: retry
continue-on-error: true
run: |
export "LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH"
py.test -sv tests/integration/
- name: set status
if: always()
run: |
if ${{ steps.test.outcome=='success' || steps.retry.outcome=='success' }}; then
echo success!
else
exit 1
fi
- name: build wheel
run: |
export "LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH"
manage.py set_git_commit
flit build --no-use-vcs
- name: Upload webpack build
uses: actions/upload-artifact@v4
with:
name: wheel
path: dist/*.whl