Skip to content

Commit f5160f5

Browse files
authored
Tests to validate built python packages (#1678)
1 parent c19f120 commit f5160f5

File tree

4 files changed

+88
-42
lines changed

4 files changed

+88
-42
lines changed

.github/workflows/install_and_test.sh

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
SUFFIX=$1
6+
if [ -z ${SUFFIX} ]; then
7+
echo "Supply valid python package extension such as whl or tar.gz. Exiting."
8+
exit 3
9+
fi
10+
11+
script=`pwd`/${BASH_SOURCE[0]}
12+
HERE=`dirname ${script}`
13+
ROOT=`realpath ${HERE}/../..`
14+
15+
cd ${ROOT}
16+
DESTENV=${ROOT}/.venvforinstall
17+
if [ -d ${DESTENV} ]; then
18+
rm -rf ${DESTENV}
19+
fi
20+
python -m venv ${DESTENV}
21+
source ${DESTENV}/bin/activate
22+
pip install --upgrade --quiet pip
23+
pip install --quiet -r dev_requirements.txt
24+
invoke devenv
25+
invoke package
26+
27+
# find packages
28+
PKG=`ls ${ROOT}/dist/*.${SUFFIX}`
29+
ls -l ${PKG}
30+
31+
TESTDIR=${ROOT}/STAGETESTS
32+
if [ -d ${TESTDIR} ]; then
33+
rm -rf ${TESTDIR}
34+
fi
35+
mkdir ${TESTDIR}
36+
cp -R ${ROOT}/tests ${TESTDIR}/tests
37+
cd ${TESTDIR}
38+
39+
# install, run tests
40+
pip install ${PKG}
41+
pytest

.github/workflows/integration.yaml

+45-41
Original file line numberDiff line numberDiff line change
@@ -6,61 +6,65 @@ on:
66
- 'docs/**'
77
- '**/*.rst'
88
- '**/*.md'
9+
branches:
10+
- master
911
pull_request:
1012
branches:
1113
- master
1214

1315
jobs:
1416

15-
lint:
16-
name: Code linters
17-
runs-on: ubuntu-latest
18-
steps:
19-
- uses: actions/checkout@v2
20-
- name: install python
21-
uses: actions/setup-python@v2
22-
with:
23-
python-version: 3.9
24-
- name: run code linters
25-
run: |
26-
pip install -r dev_requirements.txt
27-
invoke linters
17+
lint:
18+
name: Code linters
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: install python
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: 3.9
26+
- name: run code linters
27+
run: |
28+
pip install -r dev_requirements.txt
29+
invoke linters
2830
29-
run-tests:
30-
runs-on: ubuntu-latest
31-
strategy:
32-
max-parallel: 6
33-
matrix:
34-
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', 'pypy-3.7']
35-
env:
36-
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
37-
name: Python ${{ matrix.python-version }} tests
38-
steps:
39-
- uses: actions/checkout@v2
40-
- name: install python
41-
uses: actions/setup-python@v2
42-
with:
43-
python-version: ${{ matrix.python-version }}
44-
- name: run tests
45-
run: |
46-
pip install -r dev_requirements.txt
47-
invoke tests
48-
- name: Upload codecov coverage
49-
uses: codecov/codecov-action@v2
50-
with:
51-
fail_ci_if_error: false
52-
token: ${{ secrets.CODECOV_TOKEN }}
31+
run-tests:
32+
runs-on: ubuntu-latest
33+
strategy:
34+
max-parallel: 6
35+
matrix:
36+
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', 'pypy-3.7']
37+
env:
38+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
39+
name: Python ${{ matrix.python-version }} tests
40+
steps:
41+
- uses: actions/checkout@v2
42+
- name: install python
43+
uses: actions/setup-python@v2
44+
with:
45+
python-version: ${{ matrix.python-version }}
46+
- name: run tests
47+
run: |
48+
pip install -r dev_requirements.txt
49+
invoke tests
50+
- name: Upload codecov coverage
51+
uses: codecov/codecov-action@v2
52+
with:
53+
fail_ci_if_error: false
54+
token: ${{ secrets.CODECOV_TOKEN }}
5355

54-
build_package:
56+
build_and_test_package:
5557
name: Validate building and installing the package
5658
runs-on: ubuntu-latest
59+
strategy:
60+
matrix:
61+
extension: ['tar.gz', 'whl']
5762
steps:
5863
- uses: actions/checkout@v2
5964
- name: install python
6065
uses: actions/setup-python@v2
6166
with:
6267
python-version: 3.9
63-
- name: build and install
68+
- name: Run installed unit tests
6469
run: |
65-
pip install invoke
66-
invoke package
70+
bash .github/workflows/install_and_test.sh ${{ matrix.extension }}

dev_requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ tox-docker==3.1.0
66
invoke==1.6.0
77
pytest-cov>=3.0.0
88
vulture>=2.3.0
9+
wheel>=0.30.0

tasks.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ def clean(c):
5656
@task
5757
def package(c):
5858
"""Create the python packages"""
59-
run("python setup.py build install")
59+
run("python setup.py sdist bdist_wheel")

0 commit comments

Comments
 (0)