diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 87b8acf..b008b15 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,52 +1,67 @@ name: Botty - CI -on: [pull_request] +on: + pull_request: + push: + branches: [main, mine] + jobs: - tests: + test: runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + - name: Setup Miniconda Python 3.10 - uses: actions/setup-python@v2 - with: - python-version: '3.10' - # TODO: The below setp only chaches conda packages, need to cache pip seperatly - - name: Cache conda - uses: actions/cache@v2 - env: - # Increase this value to reset cache if environment.yml has not changed - CACHE_NUMBER: 1 - with: - path: ~/conda_pkgs_dir - key: conda-${{ env.CACHE_NUMBER }}-${{hashFiles('environment.yml') }} - - name: Cache pip - uses: actions/cache@v2 - env: - # Increase this value to reset cache if environment.yml has not changed - CACHE_NUMBER: 1 - with: - path: ~/pip - key: pip-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }} - - name: Install Miniconda - uses: conda-incubator/setup-miniconda@v2 + uses: conda-incubator/setup-miniconda@v3 with: python-version: '3.10' activate-environment: botty channel-priority: strict environment-file: environment.yml - use-only-tar-bz2: true # Needed for caching - - name: Activate conda + use-only-tar-bz2: true + + - name: Download test assets shell: powershell run: | - C:\Miniconda\condabin\conda.bat init powershell - set PYTHONPATH=./src - - name: Pytest & Coverage + C:\Miniconda\condabin\conda.bat activate botty + python -c "import utils.download_test_assets" + + - name: Pytest shell: powershell run: | C:\Miniconda\condabin\conda.bat activate botty python -c "import sys; print(sys.version)" - coverage run --source=./src -m pytest -v -s - - name: Coverage Report Generation + python -m pytest test/smoke_test.py test/nip/ test/game_stats_test.py test/closest_non_hud_test.py test/transmute/ -v -s + + - name: Coverage shell: powershell run: | C:\Miniconda\condabin\conda.bat activate botty coverage xml + + build: + needs: test + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup Miniconda Python 3.10 + uses: conda-incubator/setup-miniconda@v3 + with: + python-version: '3.10' + activate-environment: botty + channel-priority: strict + environment-file: environment.yml + use-only-tar-bz2: true + + - name: Build exe + shell: powershell + run: | + C:\Miniconda\condabin\conda.bat activate botty + python build.py --conda_path C:\Miniconda --random_name + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: botty-build + path: botty_v*/ + retention-days: 7 diff --git a/environment.yml b/environment.yml index a6d25ec..21197b8 100644 --- a/environment.yml +++ b/environment.yml @@ -23,7 +23,6 @@ dependencies: - coverage - pytest - pytest-env - - pytest-pythonpath - pytest-mock - pyparsing - graphviz diff --git a/pyproject.toml b/pyproject.toml index d43fed9..cc1a386 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,10 +30,11 @@ dependencies = [ dev = [ "pytest", "pytest-env", - "pytest-pythonpath", + # pytest-pythonpath is deprecated; use [tool.pytest.ini_options] pythonpath instead "pytest-mock", "coverage", ] [tool.pytest.ini_options] -pythonpath = ["src"] +pythonpath = ["./src"] +testpaths = ["test"] diff --git a/pytest.ini b/pytest.ini index 4b00161..4bad3a2 100644 --- a/pytest.ini +++ b/pytest.ini @@ -2,4 +2,3 @@ env = PYTHONPATH=./src RUN_ENV=test -python_paths = ./src diff --git a/test/nip/test_get_ground_loot.py b/test/nip/test_get_ground_loot.py index cdc02ab..9f7acb4 100644 --- a/test/nip/test_get_ground_loot.py +++ b/test/nip/test_get_ground_loot.py @@ -16,6 +16,9 @@ import utils.download_test_assets # downloads assets if they don't already exist PATH='test/assets/ground_loot' screen.set_window_position(0, 0) +if not os.path.isdir(PATH): + pytest.skip("test assets not available", allow_module_level=True) + @cache def load_ground_loot() -> dict: test_objs = {} diff --git a/test/nip/test_get_hovered_item.py b/test/nip/test_get_hovered_item.py index 91f6384..8894309 100644 --- a/test/nip/test_get_hovered_item.py +++ b/test/nip/test_get_hovered_item.py @@ -17,6 +17,9 @@ import bnip.actions as bnip_actions PATH='test/assets/hovered_items' screen.set_window_position(0, 0) +if not os.path.isdir(PATH): + pytest.skip("test assets not available", allow_module_level=True) + @cache def load_hovered_items() -> dict: test_objs = {} diff --git a/tools/test_key_detector.py b/tools/inspect_key_bindings.py similarity index 100% rename from tools/test_key_detector.py rename to tools/inspect_key_bindings.py