forked from oamg/leapp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
testing: Start using GH Actions for unit tests (oamg#719)
This patch applies all necessary changes to make tests run on GitHub Actions. As part of this patch we are transitioning like in leapp-repository to ubi based containers running on podman. This will gives us the closest resemblance to the target environments. Tests for fedora & others can be eventually added as well. For now this patch focuses on our main targets as the tests have not been working for some time. Also as part of this patch some minor flake8 fixes have been applied, and the answerstore test has been fixed. Signed-off-by: Vinzenz Feenstra <[email protected]>
- Loading branch information
Showing
20 changed files
with
192 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Unit Tests | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
test: | ||
name: Run unit tests in containers | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
scenarios: | ||
- name: Run unit tests with python3.9 on el8 | ||
python: python3.9 | ||
container: ubi8 | ||
- name: Run unit tests with python 3.6 on el8 | ||
python: python3.6 | ||
container: ubi8 | ||
- name: Run unit tests with python2.7 on el7 | ||
python: python2.7 | ||
container: ubi7 | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: '0' | ||
- name: Set master to origin/master | ||
if: github.ref != 'refs/heads/master' | ||
run: | | ||
git branch -f master origin/master | ||
- name: ${{matrix.scenarios.name}} | ||
run: script -e -c /bin/bash -c 'TERM=xterm podman build --security-opt=seccomp=unconfined -t leapp-tests -f res/container-tests/Containerfile.${{matrix.scenarios.container}} res/container-tests && PYTHON_VENV=${{matrix.scenarios.python}} REPOSITORIES=${{matrix.scenarios.repos}} podman run --security-opt=seccomp=unconfined --rm -ti -v ${PWD}:/payload --env=PYTHON_VENV --env=REPOSITORIES leapp-tests' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
-r requirements.txt | ||
-e . | ||
|
||
flake8 | ||
isort | ||
jsonschema==3.2.0 | ||
mock | ||
pyrsistent==0.16.1 | ||
pytest==3.6.4 | ||
pytest-flake8 | ||
pytest-cov==2.9.0 | ||
pytest-pylint==0.14.1 | ||
pylint | ||
pytest-cov | ||
pytest==4.6.11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
FROM registry.access.redhat.com/ubi7/ubi:7.9 | ||
|
||
VOLUME /payload | ||
|
||
RUN yum -y install python27-python-pip && \ | ||
scl enable python27 -- pip install -U --target /usr/lib/python2.7/site-packages/ pip==20.3.0 && \ | ||
python -m pip install --ignore-installed pip==20.3.4 virtualenv | ||
|
||
WORKDIR /payload | ||
ENTRYPOINT virtualenv testenv && \ | ||
source testenv/bin/activate && \ | ||
pip install -U setuptools && \ | ||
pip install -U funcsigs && \ | ||
pip install -U -r requirements-tests.txt && \ | ||
pip install -U . && \ | ||
export LINTABLES=$(find . -name '*.py' | grep -E -e '^\./leapp\/' -e '^\./tests/scripts/' | sort -u ) && \ | ||
echo '==================================================' && \ | ||
echo '==================================================' && \ | ||
echo '=============== Running pylint ===============' && \ | ||
echo '==================================================' && \ | ||
echo '==================================================' && \ | ||
# echo $LINTABLES | xargs pylint --py3k && echo '===> pylint PASSED' && \ | ||
echo 'TEMPORARILY DISABLED' && \ | ||
echo '==================================================' && \ | ||
echo '==================================================' && \ | ||
echo '=============== Running flake8 ===============' && \ | ||
echo '==================================================' && \ | ||
echo '==================================================' && \ | ||
flake8 $LINTABLES && echo '===> flake8 PASSED' && \ | ||
echo '==================================================' && \ | ||
echo '==================================================' && \ | ||
echo '=============== Running tests ===============' && \ | ||
echo '==================================================' && \ | ||
echo '==================================================' && \ | ||
py.test -vv --cov-report term-missing --cov=leapp tests/scripts/*.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
FROM registry.access.redhat.com/ubi8/ubi:latest | ||
|
||
VOLUME /payload | ||
|
||
ENV PYTHON_VENV "python3.6" | ||
|
||
RUN yum update -y && \ | ||
yum install python3 python39 python3-virtualenv make -y && \ | ||
yum -y install python3-pip && \ | ||
python3 -m pip install --upgrade pip==20.3.4 | ||
|
||
WORKDIR /payload | ||
ENTRYPOINT virtualenv testenv -p "/usr/bin/$PYTHON_VENV" && \ | ||
source testenv/bin/activate && \ | ||
pip install -U setuptools && \ | ||
pip install -U funcsigs && \ | ||
pip install -U -r requirements-tests.txt && \ | ||
pip install -U . && \ | ||
export LINTABLES=$(find . -name '*.py' | grep -E -e '^\./leapp\/' -e '^\./tests/scripts/' | sort -u ) && \ | ||
echo '==================================================' && \ | ||
echo '==================================================' && \ | ||
echo '=============== Running pylint ===============' && \ | ||
echo '==================================================' && \ | ||
echo '==================================================' && \ | ||
# echo $LINTABLES | xargs pylint && echo '===> pylint PASSED' && \ | ||
echo 'TEMPORARILY DISABLED' && \ | ||
echo '==================================================' && \ | ||
echo '==================================================' && \ | ||
echo '=============== Running flake8 ===============' && \ | ||
echo '==================================================' && \ | ||
echo '==================================================' && \ | ||
flake8 $LINTABLES && echo '===> flake8 PASSED' && \ | ||
echo '==================================================' && \ | ||
echo '==================================================' && \ | ||
echo '=============== Running tests ===============' && \ | ||
echo '==================================================' && \ | ||
echo '==================================================' && \ | ||
py.test -vv --cov-report term-missing --cov=leapp tests/scripts/*.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
FROM registry.access.redhat.com/ubi8/ubi:latest | ||
|
||
VOLUME /payload | ||
|
||
RUN yum update -y && \ | ||
yum install python3 python39 python3-virtualenv make -y && \ | ||
yum -y install python3-pip && \ | ||
python3 -m pip install --upgrade pip==20.3.4 | ||
|
||
WORKDIR /payload | ||
ENTRYPOINT virtualenv testenv -p "/usr/bin/$PYTHON_VENV" && \ | ||
source testenv/bin/activate && \ | ||
pip install -U setuptools && \ | ||
pip install -U funcsigs && \ | ||
pip install -U -r requirements-tests.txt && \ | ||
pip install -U . && \ | ||
export LINTABLES=$(find . -name '*.py' | grep -E -e '^\./leapp\/' -e '^\./tests/scripts/' | sort -u ) && \ | ||
echo '==================================================' && \ | ||
echo '==================================================' && \ | ||
echo '=============== Running pylint ===============' && \ | ||
echo '==================================================' && \ | ||
echo '==================================================' && \ | ||
# echo $LINTABLES | xargs pylint && echo '===> pylint PASSED' && \ | ||
echo 'TEMPORARILY DISABLED' && \ | ||
echo '==================================================' && \ | ||
echo '==================================================' && \ | ||
echo '=============== Running flake8 ===============' && \ | ||
echo '==================================================' && \ | ||
echo '==================================================' && \ | ||
flake8 $LINTABLES && echo '===> flake8 PASSED' && \ | ||
echo '==================================================' && \ | ||
echo '==================================================' && \ | ||
echo '=============== Running tests ===============' && \ | ||
echo '==================================================' && \ | ||
echo '==================================================' && \ | ||
py.test -vv --cov-report term-missing --cov=leapp tests/scripts/*.py |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,11 @@ | ||
from leapp.workflows.api.v1.testapi import TestAPI | ||
from leapp.workflows.api.v1.depcheck import DepCheckAPI1, DepCheckAPI2, DepCheckAPI3, DepCheckAPI4 | ||
from leapp.workflows.api.v1.testapi import TestAPI | ||
|
||
|
||
__all__ = ( | ||
DepCheckAPI1, | ||
DepCheckAPI2, | ||
DepCheckAPI3, | ||
DepCheckAPI4, | ||
TestAPI | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
from leapp.workflows.api.v2.testapi import TestAPI | ||
from leapp.workflows.api.v1.depcheck import DepCheckAPI1, DepCheckAPI2, DepCheckAPI3, DepCheckAPI4 | ||
from leapp.workflows.api.v2.newapi import NewAPI | ||
from leapp.workflows.api.v2.newapi import NewAPI | ||
from leapp.workflows.api.v2.testapi import TestAPI | ||
|
||
|
||
__all__ = ( | ||
DepCheckAPI1, | ||
DepCheckAPI2, | ||
DepCheckAPI3, | ||
DepCheckAPI4, | ||
TestAPI, | ||
NewAPI | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from leapp.workflows.api import WorkflowAPI | ||
|
||
|
||
class NewAPI(WorkflowAPI): | ||
def fun(self): | ||
return 'NewAPI.fun' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
from leapp.workflows.api.v3.testapi import TestAPI | ||
from leapp.workflows.api.v2.newapi import NewAPI | ||
from leapp.workflows.api.v1.depcheck import DepCheckAPI1, DepCheckAPI2, DepCheckAPI3, DepCheckAPI4 | ||
from leapp.workflows.api.v2.newapi import NewAPI | ||
from leapp.workflows.api.v3.testapi import TestAPI | ||
|
||
__all__ = ( | ||
DepCheckAPI1, | ||
DepCheckAPI2, | ||
DepCheckAPI3, | ||
DepCheckAPI4, | ||
TestAPI, | ||
NewAPI | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters