Skip to content

Commit

Permalink
Merge pull request #165 from AresSC2/ci/auto-testing-level-up
Browse files Browse the repository at this point in the history
ci: test bots and unit testing level up on auto releases
  • Loading branch information
raspersc2 authored Aug 7, 2024
2 parents 819e3b3 + 24ac400 commit 7bff80a
Show file tree
Hide file tree
Showing 59 changed files with 1,938 additions and 1,038 deletions.
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ exclude =
MapAnalyzer
sc2_helper
cython_extensions
tests/test_bots
tests/generate_pickle_data.py.py
tests/test_run.py
tests/conftest.py
tests/load_bot_from_pickle.py
tests/generate_pickle_data.py
tests/travis_test_script.py
4 changes: 4 additions & 0 deletions .github/workflows/orchestrator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ jobs:
call-linting-pipeline:
name: Linting
uses: ./.github/workflows/lint.yml
call-run-bot-game-pipeline:
name: Linting
uses: ./.github/workflows/run_bot_game.yml
call-release-pipeline:
name: Release
needs:
- call-testing-pipeline
- call-linting-pipeline
- call-run-bot-game-pipeline
uses: ./.github/workflows/release.yml
secrets: inherit
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
# check-out repo
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.GH_TOKEN }}
Expand All @@ -22,7 +22,7 @@ jobs:
run: pipx install poetry==1.6.1
# set-up python with cache
- name: Setup Python 3.11
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'poetry'
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/run_bot_game.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Run ares test bots

on:
pull_request:
branches:
- main
workflow_call:

jobs:
run_test_bots:
name: Run test bots

runs-on: ubuntu-latest
timeout-minutes: 30


strategy:
fail-fast: true
matrix:
opponents: [ melee_bot.py, micro_bot.py ]

steps:
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Print directories and files
run: |
sudo apt-get install tree
tree
- name: Load and build docker image
run: |
docker build -t test_image -f tests/Dockerfile-runbot .
- name: Run bots
run: |
docker run -it -d --name app1 test_image
docker exec -i app1 bash -c "tree"
docker exec -i app1 bash -c "poetry run python ./tests/travis_test_script.py ./tests/test_bots/${{ matrix.opponents }}"
docker rm -f app1
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ jobs:
steps:
# check-out repo
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
# install poetry
- name: Install poetry
run: pipx install poetry==1.6.1
# set-up python with cache
- name: Setup Python 3.11
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'poetry'
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ unit-tests:
unit-tests-cov:
@pytest --doctest-modules --cov=src --cov-report term-missing --cov-report=html
unit-tests-cov-fail:
@pytest --cov=src --cov-report term-missing --cov-report=html --cov-fail-under=80 --junitxml=pytest.xml | tee pytest-coverage.txt
@pytest --cov=src --cov-report term-missing --cov-report=html --cov-fail-under=49 --junitxml=pytest.xml | tee pytest-coverage.txt
clean-cov:
@rm -rf .coverage
@rm -rf htmlcov
Expand Down
3 changes: 3 additions & 0 deletions docs/contributing/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ Indicates how much code is covered by tests
Run coverage through `pytest`:
`pytest --cov=src --cov-report term-missing --cov-report=html`

Run specific tests
`pytest -v -s tests/managers/test_building_manager.py::TestBuildingManager::test_construct_gas`

