Skip to content

Commit

Permalink
feat: migrate to github-actions (#475)
Browse files Browse the repository at this point in the history
* fix: failing ci due to strange unittests

* ci: migrate to github-actions
  • Loading branch information
sebastianpfischer authored May 27, 2024
1 parent 452f9c6 commit 027fc2d
Show file tree
Hide file tree
Showing 8 changed files with 803 additions and 746 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,23 @@ jobs:
- name: Prerequisite installation
uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'

- name: Install poetry
run: pip3 install poetry

# Runs the preparation
- name: Prepare working environement
- name: Prepare working environment
run: poetry install --all-extras

# Runs the test
- name: Run unittests
run: poetry run pytest --cov=./ --cov-report=xml -p no:pytest_kiso --runslow
run: poetry run coverage run -m pytest

# Run the coverage
- name: Run coverage
run: poetry run coverage xml

# Upload the test result
- name: Upload test-result to codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v4
74 changes: 74 additions & 0 deletions .github/workflows/verification_validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@

name: Verification and validation of the code

on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains 2 jobs
verification_validation:
# The type of runner that the job will run on
runs-on: ubuntu-22.04

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# Pre requisite installation
- name: Prerequisite installation
uses: actions/setup-python@v4
with:
python-version: '3.12'

- name: Install poetry
run: pip3 install poetry

# Runs the preparation
- name: Prepare working environment
run: poetry install --all-extras

# Formatting check
- name: Run format check
run: poetry run pre-commit

# Runs the tox test
- name: Run unittests (via tox)
run: poetry run tox -v run

# Run dummy test
- name: Dummy pykiso run
run: poetry run pykiso -c examples/dummy.yaml --junit

# Upload the test result
- name: Run doc
run: poetry run invoke docs

release:
runs-on: ubuntu-22.04
if: github.ref_type == 'tag'
needs: verification_validation
steps:
- uses: actions/checkout@v2

- name: Prerequisite installation
uses: actions/setup-python@v4
with:
python-version: '3.12'

- name: Install poetry
run: pip3 install poetry

- name: Prepare working environment
run: poetry install --all-extras

- name: Update to Pypi
run: poetry publish --no-interaction --build --username __token__ --password ${{ secrets.pypi_token }}
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pipeline
}
steps
{
sh 'tox run'
sh 'poetry run tox -v run'
}
}
stage('Run virtual-test')
Expand Down
1,408 changes: 695 additions & 713 deletions poetry.lock

Large diffs are not rendered by default.

18 changes: 17 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ classifiers = [
]

[tool.poetry.dependencies]
python = "^3.7"
python = "^3.9"
brainstem = "*"
PyYAML = "^6.0"
robotframework = "3.2.2"
Expand Down Expand Up @@ -106,6 +106,7 @@ sphinx-rtd-theme = "*"
sphinxcontrib-programoutput = "*"
sphinx-autodoc-typehints = "*"
ruff = "0.2.1"
tox = "^4.15.0"

[tool.poetry.scripts]
pykiso = 'pykiso.cli:main'
Expand Down Expand Up @@ -158,3 +159,18 @@ build-backend = "poetry.core.masonry.api"
# Linelength according to PEP 8.
line-length = 120
exclude = ['examples', 'tests', 'tasks.py']

[tool.tox]
legacy_tox_ini = """
[tox]
isolated_build = True
env_list =
python3.11
python3.12
[testenv]
description = run the tests with pytest
extras = all
allowlist_externals = pytest, poetry, invoke
commands = pytest
"""
15 changes: 7 additions & 8 deletions src/pykiso/tool/show_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@

from pykiso.config_parser import parse_config
from pykiso.exceptions import TestCollectionError
from pykiso.test_coordinator import test_execution
from pykiso.test_coordinator.test_case import BasicTest
from pykiso.test_coordinator import test_case, test_execution
from pykiso.types import PathType


Expand Down Expand Up @@ -65,7 +64,7 @@ def get_yaml_files(config_path: PathType, recursive: bool) -> List[Path]:
return config_files


def get_test_cases(cfg_dict: Dict[str, List[dict]]) -> List[BasicTest]:
def get_test_cases(cfg_dict: Dict[str, List[dict]]) -> List[test_case.BasicTest]:
"""Return the list of tests meant to be run by the provided
test configuration file.
Expand All @@ -82,18 +81,18 @@ def get_test_cases(cfg_dict: Dict[str, List[dict]]) -> List[BasicTest]:
return test_cases


def get_test_tags(test_case_list: List[BasicTest]) -> Dict[str, List[str]]:
def get_test_tags(test_case_list: List[test_case.BasicTest]) -> Dict[str, List[str]]:
"""Return the list of tag and values contained in the test case list
:param test_case_list: list of loaded test cases.
:return: dictionary linking the tag names to their values.
"""
tag_dict = {}
# search the tag for each test case
for test_case in test_case_list:
if test_case.tag is None:
for testCase in test_case_list:
if testCase.tag is None:
continue
for tag_name, tag_values in test_case.tag.items():
for tag_name, tag_values in testCase.tag.items():
if tag_name not in tag_dict:
tag_dict[tag_name] = list()
# tag values are lists of strings
Expand All @@ -106,7 +105,7 @@ def get_test_tags(test_case_list: List[BasicTest]) -> Dict[str, List[str]]:

def build_result_dict(
config_file_name: str,
test_case_list: List[BasicTest],
test_case_list: List[test_case.BasicTest],
test_tags: Dict[str, list],
show_test_cases: bool = False,
) -> Dict[str, Union[str, int]]:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_show_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def tmp_yaml_files(tmp_path: Path, request):

@pytest.fixture
def basic_test_mock(mocker):
return mocker.patch("pykiso.tool.show_tag.BasicTest")
return mocker.patch("pykiso.tool.show_tag.test_case.BasicTest")


@pytest.fixture(autouse=True, scope="module")
Expand Down
18 changes: 0 additions & 18 deletions tox.ini

This file was deleted.

0 comments on commit 027fc2d

Please sign in to comment.