Re-write #76
Workflow file for this run
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: OpenSCM-Zenodo CI-CD | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- 'v*' | |
pull_request: | |
jobs: | |
linting-and-docs: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [3.7] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Setup python | |
uses: actions/setup-python@v1 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dev dependencies | |
run: | | |
pip install --upgrade pip wheel | |
pip install -e .[dev] | |
- name: Formatting and linters | |
run: | | |
black --check src tests setup.py --exclude openscm_zenodo/_version.py | |
isort --check-only --quiet --recursive src tests setup.py | |
pydocstyle src | |
bandit -c .bandit.yml -r src | |
flake8 src tests setup.py | |
pylint src | |
- name: Build docs | |
# treat warnings as errors (-W)... | |
# ...but not when being nitpicky (-n) | |
run: | | |
sphinx-build -M html docs/source docs/build -qW | |
sphinx-build -M html docs/source docs/build -Eqn -b coverage | |
if [[ -s docs/build/html/python.txt ]] | |
then | |
echo | |
echo \"Error: Documentation missing:\" | |
echo | |
cat docs/build/html/python.txt | |
exit 1 | |
fi | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [3.6, 3.7, 3.8, 3.9] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Setup python | |
uses: actions/setup-python@v1 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install test dependencies | |
run: | | |
pip install --upgrade pip wheel | |
pip install -e .[tests] | |
- name: Test with pytest | |
if: matrix.python-version != 3.7 | |
run: | | |
pytest tests -r a | |
- name: Test with pytest including Zenodo token | |
if: matrix.python-version == 3.7 | |
env: | |
MIN_COVERAGE: 90 | |
ZENODO_TOKEN: ${{ secrets.zenodo_sandbox_token }} | |
run: | | |
pytest tests -r a --cov=openscm_zenodo --cov-report=xml | |
if ! coverage report --fail-under=${MIN_COVERAGE} --show-missing | |
then | |
echo | |
echo "Error: Test coverage has to be at least ${MIN_COVERAGE}" | |
exit 1 | |
fi | |
- name: Upload coverage to Codecov | |
if: matrix.python-version == 3.7 | |
uses: codecov/codecov-action@v1 | |
with: | |
file: ./coverage.xml | |
test-install: | |
needs: [build,linting-and-docs] | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [3.6, 3.7, 3.8, 3.9] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Setup python | |
uses: actions/setup-python@v1 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install | |
run: | | |
pip install --upgrade pip wheel | |
pip install . | |
- name: Test installation | |
run: | | |
pip list | |
python scripts/test_install.py | |
create-dist: | |
needs: [build,linting-and-docs] | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [3.7] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Setup python | |
uses: actions/setup-python@v1 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
pip install --upgrade pip wheel | |
pip install -e .[dev] | |
- name: Create package | |
run: | | |
python setup.py sdist bdist_wheel --universal | |
twine check dist/* | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: dist | |
path: dist | |
deploy-pypi: | |
needs: [test-install,create-dist] | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [3.7] | |
steps: | |
- uses: actions/download-artifact@v2 | |
with: | |
name: dist | |
path: dist | |
- name: Publish package to PyPI | |
uses: pypa/gh-action-pypi-publish@master | |
with: | |
user: __token__ | |
password: ${{ secrets.pypi_password }} |