Skip to content

Commit 81bf90a

Browse files
authored
Add: Windows and mac testing (#227)
* Add: Windows and mac testing * Fix: bad matrix arg * Fix: Seperated out test types into different jobs * Fix: Remove list from env var * Fix: Remove unneeded braces * Fix: can't escape bash var, make as step output * Fix: env.code-cov-action bool check * Fix: Remove more uneeded braces * Fix: maybe? * Fix: Job setup doesn't read env vars * Fix: Remove extra brace * Fix: explicitly evaluate expression in job.step.env * Try: single quotes? * Fix: explictly use `python -m pip` * Add: Name dist tests with prefix "dist" * Test: debug python version * test: fix debug statement * Fix: syntax * fix: try join instead of format * Try: Don't use job.step.env and embed expression in run * Fix: remove join * Fix: remove bad right bracket * Try: wrap in string * Fix: sdist env variable * Fix: macos not using correct Python version * Fix: Remove unneeded fix * Fix: Use global env for code-cov python version * Fix: Enable code cov upload * Add: Make more generic * Fix: Make install from editable to prevent wheel building * Fix: Make dist install non-editable
1 parent 5842d4d commit 81bf90a

1 file changed

Lines changed: 133 additions & 63 deletions

File tree

.github/workflows/pytest.yml

Lines changed: 133 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Tests
33
on:
44
# Allow to manually trigger through github API
55
workflow_dispatch:
6+
67
# Triggers with push to master
78
push:
89
branches:
@@ -19,106 +20,70 @@ on:
1920

2021
env:
2122

23+
package-name: ConfigSpace
24+
test-dir: test
25+
extra-requires: "[test]" # "" for no extra_requires
26+
2227
# Arguments used for pytest
2328
pytest-args: >-
2429
--durations=20
2530
-v
2631
27-
# Arguments used for code-cov which is later used to annotate PR's on github
32+
# Version to run code-cov on
33+
# NOTE: These are only acessible inside a jobs **steps** and not in the job setup,
34+
# Hence, some of these varialbes are copied and are just here for reference
35+
#
36+
code-cov-active: true # Copied in job setup
37+
code-cov-os: ubuntu-latest # Copied in job setup
38+
code-cov-python-version: "3.7"
2839
code-cov-args: >-
2940
--cov=ConfigSpace
3041
--cov-report=xml
3142
3243
jobs:
3344

34-
unit-test:
35-
name: ${{ matrix.python-version }}-${{ matrix.os }}-${{ matrix.kind }}
45+
# General unit tests
46+
source-test:
47+
name: ${{ matrix.python-version }}-${{ matrix.os }}
3648

3749
runs-on: ${{ matrix.os }}
50+
defaults:
51+
run:
52+
shell: bash # Default to using bash on all
53+
3854
strategy:
3955
fail-fast: false
4056
matrix:
41-
os: [windows-latest, ubuntu-latest, macos-latest]
4257
python-version: ["3.7", "3.8", "3.9", "3.10"]
43-
kind: ['conda', 'source', 'dist']
44-
45-
exclude:
46-
# Exclude all configurations *-*-dist, include one later
47-
- kind: 'dist'
48-
49-
# Exclude windows as bash commands wont work in windows runner
50-
- os: windows-latest
51-
52-
# Exclude macos as there are permission errors using conda as we do
53-
- os: macos-latest
54-
55-
include:
56-
# Add the tag code-cov to ubuntu-3.7-source
57-
- os: ubuntu-latest
58-
python-version: 3.7
59-
kind: 'source'
60-
code-cov: true
61-
62-
# Include one config with dist, ubuntu-3.7-dist
63-
- os: ubuntu-latest
64-
python-version: 3.7
65-
kind: 'dist'
58+
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
6659

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

75-
- name: Setup Python ${{ matrix.python-version }}
64+
- name: Setup Python
7665
uses: actions/setup-python@v2
7766
with:
7867
python-version: ${{ matrix.python-version }}
7968

80-
- name: Conda install
81-
if: matrix.kind == 'conda'
82-
run: |
83-
# Miniconda is available in $CONDA env var
84-
$CONDA/bin/conda create -n testenv --yes pip wheel python=${{ matrix.python-version }}
85-
$CONDA/envs/testenv/bin/python3 -m pip install --upgrade pip
86-
$CONDA/envs/testenv/bin/pip3 install -e .[test]
87-
88-
- name: Source install
89-
if: matrix.kind == 'source'
69+
- name: Install ${{ env.package-name }}
9070
run: |
9171
python -m pip install --upgrade pip
92-
pip install -e .[test]
93-
94-
- name: Dist install
95-
if: matrix.kind == 'dist'
96-
run: |
97-
python -m pip install --upgrade pip
98-
python setup.py sdist
99-
last_dist=$(ls -t dist/ConfigSpace-*.tar.gz | head -n 1)
100-
python -m pip install $last_dist[test]
72+
python -m pip install wheel
73+
python -m pip install -e ".${{ env.extra-requires }}"
10174
10275
- name: Store git status
10376
id: status-before
77+
shell: bash
10478
run: |
10579
echo "::set-output name=BEFORE::$(git status --porcelain -b)"
10680
10781
- name: Tests
10882
timeout-minutes: 45
10983
run: |
110-
if [[ ${{ matrix.kind }} == 'conda' ]]; then
111-
export PATH="$CONDA/envs/testenv/bin:$PATH"
112-
fi
113-
114-
if [ ${{ matrix.code-cov }} ]; then
115-
pytest ${{ env.pytest-args }} ${{ env.code-cov-args }} test
116-
else
117-
pytest ${{ env.pytest-args }} test
118-
fi
84+
pytest ${{ env.pytest-args }} ${{ env.test-dir }}
11985
12086
- name: Check for files left behind by test
121-
if: ${{ always() }}
12287
run: |
12388
before="${{ steps.status-before.outputs.BEFORE }}"
12489
after="$(git status --porcelain -b)"
@@ -129,9 +94,114 @@ jobs:
12994
exit 1
13095
fi
13196
97+
# Testing with conda
98+
conda-tests:
99+
name: conda-${{ matrix.python-version }}-${{ matrix.os }}
100+
runs-on: ${{ matrix.os }}
101+
defaults:
102+
run:
103+
shell: bash -l {0} # Default to using bash on all and load (-l) .bashrc which miniconda uses
104+
105+
strategy:
106+
fail-fast: false
107+
matrix:
108+
python-version: ["3.7", "3.8", "3.9", "3.10"]
109+
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
110+
111+
steps:
112+
- name: Checkout
113+
uses: actions/checkout@v2
114+
115+
- name: Conda install
116+
uses: conda-incubator/setup-miniconda@v2
117+
with:
118+
auto-update-conda: true
119+
python-version: ${{ matrix.python-version }}
120+
121+
- name: Install ${{ env.package-name }}
122+
run: |
123+
python -V
124+
python -m pip install --upgrade pip
125+
python -m pip install wheel
126+
python -m pip install -e ".${{ env.extra-requires }}"
127+
128+
- name: Tests
129+
timeout-minutes: 45
130+
run: |
131+
pytest ${{ env.pytest-args }} ${{ env.test-dir }}
132+
#
133+
# Testing a dist install
134+
dist-test:
135+
name: dist-${{ matrix.python-version }}-${{ matrix.os }}
136+
137+
runs-on: ${{ matrix.os }}
138+
defaults:
139+
run:
140+
shell: bash
141+
142+
strategy:
143+
fail-fast: false
144+
matrix:
145+
python-version: ["3.7", "3.8", "3.9", "3.10"]
146+
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
147+
148+
steps:
149+
- name: Checkout
150+
uses: actions/checkout@v2
151+
152+
- name: Setup Python
153+
uses: actions/setup-python@v2
154+
with:
155+
python-version: ${{ matrix.python-version }}
156+
157+
- name: Create sdist
158+
id: sdist
159+
run: |
160+
python -m pip install --upgrade pip
161+
python setup.py sdist
162+
echo "sdist_name=$(ls -t dist/${{ env.package-name }}-*.tar.gz | head -n 1)" >> $GITHUB_ENV
163+
164+
- name: Install ${{ env.package-name }}
165+
run: |
166+
python -m pip install ${{ env.sdist_name }}${{ env.extra-requires }}
167+
168+
- name: Tests
169+
timeout-minutes: 45
170+
run: |
171+
pytest ${{ env.pytest-args }} ${{ env.test-dir }}
172+
173+
174+
# Testing with codecov coverage uploaded
175+
codecov-test:
176+
name: codecov-test
177+
178+
runs-on: "ubuntu-latest"
179+
defaults:
180+
run:
181+
shell: bash
182+
183+
steps:
184+
- name: Checkout
185+
uses: actions/checkout@v2
186+
187+
- name: Setup Python
188+
uses: actions/setup-python@v2
189+
with:
190+
python-version: ${{ env.code-cov-python-version }}
191+
192+
- name: Install ${{ env.package-name }}
193+
run: |
194+
python -m pip install --upgrade pip
195+
python -m pip install wheel
196+
python -m pip install -e ".${{ env.extra-requires }}"
197+
198+
- name: Tests
199+
timeout-minutes: 45
200+
run: |
201+
pytest ${{ env.pytest-args }} ${{ env.code-cov-args }} ${{ env.test-dir }}
202+
132203
- name: Upload coverage
133-
if: matrix.code-cov && always()
134-
uses: codecov/codecov-action@v1
204+
uses: codecov/codecov-action@v2
135205
with:
136206
fail_ci_if_error: true
137207
verbose: true

0 commit comments

Comments
 (0)