Skip to content

Data freeze

Data freeze #2342

Workflow file for this run

name: Continuous Integration
on:
push:
branches: ["*"]
pull_request:
branches: ["*"]
jobs:
test:
strategy:
matrix:
python-version: [3.8, 3.9]
runs-on: ubuntu-latest
services:
postgres:
# Docker Hub image
image: postgres:9.6
ports:
- 5432:5432
env:
POSTGRES_USER: cidcdev
POSTGRES_PASSWORD: 1234
POSTGRES_DB: cidctest
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.dev.txt
pip install pytest-cov
- name: Check code format with black
run: |
black --check cidc_api tests --target-version=py37
- name: Setup codeclimate test coverage reporter
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
- name: Setup test database
run: |
docker exec -e PGPASSWORD=1234 ${{ job.services.postgres.id }} psql cidctest -U cidcdev -c "
create extension citext;
create extension pgcrypto;
"
- name: Test with pytest
run: |
pytest --cov=cidc_api -v
- name: Report test coverage
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
run: |
coverage xml
./cc-test-reporter after-build -t coverage.py --exit-code 0
build:
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/production' }}
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install pypa/build
run: |
python -m pip install build --user
- name: Build a binary wheel and a source tarball
run: |
python -m build --sdist --wheel --outdir dist/ .
- name: Archive the build artifacts
uses: actions/upload-artifact@v2
if: ${{ github.ref == 'refs/heads/master' }}
with:
name: build-artifacts
path: dist
pypi-publish:
needs: [test, build]
if: ${{ github.ref == 'refs/heads/master' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: build-artifacts
path: dist
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
skip_existing: true
user: ${{ secrets.PYPI_USERNAME }}
password: ${{ secrets.PYPI_PASSWORD }}
gae-deploy:
runs-on: ubuntu-latest
needs: [build, test]
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/production' }}
steps:
- uses: actions/checkout@v2
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0
with:
service_account_key: ${{ github.ref == 'refs/heads/production' && secrets.GCP_SA_KEY_PROD || secrets.GCP_SA_KEY_STAGING }}
export_default_credentials: true
- name: Deploy to App Engine (Prod)
if: ${{ github.ref == 'refs/heads/production' }}
run: |
gcloud --quiet app deploy app.prod.yaml \
--project cidc-dfci \
--version "githubactions-${GITHUB_SHA:0:7}-$GITHUB_RUN_NUMBER" \
--no-cache
- name: Deploy to App Engine (Staging)
if: ${{ github.ref == 'refs/heads/master' }}
run: |
gcloud --quiet app deploy app.staging.yaml \
--project cidc-dfci-staging \
--version "githubactions-${GITHUB_SHA:0:7}-$GITHUB_RUN_NUMBER" \
--no-cache