Skip to content

Commit

Permalink
Fix double github action test triggers (#213)
Browse files Browse the repository at this point in the history
* Added windows and osx to test workflow

* Move fail fast to proper location

* Updated workflow to not double run

* typo fix

* Cleaned up pytest workflow more

* Remove bad semi-colon

* Fix naming of jobs

* Tried adding back in `sudo apt-get update`

* Remove explicit dependancy on python3

* Try exporting python to path and use that
  • Loading branch information
eddiebergman authored Jan 26, 2022
1 parent 61d7259 commit c67b347
Showing 1 changed file with 83 additions and 41 deletions.
124 changes: 83 additions & 41 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -1,81 +1,122 @@
name: Tests

on:
# Allow to manually trigger through github API
workflow_dispatch:
# Triggers with push to master
push:
branches:
- master

# Triggers with push to a pr aimed at master
pull_request:
branches:
- master

schedule:
# Every Monday at 7AM UTC
- cron: '0 07 * * 5'
# Every day at 7AM UTC
- cron: '0 07 * * *'

env:

# Arguments used for pytest
pytest-args: >-
--durations=20
-v
# Arguments used for code-cov which is later used to annotate PR's on github
code-cov-args: >-
--cov=ConfigSpace
--cov-report=xml
jobs:
ubuntu:

runs-on: ubuntu-18.04
unit-test:
name: ${{ matrix.python-version }}-${{ matrix.os }}-${{ matrix.kind }}

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8, 3.9]
use-conda: [true, false]
use-dist: [false]
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: ["3.7", "3.8", "3.9", "3.10"]
kind: ['conda', 'source', 'dist']

exclude:
# Exclude all configurations *-*-dist, include one later
- kind: 'dist'

# Exclude windows as bash commands wont work in windows runner
- os: windows-latest

# Exclude macos as there are permission errors using conda as we do
- os: macos-latest

include:
- python-version: 3.8
# Add the tag code-cov to ubuntu-3.7-source
- os: ubuntu-latest
python-version: 3.7
kind: 'source'
code-cov: true
- python-version: 3.7
use-conda: false
use-dist: true
fail-fast: false

# Include one config with dist, ubuntu-3.7-dist
- os: ubuntu-latest
python-version: 3.7
kind: 'dist'

steps:
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2

# A note on checkout: When checking out the repository that
# triggered a workflow, this defaults to the reference or SHA for that event.
# Otherwise, uses the default branch (master) is used.
- name: Checkout
uses: actions/checkout@v2

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Conda Install test dependencies
if: matrix.use-conda == true

- name: Conda install
if: matrix.kind == 'conda'
run: |
# Miniconda is available in $CONDA env var
$CONDA/bin/conda create -n testenv --yes pip wheel python=${{ matrix.python-version }}
$CONDA/envs/testenv/bin/python3 -m pip install --upgrade pip
$CONDA/envs/testenv/bin/pip3 install -e .[test]
- name: Install test dependencies
if: matrix.use-conda == false && matrix.use-dist == false
- name: Source install
if: matrix.kind == 'source'
run: |
python -m pip install --upgrade pip
if [[ `python -c 'import platform; print(platform.python_version())' | cut -d '.' -f 2` -eq 6 ]]; then
# Numpy 1.20 dropped suppert for Python3.6
pip install "numpy<=1.19"
fi
pip install -e .[test]
sudo apt-get update
- name: Dist Install test dependencies
if: matrix.use-conda == false && matrix.use-dist == true
- name: Dist install
if: matrix.kind == 'dist'
run: |
python -m pip install --upgrade pip
sudo apt-get update
# We need to install for the dependencies, like pytest
python setup.py sdist
last_dist=$(ls -t dist/ConfigSpace-*.tar.gz | head -n 1)
pip install $last_dist[test]
- name: Store repository status
python -m pip install $last_dist[test]
- name: Store git status
id: status-before
run: |
echo "::set-output name=BEFORE::$(git status --porcelain -b)"
- name: Conda Run tests
timeout-minutes: 45
if: matrix.use-conda == true
run: |
export PATH="$CONDA/envs/testenv/bin:$PATH"
if [ ${{ matrix.code-cov }} ]; then codecov='--cov=ConfigSpace --cov-report=xml'; fi
$CONDA/envs/testenv/bin/python3 -m pytest --durations=20 -v $codecov test
- name: Run tests
- name: Tests
timeout-minutes: 45
if: matrix.use-conda == false
run: |
if [ ${{ matrix.code-cov }} ]; then codecov='--cov=ConfigSpace --cov-report=xml'; fi
pytest --durations=20 -v $codecov test
if [[ ${{ matrix.kind }} == 'conda' ]]; then
export PATH="$CONDA/envs/testenv/bin:$PATH"
fi
if [ ${{ matrix.code-cov }} ]; then
pytest ${{ env.pytest-args }} ${{ env.code-cov-args }} test
else
pytest ${{ env.pytest-args }} test
fi
- name: Check for files left behind by test
if: ${{ always() }}
run: |
Expand All @@ -87,6 +128,7 @@ jobs:
echo "Not all generated files have been deleted!"
exit 1
fi
- name: Upload coverage
if: matrix.code-cov && always()
uses: codecov/codecov-action@v1
Expand Down

0 comments on commit c67b347

Please sign in to comment.