Skip to content

Commit

Permalink
Merge pull request #310 from pbs/OCTO-10853
Browse files Browse the repository at this point in the history
OCTO-10853-dockerize tests
  • Loading branch information
lorandvarga authored Oct 31, 2023
2 parents ae1881b + e7cc56a commit 9295160
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 19 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @pbs/core-services
2 changes: 1 addition & 1 deletion .github/workflows/create_github_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
call-unit-tests-workflow:
name: Run unit tests
uses: pbs/pycaption/.github/workflows/main.yml@main
uses: pbs/pycaption/.github/workflows/unit_tests.yml@main
secrets:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on: workflow_dispatch
jobs:
call-unit-tests-workflow:
name: Run unit tests
uses: pbs/pycaption/.github/workflows/main.yml@main
uses: pbs/pycaption/.github/workflows/unit_tests.yml@main
secrets:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }}
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/release_test_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ on: workflow_dispatch
jobs:
call-unit-tests-workflow:
name: Run unit tests
uses: ./.github/workflows/main.yml
uses: ./.github/workflows/unit_tests.yml
secrets:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }}

build-n-publish:
name: Build and publish PyCaption to PyPI
name: Build and publish PyCaption to Test PyPI
needs: call-unit-tests-workflow
runs-on: ubuntu-latest
steps:
Expand All @@ -32,8 +32,9 @@ jobs:
run: python -m build
timeout-minutes: 10

- name: Publish package on PyPI
- name: Publish package on Test PyPI
run: python -m twine upload --verbose dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
TWINE_REPOSITORY: "testpypi"
27 changes: 16 additions & 11 deletions .github/workflows/main.yml → .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,29 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
python-version: ["py37", "py38", "py39", "py310", "py311"]

steps:
- uses: actions/checkout@v2

- name: Setup python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install Tox
run: pip install tox==3
- name: Run Tox
- name: Run Test
id: tests
# Run tox using the version of Python in `PATH`
run: tox -e py
run: |
./run_tests.sh test_${{ matrix.python-version }}
continue-on-error: true

- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: test-report-${{ matrix.python-version }}
path: junit.xml

- name: Archive code coverage results
uses: actions/upload-artifact@v3
with:
name: code-coverage-report-${{ matrix.python-version }}
path: coverage.xml

- name: Add context info to env
run: |
sudo apt-get install -y --no-install-recommends libxml-xpath-perl
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ License
This module is Copyright (c) 2012-2023 PBS.org and is available under the `Apache
License, Version 2.0 <http://www.apache.org/licenses/LICENSE-2.0>`__.

.. |Build Status| image:: https://github.com/pbs/pycaption/actions/workflows/main.yml/badge.svg
:target: https://github.com/pbs/pycaption/actions/workflows/main.yml
.. |Build Status| image:: https://github.com/pbs/pycaption/actions/workflows/unit_tests.yml/badge.svg
:target: https://github.com/pbs/pycaption/actions/workflows/unit_tests.yml
:alt: Unit Tests

.. |Pre-Commit| image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white
Expand Down
62 changes: 62 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
version: '3.8'

services:
test_py37:
image: python:3.7-slim-bullseye
command: sh -c "
cd pycaption;
pip install --upgrade pip;
pip install -r test_requirements.txt;
pip install -e .;
pytest -vvvv --color=yes --junit-xml=junit.xml --cov=pycaption --cov-report xml:coverage.xml;
"
volumes:
- .:/pycaption
test_py38:
image: python:3.8-slim-bullseye
command: sh -c "
cd pycaption;
pip install --upgrade pip;
pip install -r test_requirements.txt;
pip install -e .;
pytest -vvvv --color=yes --junit-xml=junit.xml --cov=pycaption --cov-report xml:coverage.xml;
"
volumes:
- .:/pycaption
test_py39:
image: python:3.9-slim-bullseye
command: sh -c "
cd pycaption;
pip install --upgrade pip;
pip install -r test_requirements.txt;
pip install -e .;
pytest -vvvv --color=yes --junit-xml=junit.xml --cov=pycaption --cov-report xml:coverage.xml;
"
volumes:
- .:/pycaption
test_py310:
image: python:3.10-slim-bullseye
command: sh -c "
cd pycaption;
pip install --upgrade pip;
pip install -r test_requirements.txt;
pip install -e .;
pytest -vvvv --color=yes --junit-xml=junit.xml --cov=pycaption --cov-report xml:coverage.xml;
"
volumes:
- .:/pycaption
test_py311:
image: python:3.11-slim-bullseye
command: sh -c "
cd pycaption;
pip install --upgrade pip;
pip install -r test_requirements.txt;
pip install -e .;
pytest -vvvv --color=yes --junit-xml=junit.xml --cov=pycaption --cov-report xml:coverage.xml;
"
volumes:
- .:/pycaption
23 changes: 23 additions & 0 deletions run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash -eux

DOCKER_CMD="docker-compose -p pycaption"

SERVICE="test_py311"

if [ "$@" ]; then
if [ "$1" == "test_py37" ] || [ "$1" == "test_py38" ] || \
[ "$1" == "test_py39" ] || [ "$1" == "test_py310" ] || [ "$1" == "test_py311" ]; then
SERVICE="$1"
fi
fi

$DOCKER_CMD build "$SERVICE"

function cleanup {
echo "Cleaning up ..."
$DOCKER_CMD down && $DOCKER_CMD rm -fv
}

$DOCKER_CMD run --rm "$SERVICE"

cleanup
6 changes: 6 additions & 0 deletions test_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pytest
pytest-cov
pytest-lazy-fixture
beautifulsoup4>=4.8.1
lxml>=4.9.1
cssutils>=2.0.0
1 change: 1 addition & 0 deletions tests/test_dfxp.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
UnitEnum, HorizontalAlignmentEnum, VerticalAlignmentEnum,
)
from tests.mixins import ReaderTestingMixIn
from pytest_lazyfixture import lazy_fixture


class TestDFXPReader(ReaderTestingMixIn):
Expand Down

0 comments on commit 9295160

Please sign in to comment.