diff --git a/.github/workflows/actions.yaml b/.github/workflows/actions.yaml new file mode 100644 index 0000000..990fa7a --- /dev/null +++ b/.github/workflows/actions.yaml @@ -0,0 +1,45 @@ +name: Python CI + +on: + push: + branches: + - main + pull_request: + +permissions: + checks: write + pull-requests: write + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + + - name: Install dependencies + run: pip install -e . + + - name: Run tests with coverage + run: | + pytest --cov=roll_sim --cov-report xml:cov.xml --junitxml=res.xml + + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action/composite@v2 + if: always() + with: + files: | + res.xml + + - name: Coverage report + uses: 5monkeys/cobertura-action@master + if: always() + with: + path: cov.xml + minimum_coverage: 66 \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 88be79e..9debbd2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,9 @@ requires-python = ">=3.8" dependencies = [ "pytest>=8.0.0", "click>=8.0.0", - "PyYAML>=6.0.0" + "PyYAML>=6.0.0", + "coverage>=7.0", + "pytest-cov>=4.1.0" ] dynamic = ["version"] diff --git a/roll_sim/tests/test_headliners.py b/roll_sim/tests/test_headliners.py index f4773e0..e42cd52 100644 --- a/roll_sim/tests/test_headliners.py +++ b/roll_sim/tests/test_headliners.py @@ -1,7 +1,7 @@ import pytest from roll_sim.code import utils -from roll_sim.code.roll import RolldownSimulator -from roll_sim.scripts import run_rolldown +from roll_sim.code.roll_headliners import RolldownSimulator +from roll_sim.scripts import headliner_rolldown from roll_sim.code import statistics from roll_sim.tests.fixtures import ( level8_executioner, @@ -13,13 +13,13 @@ from pathlib import Path def rolldown(conf, **kwargs): - headliners, level, other = run_rolldown.get_and_validate_data(conf) + headliners, level, other = headliner_rolldown.get_and_validate_data(conf) path_script = Path(__file__).parent.resolve() path_roll_sim = path_script.parent.resolve() path_data = path_roll_sim / "data" - champions, headliners = run_rolldown.prepare_data(path_data, headliners, level, other) + champions, headliners = headliner_rolldown.prepare_data(path_data, headliners, level, other) sim = RolldownSimulator(champions=champions, headliners_to_buy=headliners) avg_rolls = sim.roll(**kwargs) @@ -28,12 +28,12 @@ def rolldown(conf, **kwargs): def test_conf_no_level(incorrect_conf_no_level): conf = incorrect_conf_no_level with pytest.raises(ValueError): - run_rolldown.get_and_validate_data(conf) + headliner_rolldown.get_and_validate_data(conf) def test_conf_headliners(incorrect_conf_no_headliners): conf = incorrect_conf_no_headliners with pytest.raises(ValueError): - run_rolldown.get_and_validate_data(conf) + headliner_rolldown.get_and_validate_data(conf) def test_simple_rolldown(level8_executioner): conf = level8_executioner