Continuous Integration #75
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: Continuous Integration | |
on: | |
schedule: | |
- cron: "0 8 * * 1" | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
workflow_dispatch: | |
concurrency: | |
group: actions-id-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
check-formatting: | |
name: Check Formatting Errors | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Dependencies | |
run: | | |
python -m pip install pycodestyle autopep8 | |
python -m pip install . | |
- name: Run pycodestyle | |
run: | | |
pycodestyle --statistics --count --max-line-length=150 --show-source --ignore=E731 . | |
build-and-test: | |
needs: check-formatting | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
runs-on: ${{ matrix.os }} | |
defaults: | |
run: | |
shell: bash -el {0} | |
name: ${{ matrix.os }} Python ${{ matrix.python-version }} Subtest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: mamba-org/setup-micromamba@main | |
with: | |
environment-name: temp | |
condarc: | | |
channels: | |
- defaults | |
- conda-forge | |
channel_priority: flexible | |
create-args: | | |
python=${{ matrix.python-version }} | |
- name: Install Dependencies | |
run: | | |
python -m pip install .[dev] | |
python -m pip install coverage | |
- name: Run Tests | |
uses: nick-fields/retry@v3 | |
with: | |
max_attempts: 3 | |
timeout_minutes: 15 | |
shell: bash | |
command: | | |
micromamba run -n temp coverage run --source=. --omit=py2opsin/__init__.py,setup.py,test/* -m unittest discover | |
- name: Show Coverage | |
run: | | |
coverage report -m | |
ci-report-status: | |
name: report CI status | |
needs: build-and-test | |
runs-on: ubuntu-latest | |
steps: | |
- run: | | |
result="${{ needs.build-and-test.result }}" | |
if [[ $result == "success" ]] ; then | |
exit 0 | |
else | |
exit 1 | |
fi | |
pypi-package: | |
name: Build and publish Python 🐍 distributions 📦 to PyPI | |
runs-on: ubuntu-latest | |
if: ${{ github.ref == 'refs/heads/main' && github.repository == 'JacksonBurns/py2opsin'}} | |
needs: ci-report-status | |
steps: | |
- uses: actions/checkout@master | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.10" | |
- 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: Publish distribution 📦 to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
skip-existing: true | |
verbose: true | |