File tree Expand file tree Collapse file tree 7 files changed +82
-5
lines changed
Expand file tree Collapse file tree 7 files changed +82
-5
lines changed Original file line number Diff line number Diff line change 1+ --container-architecture=linux/amd64
2+ --action-offline-mode
Original file line number Diff line number Diff line change 1111 steps :
1212 - name : Checkout
1313 uses : actions/checkout@v4
14-
14+ - name : Set up Python
15+ uses : actions/setup-python@v4
16+ with :
17+ python-version : ' 3.10'
18+ - name : Install ruff
19+ run : pip install ruff
1520 - name : Get pre-commit
1621 uses : pre-commit/action@v3.0.0
1722 - name : Run pre-commit
Original file line number Diff line number Diff line change 1+ # This workflow will install Python dependencies, run tests and lint with a single version of Python
2+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
4+ name : Python application
5+
6+ on :
7+ push :
8+ branches : [ "main" ]
9+ pull_request :
10+ branches : [ "main" ]
11+
12+ permissions :
13+ contents : read
14+
15+ jobs :
16+ build :
17+
18+ runs-on : ubuntu-latest
19+
20+ steps :
21+ - uses : actions/checkout@v4
22+ - name : Set up Python 3.10
23+ uses : actions/setup-python@v3
24+ with :
25+ python-version : " 3.10"
26+ - name : Install dependencies
27+ run : |
28+ python -m pip install --upgrade pip
29+ pip install pytest
30+ pip install .
31+ - name : Test with pytest
32+ run : pytest
Original file line number Diff line number Diff line change @@ -28,3 +28,16 @@ build website with bundle
2828``` bash
2929bundle exec jekyll serve --port 4001
3030```
31+
32+ ## Test actions locally
33+
34+ Using [ act] ( https://nektosact.com/introduction.html )
35+
36+ Make sure Docker is running then simply
37+ ``` bash
38+ act
39+ ```
40+ If you want to run it on one of the actions simply
41+ ``` bash
42+ act -W .github/workflows/action.yml
43+ ```
Original file line number Diff line number Diff line change 1+ from randomfpl .fantasy_random import generate_team
2+ import argparse
3+ import asyncio
4+
5+
6+ def test_generate_team ():
7+ args = argparse .Namespace (
8+ max_expense = 100 ,
9+ show_average = False ,
10+ show_toprank = False ,
11+ show_ext_info = False ,
12+ veto_player = False ,
13+ veto_teams = False ,
14+ )
15+ team = asyncio .run (generate_team (args ))
16+ assert team is not None
Original file line number Diff line number Diff line change @@ -12,8 +12,9 @@ dependencies = [
1212 " matplotlib" ,
1313]
1414
15- [project .optional-dependencies ]
16- dev = [" pylint" , " black" ]
17-
1815[project .scripts ]
1916randomfpl = " randomfpl:main"
17+
18+ [tool .pytest .ini_options ]
19+ asyncio_mode = " strict"
20+ asyncio_default_fixture_loop_scope = " function"
Original file line number Diff line number Diff line change 1010
1111def main ():
1212 """`main` function for RandomFPL module"""
13+ args = parse_args ()
14+ asyncio .run (generate_team (args ))
15+
16+
17+ def parse_args ():
18+ """'parse_args' returns parser.parse_args()"""
1319 parser = argparse .ArgumentParser ()
1420 parser .add_argument (
1521 "--show_average" ,
@@ -51,7 +57,7 @@ def main():
5157 )
5258
5359 args = parser .parse_args ()
54- asyncio . run ( generate_team ( args ))
60+ return args
5561
5662
5763async def generate_team (args ):
@@ -151,6 +157,8 @@ async def generate_team(args):
151157 df_mingoalscon ,
152158 )
153159
160+ return random_team
161+
154162
155163def print_average_quantities (df , show ):
156164 """`print_average_quantities` prints average goals and assists"""
You can’t perform that action at this time.
0 commit comments