CI #476
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@v3 | |
- name: Set up conda environment | |
uses: mamba-org/provision-with-micromamba@v15 | |
with: | |
micromamba-version: latest | |
channel-priority: strict | |
environment-file: environment-dev.yml | |
environment-name: ncviewjs | |
cache-env: true | |
extra-specs: | | |
python="3.10" | |
- name: Prefect Cloud login | |
run: | | |
prefect config set PREFECT_API_KEY=${{ secrets.PREFECT_API_KEY }} | |
prefect config set PREFECT_API_URL=${{ secrets.PREFECT_API_URL }} | |
- name: Register workflow | |
run: | | |
cd flows | |
python submit.py | |
- 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 | |
# - name: Upload code coverage to Codecov | |
# uses: codecov/codecov-action@v3 | |
# with: | |
# fail_ci_if_error: true |