Skip to content

Commit

Permalink
Use GitHub Actions for tests (IDSIA#896)
Browse files Browse the repository at this point in the history
* Use GitHub Actions for testing

* Add fail-fast: false

* Use strings for python version numbers and tox commands

* Use separate jobs for coverage and setup tests

* Update build badge

* Remove azure-pipelines.yml

* Change trigger to push

As recommended in https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
  • Loading branch information
thequilo committed Jan 25, 2023
1 parent aa6a4af commit 86cbd72
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 196 deletions.
113 changes: 113 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Tests

on:
- push

jobs:
pytest:
strategy:
fail-fast: false
matrix:
# These tests run on all os versions
env: [
{python: '3.8', tox: 'py38'},
{python: '3.9', tox: 'py39'},
{python: '3.10', tox: 'py310'},
{python: '3.11', tox: 'py311'},
]
os: [ubuntu-latest, windows-latest, macos-latest]

# These tests only run on ubuntu
include:
- os: ubuntu-latest
env:
python: '3.8'
tox: 'tensorflow-27'
- os: ubuntu-latest
env:
python: '3.9'
tox: 'tensorflow-28'
- os: ubuntu-latest
env:
python: '3.10'
tox: 'tensorflow-29'
- os: ubuntu-latest
env:
python: '3.10'
tox: 'tensorflow-210'
- os: ubuntu-latest
env:
python: '3.10'
tox: 'tensorflow-211'
- os: ubuntu-latest
env:
python: '3.9'
tox: 'numpy-120'
- os: ubuntu-latest
env:
python: '3.10'
tox: 'numpy-121'
- os: ubuntu-latest
env:
python: '3.10'
tox: 'numpy-123'
- os: ubuntu-latest
env:
python: '3.11'
tox: 'numpy-124'

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.env.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.env.python }}
- name: Install tox
run: |
python -m pip install tox
- name: Test with tox against environments ${{ matrix.env.tox }}
run: python -m tox -e ${{ matrix.env.tox }}
test_pre_commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Test pre-commit
run: |
bash ./tests/check_pre_commit.sh
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install tox
run: |
python -m pip install tox
- name: Run coverage tox job
run: python -m tox -e coverage
setup:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install tox
run: |
python -m pip install tox
- name: Run setup tox job
run: python -m tox -e setup

6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ in Proceedings of the 15th Python in Science Conference (SciPy 2017), Austin, Te
:target: http://dx.doi.org/10.5281/zenodo.16386
:alt: DOI for this release

.. |build| image:: https://dev.azure.com/qwlouse/Sacred%20CI/_apis/build/status/IDSIA.sacred?branchName=master
:target: https://dev.azure.com/qwlouse/Sacred%20CI/_build/latest?definitionId=1&branchName=master
:alt: Azure CI status
.. |build| image:: https://github.com/IDSIA/sacred/actions/workflows/test.yml/badge.svg
:target: https://github.com/IDSIA/sacred/actions/workflows/test.yml/badge.svg
:alt: Github Actions PyTest

.. |coverage| image:: https://coveralls.io/repos/IDSIA/sacred/badge.svg
:target: https://coveralls.io/r/IDSIA/sacred
Expand Down
173 changes: 0 additions & 173 deletions azure-pipelines.yml

This file was deleted.

22 changes: 2 additions & 20 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# and then run "tox" from this directory.

[tox]
envlist = py38, py39, py310, py311, setup, flake8, numpy-120, numpy-121, numpy-122, numpy-123, numpy-124, tensorflow-26, tensorflow-27, tensorflow-28, tensorflow-29, tensorflow-210, tensorflow-211
envlist = py{38,39,310,311}, setup, numpy-{120,121,123}, tensorflow-{26,27,28,29,210,211}

[testenv]
deps =
Expand Down Expand Up @@ -124,26 +124,8 @@ deps =
commands =
pytest {posargs}

[testenv:flake8]
basepython = python
deps =
flake8
pep8-naming
mccabe
flake8-docstrings

commands =
flake8 sacred

[testenv:black]
basepython = python
deps =
black
commands =
black --check sacred/ tests/

[testenv:coverage]
passenv = TRAVIS TRAVIS_*
passenv = TRAVIS, TRAVIS_*
basepython = python
deps =
-rdev-requirements.txt
Expand Down

0 comments on commit 86cbd72

Please sign in to comment.