Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github actions, automated testing and coverage reports. #5

Merged
merged 1 commit into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/actions.yaml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
12 changes: 6 additions & 6 deletions roll_sim/tests/test_headliners.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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)
Expand All @@ -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
Expand Down
Loading