Skip to content
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
2 changes: 2 additions & 0 deletions .actrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--container-architecture=linux/amd64
--action-offline-mode
7 changes: 6 additions & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install ruff
run: pip install ruff
- name: Get pre-commit
uses: pre-commit/action@v3.0.0
- name: Run pre-commit
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python application

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install .
- name: Test with pytest
run: pytest
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,16 @@ build website with bundle
```bash
bundle exec jekyll serve --port 4001
```

## Test actions locally

Using [act](https://nektosact.com/introduction.html)

Make sure Docker is running then simply
```bash
act
```
If you want to run it on one of the actions simply
```bash
act -W .github/workflows/action.yml
```
16 changes: 16 additions & 0 deletions _tests/test_generate_team.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from randomfpl.fantasy_random import generate_team
import argparse
import asyncio


def test_generate_team():
args = argparse.Namespace(
max_expense=100,
show_average=False,
show_toprank=False,
show_ext_info=False,
veto_player=False,
veto_teams=False,
)
team = asyncio.run(generate_team(args))
assert team is not None
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ dependencies = [
"matplotlib",
]

[project.optional-dependencies]
dev = ["pylint", "black"]

[project.scripts]
randomfpl = "randomfpl:main"

[tool.pytest.ini_options]
asyncio_mode = "strict"
asyncio_default_fixture_loop_scope = "function"
10 changes: 9 additions & 1 deletion randomfpl/fantasy_random.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

def main():
"""`main` function for RandomFPL module"""
args = parse_args()
asyncio.run(generate_team(args))


def parse_args():
"""'parse_args' returns parser.parse_args()"""
parser = argparse.ArgumentParser()
parser.add_argument(
"--show_average",
Expand Down Expand Up @@ -51,7 +57,7 @@ def main():
)

args = parser.parse_args()
asyncio.run(generate_team(args))
return args


async def generate_team(args):
Expand Down Expand Up @@ -151,6 +157,8 @@ async def generate_team(args):
df_mingoalscon,
)

return random_team


def print_average_quantities(df, show):
"""`print_average_quantities` prints average goals and assists"""
Expand Down