From b89e8ded649d4f7cc1e84f5aa6b9dd22be1dc89f Mon Sep 17 00:00:00 2001 From: jfhovinne Date: Sun, 5 Feb 2023 15:18:55 +0100 Subject: [PATCH] Test matrix with podman (#11) --- .github/workflows/test.yml | 11 +++++----- Taskfile.yml | 6 ------ test-matrix.py | 44 -------------------------------------- test.sh | 7 ++++++ 4 files changed, 12 insertions(+), 56 deletions(-) delete mode 100644 test-matrix.py create mode 100755 test.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9f7afd3..b4d55a4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,13 +10,12 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Install Task + - name: Get podmatrix run: | - sh -c "$(curl -ssL https://taskfile.dev/install.sh)" -- -d - echo "./bin" >> $GITHUB_PATH + sudo wget https://raw.githubusercontent.com/jfhovinne/podmatrix/master/podmatrix -O /usr/local/bin/podmatrix + sudo chmod +x /usr/local/bin/podmatrix - name: Test matrix run: | - python3 -m venv /tmp/venv/ - source /tmp/venv/bin/activate - task test-matrix + podmatrix exec ./test.sh --source . --target /tmp/src --image python \ + --tag 3.7 --tag 3.8 --tag 3.9 --tag 3.10 --tag 3.11 diff --git a/Taskfile.yml b/Taskfile.yml index ff1230e..7499ff6 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -25,9 +25,3 @@ tasks: desc: Execute tests cmds: - python -m pytest - - test-matrix: - desc: Execute test matrix - cmds: - - pip install dagger-io - - python test-matrix.py diff --git a/test-matrix.py b/test-matrix.py deleted file mode 100644 index 73093f2..0000000 --- a/test-matrix.py +++ /dev/null @@ -1,44 +0,0 @@ -""" -Run tests for multiple Python versions concurrently. -""" - -import sys -import anyio -import dagger - - -async def test(): - versions = ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12-rc'] - - async with dagger.Connection(dagger.Config(log_output=sys.stderr)) as client: - src = client.host().directory('.') - deb = 'https://github.com/go-task/task/releases/download/v3.19.1/task_linux_amd64.deb' - - async def test_version(version: str): - python = ( - client.container().from_(f'python:{version}-buster') - .with_mounted_directory('/src', src) - .with_workdir('/tmp') - .with_exec(['bash', '-c', f'wget {deb}']) - .with_exec(['bash', '-c', 'dpkg -i *.deb']) - .with_workdir('/src') - .with_exec(['task', 'build']) - .with_exec(['task', 'qa']) - .with_exec(['task', 'test']) - ) - - print(f'Starting tests for Python {version}') - - await python.exit_code() - - print(f'Tests for Python {version} succeeded!') - - async with anyio.create_task_group() as tg: - for version in versions: - tg.start_soon(test_version, version) - - print('All tasks have finished') - - -if __name__ == '__main__': - anyio.run(test) diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..3e5caaa --- /dev/null +++ b/test.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +pip install -r requirements.txt +flake8 --max-line-length=127 gnrt +pip freeze | safety check --stdin +bandit -r gnrt -c .bandit.yml +python -m pytest