Skip to content

Commit

Permalink
GitHub actions testing (#9)
Browse files Browse the repository at this point in the history
Moving from Travis to GitHub actions

* Add GitHub actions to build package
* Change Python versions to 3.x
* Use pytest instead of nose
* Drop 3.4 testing and test uploading of results
* Test junit reporting
* Move Pypi to use secret keys
* Add skip_existing flag for dev deployments
* Update test results dir
* Add production deployment
(Should only run on master branch and tagged commits)
* Only run production on tagged commits v2
  • Loading branch information
fininicus authored Mar 1, 2022
1 parent b4e33a6 commit 45e08e7
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 37 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Build, Test and Release Python Package

on:
push:
pull_request:
branches: [ master ]

jobs:
build:

# Currently Ubuntu 20.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.5", "3.6", "3.7", "3.8", "3.9", "3.10"]

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
python -m pip install .
python -m pip install pytest
- name: Test with pytest
run: |
python -m pytest --doctest-modules --junitxml junit/test-results-${{ matrix.python-version }}.xml
- name: Publish pytest test results
uses: mikepenz/action-junit-report@v2
with:
report_paths: junit/test-results*.xml
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}

deploy-test:
runs-on: ubuntu-latest
environment: Development
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
# Build on the latest version of Python
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build --sdist --wheel
- name: Publish package to Test PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.DEV_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true

deploy-production:
runs-on: ubuntu-latest
environment: Production
if: startsWith(github.ref, 'refs/tags')
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
# Build on the latest version of Python
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build --sdist --wheel
- name: Publish package to PyPi
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PROD_PYPI_API_TOKEN }}
37 changes: 0 additions & 37 deletions .travis.yml

This file was deleted.

0 comments on commit 45e08e7

Please sign in to comment.