Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test built artifacts in the CI instead of Git src #682

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 118 additions & 14 deletions .github/workflows/test-library.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
runs-on: ${{ matrix.os }}-latest
name: >-
e2e: 🐍${{ matrix.python }} @ ${{ matrix.os }}
needs:
- build
strategy:
matrix:
os: [macOS, Ubuntu]
Expand All @@ -25,40 +27,118 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@v2
- name: Make the env clean of non-test files
run: |
shopt -s extglob
mv -v tests/integration/main.sh integration-test.sh
rm -rf !integration-test.sh
shell: bash
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Download all the dists
uses: actions/download-artifact@v2
with:
name: python-package-distributions
path: dist/
- name: Integration testing
run: |
pip install -U pip
pip install .
pip install dist/proxy.py-*-py3-none-any.whl
proxy \
--hostname 127.0.0.1 \
--enable-web-server \
--pid-file proxy.pid \
--log-file proxy.log \
&
./tests/integration/main.sh
./integration-test.sh

build:
name: build-dists

runs-on: Ubuntu-latest

env:
PY_COLORS: 1
TOX_PARALLEL_NO_SPINNER: 1
TOXENV: cleanup-dists,build-dists

steps:
- name: Switch to using Python v3.10
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: >-
Calculate Python interpreter version hash value
for use in the cache key
id: calc-cache-key-py
run: |
from hashlib import sha512
from sys import version

hash = sha512(version.encode()).hexdigest()
print(f'::set-output name=py-hash-key::{hash}')
shell: python
- name: Get pip cache dir
id: pip-cache
run: >-
echo "::set-output name=dir::$(pip cache dir)"
- name: Set up pip cache
uses: actions/[email protected]
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: >-
${{ runner.os }}-pip-${{
steps.calc-cache-key-py.outputs.py-hash-key }}-${{
hashFiles('tox.ini') }}
restore-keys: |
${{ runner.os }}-pip-${{
steps.calc-cache-key-py.outputs.py-hash-key
}}-
${{ runner.os }}-pip-
- name: Install tox
run: >-
python -m
pip install
--user
tox

- name: Grab the source from Git
uses: actions/checkout@v2

- name: Pre-populate the tox env
run: >-
python -m
tox
--parallel auto
--parallel-live
--skip-missing-interpreters false
--notest
- name: Build dists
run: >-
python -m
tox
--parallel auto
--parallel-live
--skip-missing-interpreters false
- name: Store the distribution packages
uses: actions/upload-artifact@v2
with:
name: python-package-distributions
path: dist
retention-days: 30 # Defaults to 90

lint:
name: >-
${{
toJSON(matrix.custom_job_name)
&& matrix.custom_job_name
|| matrix.toxenv
}}
name: ${{ matrix.toxenv }}
needs:
- build

runs-on: Ubuntu-latest
strategy:
matrix:
toxenv:
- lint
custom_job_name:
- ''
include:
- custom_job_name: build-dists
toxenv: cleanup-dists,build-dists,metadata-validation
- metadata-validation
fail-fast: false

env:
Expand Down Expand Up @@ -109,6 +189,19 @@ jobs:
- name: Grab the source from Git
uses: actions/checkout@v2

- name: Make the env clean of non-test files
if: matrix.toxenv == 'metadata-validation'
run: |
shopt -s extglob
rm -rf !tox.ini
shell: bash
- name: Download all the dists
if: matrix.toxenv == 'metadata-validation'
uses: actions/download-artifact@v2
with:
name: python-package-distributions
path: dist/

- name: >-
Pre-populate tox envs: `${{ env.TOXENV }}`
run: >-
Expand All @@ -129,6 +222,8 @@ jobs:

test:
name: 🐍${{ matrix.python }} @ ${{ matrix.os }}
needs:
- build

runs-on: ${{ matrix.os }}-latest
strategy:
Expand Down Expand Up @@ -198,21 +293,30 @@ jobs:
- name: Grab the source from Git
uses: actions/checkout@v2

- name: Download all the dists
uses: actions/download-artifact@v2
with:
name: python-package-distributions
path: dist/

- name: Pre-populate the testing env
run: >-
python -m
tox
--parallel auto
--parallel-live
--skip-missing-interpreters false
--installpkg dist/proxy.py-*-py3-none-any.whl
--notest
shell: bash
- name: Run the testing
run: >-
python -m
tox
--parallel auto
--parallel-live
--skip-missing-interpreters false
--skip-pkg-install
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
Expand Down