CI #983
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: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
schedule: | |
- cron: "0 0 * * *" # Daily “At 00:00” UTC | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
DATABASE_URL: postgres://postgres_user:postgres_password@localhost:5432/postgres_db | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_DEFAULT_REGION: us-west-2 | |
AWS_USER: ${{ secrets.AWS_USER }} | |
SCRATCH_BUCKET: s3://carbonplan-scratch/temp | |
STAGING_BUCKET: s3://carbonplan-scratch/staging | |
PRODUCTION_BUCKET: s3://carbonplan-scratch/production | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
# https://docs.github.com/en/actions/using-containerized-services/creating-postgresql-service-containers | |
# See also https://remarkablemark.org/blog/2021/03/14/setup-postgresql-in-github-actions/ | |
# and https://github.com/actions/example-services/blob/master/.github/workflows/postgres-service.yml | |
services: | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_DB: postgres_db | |
POSTGRES_PASSWORD: postgres_password | |
POSTGRES_PORT: 5432 | |
POSTGRES_USER: postgres_user | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
defaults: | |
run: | |
shell: bash -l {0} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: set up conda environment | |
uses: mamba-org/setup-micromamba@v1 | |
with: | |
environment-file: environment-dev.yml | |
init-shell: >- | |
bash | |
cache-environment: true | |
cache-downloads: true | |
post-cleanup: "all" | |
- name: Install package | |
run: | | |
python -m pip install -e . | |
- name: Database migration | |
run: | | |
python -m alembic upgrade head | |
- name: Run tests | |
id: status | |
run: | | |
python -m pytest | |
- name: Open or update issue on failure | |
if: | | |
failure() | |
&& github.event_name == 'schedule' | |
&& github.repository_owner == 'carbonplan' | |
&& steps.status.outcome == 'failure' | |
uses: xarray-contrib/issue-from-pytest-log@v1 | |
with: | |
log-path: pytest-log.jsonl | |
issue-title: ⚠️ Nightly CI failed ⚠️ | |
issue-label: nightly |