Skip to content

Commit

Permalink
Tests to validate built python packages (#1678)
Browse files Browse the repository at this point in the history
  • Loading branch information
chayim authored Nov 9, 2021
1 parent c19f120 commit f5160f5
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 42 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/install_and_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

set -e

SUFFIX=$1
if [ -z ${SUFFIX} ]; then
echo "Supply valid python package extension such as whl or tar.gz. Exiting."
exit 3
fi

script=`pwd`/${BASH_SOURCE[0]}
HERE=`dirname ${script}`
ROOT=`realpath ${HERE}/../..`

cd ${ROOT}
DESTENV=${ROOT}/.venvforinstall
if [ -d ${DESTENV} ]; then
rm -rf ${DESTENV}
fi
python -m venv ${DESTENV}
source ${DESTENV}/bin/activate
pip install --upgrade --quiet pip
pip install --quiet -r dev_requirements.txt
invoke devenv
invoke package

# find packages
PKG=`ls ${ROOT}/dist/*.${SUFFIX}`
ls -l ${PKG}

TESTDIR=${ROOT}/STAGETESTS
if [ -d ${TESTDIR} ]; then
rm -rf ${TESTDIR}
fi
mkdir ${TESTDIR}
cp -R ${ROOT}/tests ${TESTDIR}/tests
cd ${TESTDIR}

# install, run tests
pip install ${PKG}
pytest
86 changes: 45 additions & 41 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,61 +6,65 @@ on:
- 'docs/**'
- '**/*.rst'
- '**/*.md'
branches:
- master
pull_request:
branches:
- master

jobs:

lint:
name: Code linters
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: install python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: run code linters
run: |
pip install -r dev_requirements.txt
invoke linters
lint:
name: Code linters
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: install python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: run code linters
run: |
pip install -r dev_requirements.txt
invoke linters
run-tests:
runs-on: ubuntu-latest
strategy:
max-parallel: 6
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', 'pypy-3.7']
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
name: Python ${{ matrix.python-version }} tests
steps:
- uses: actions/checkout@v2
- name: install python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: run tests
run: |
pip install -r dev_requirements.txt
invoke tests
- name: Upload codecov coverage
uses: codecov/codecov-action@v2
with:
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
run-tests:
runs-on: ubuntu-latest
strategy:
max-parallel: 6
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', 'pypy-3.7']
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
name: Python ${{ matrix.python-version }} tests
steps:
- uses: actions/checkout@v2
- name: install python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: run tests
run: |
pip install -r dev_requirements.txt
invoke tests
- name: Upload codecov coverage
uses: codecov/codecov-action@v2
with:
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}

build_package:
build_and_test_package:
name: Validate building and installing the package
runs-on: ubuntu-latest
strategy:
matrix:
extension: ['tar.gz', 'whl']
steps:
- uses: actions/checkout@v2
- name: install python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: build and install
- name: Run installed unit tests
run: |
pip install invoke
invoke package
bash .github/workflows/install_and_test.sh ${{ matrix.extension }}
1 change: 1 addition & 0 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ tox-docker==3.1.0
invoke==1.6.0
pytest-cov>=3.0.0
vulture>=2.3.0
wheel>=0.30.0
2 changes: 1 addition & 1 deletion tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ def clean(c):
@task
def package(c):
"""Create the python packages"""
run("python setup.py build install")
run("python setup.py sdist bdist_wheel")

0 comments on commit f5160f5

Please sign in to comment.