CI #1160
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 | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: read # This is required for actions/checkout | |
env: | |
OFFSETS_DB_DATABASE_URL: postgres://postgres_user:postgres_password@localhost:5432/postgres_db | |
OFFSETS_DB_STAGING: true | |
OFFSETS_DB_API_KEY: cowsay | |
AWS_DEFAULT_REGION: us-west-2 | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
# 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: configure aws credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: arn:aws:iam::631969445205:role/github-action-role | |
role-session-name: offsets-db-ci-role-session | |
aws-region: ${{ env.AWS_DEFAULT_REGION }} | |
- name: set up conda environment | |
uses: mamba-org/setup-micromamba@v2 | |
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 | |
run: | | |
python -m pytest | |
- name: Upload code coverage to Codecov | |
uses: codecov/[email protected] | |
with: | |
file: ./coverage.xml | |
flags: unittests | |
env_vars: OS,PYTHON | |
name: codecov-umbrella | |
fail_ci_if_error: false |