.github/workflows/ci.yml
name: Continuous Integration
on:
push:
branches: ["*"]
pull_request:
branches: ["*"]
jobs:
test:
strategy:
matrix:
python-version: [3.8, 3.9]
runs-on: ubuntu-latest
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_schemas tests docs --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: Test with pytest
run: |
pytest --cov=cidc_schemas -v --benchmark-group-by=func
- 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
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
verbose: true
user: ${{ secrets.PYPI_USERNAME }}
password: ${{ secrets.PYPI_PASSWORD }}