[Offical docs](https://coverage.readthedocs.io/en/6.5.0/config.html)


Expand Down
1,697 changes: 886 additions & 811 deletions poetry.lock

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ build-backend = "poetry.core.masonry.api"
exclude_lines = [
'if __name__ == "__main__":'
]
exclude_also = [
"pass",
"if TYPE_CHECKING:"
]
# only omitting files, where it seems there
# are no reasonable ways of unit testing them
omit = [
"src/ares/chat_debug.py",
"src/ares/behaviors/combat/combat_behavior.py"
]

[tool.pytest.ini_options]
testpaths = ["src", "tests"]
Expand Down Expand Up @@ -116,4 +126,3 @@ upload_to_pypi = false
upload_to_release = false
hvcs = "github"
commit_message = "{version} [skip ci]" # skip triggering ci pipelines for version commits

1 change: 1 addition & 0 deletions pytest.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/ares/behaviors/combat/individual/a_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AMove(CombatIndividualBehavior):
Example:
```py
from ares.behaviors.combat import AMove
from ares.behaviors.combat.individual import AMove
self.register_behavior(AMove(unit, self.game_info.map_center))
```
Expand Down
2 changes: 1 addition & 1 deletion src/ares/behaviors/combat/individual/attack_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AttackTarget(CombatIndividualBehavior):
Example:
```py
from ares.behaviors.combat import AttackTarget
from ares.behaviors.combat.individual import AttackTarget
unit: Unit
target: Unit
Expand Down
6 changes: 3 additions & 3 deletions src/ares/chat_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, ai: CustomBotAI):
"""
self.ai: CustomBotAI = ai

async def parse_commands(self) -> None:
async def parse_commands(self) -> None: # pragma: no cover
"""Read chat since last iteration and send debug command if it matches.
Returns
Expand Down Expand Up @@ -120,7 +120,7 @@ async def _create_units(
amount: int,
unit_id: UnitID,
player_id: int = 1,
) -> None:
) -> None: # pragma: no cover
"""Create units at player camera location.
Parameters
Expand All @@ -143,7 +143,7 @@ async def _create_units(

async def _destroy_units(
self, num_to_destroy: int, unit_id: UnitID, player_id: int = 1
) -> None:
) -> None: # pragma: no cover
"""Destroy units for provided player.
Parameters
Expand Down
16 changes: 10 additions & 6 deletions src/ares/custom_bot_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class CustomBotAI(BotAI):
unit_tag_dict: Dict[int, Unit]
worker_type: UnitID

async def on_step(self, iteration: int):
async def on_step(self, iteration: int): # pragma: no cover
"""Here because all abstract methods have to be implemented.
Gets overridden in Ares.
Expand All @@ -55,7 +55,7 @@ def draw_text_on_world(
size: int = 12,
y_offset: int = 0,
color=(0, 255, 255),
) -> None:
) -> None: # pragma: no cover
"""Print out text to the game screen.
Parameters
Expand Down Expand Up @@ -193,7 +193,7 @@ async def _give_units_same_order(
order: AbilityId,
unit_tags: Union[List[int], set[int]],
target: Optional[Union[Point2, Unit, int]] = None,
) -> None:
) -> None: # pragma: no cover
"""
Give units corresponding to the given tags the same order.
@param order: the order to give to all units
Expand Down Expand Up @@ -263,7 +263,7 @@ async def _give_units_same_order(
)
)

async def _do_archon_morph(self, templar: list[Unit]) -> None:
async def _do_archon_morph(self, templar: list[Unit]) -> None: # pragma: no cover
command = raw_pb.ActionRawUnitCommand(
ability_id=AbilityId.MORPH_ARCHON.value,
unit_tags=[templar[0].tag, templar[1].tag],
Expand All @@ -274,7 +274,9 @@ async def _do_archon_morph(self, templar: list[Unit]) -> None:
action=sc_pb.RequestAction(actions=[sc_pb.Action(action_raw=action)])
)

async def unload_by_tag(self, container: Unit, unit_tag: int) -> None:
async def unload_by_tag(
self, container: Unit, unit_tag: int
) -> None: # pragma: no cover
"""Unload a unit from a container based on its tag. Thanks, Sasha!"""
index: int = 0
# noinspection PyProtectedMember
Expand All @@ -291,7 +293,9 @@ async def unload_by_tag(self, container: Unit, unit_tag: int) -> None:

await self.unload_container(container, index)

async def unload_container(self, container_tag: int, index: int = 0) -> None:
async def unload_container(
self, container_tag: int, index: int = 0
) -> None: # pragma: no cover
# noinspection PyProtectedMember
await self.client._execute(
action=sc_pb.RequestAction(
Expand Down
122 changes: 0 additions & 122 deletions src/ares/dicts/baneling_magic_numbers.py

This file was deleted.

Loading

0 comments on commit 7bff80a

Please sign in to comment.