Skip to content

Commit 838b340

Browse files
authored
[MAINT] Update project infrastructure (#7)
* update CI and dev configs * add pull request template * update to python 3.14, deprecate 3.8 * pylint: ignore test dir * restructure project * fix import in example * move all test data to temp dir * pylint * add optional --test-all option to pylint, make tests more robust * ignore logfile if it doesn't exist, run all tests on label apply * pylint * skip tests that require online mode * pylint * add pre-commit hooks * skip test if serrver jar download times out * Bump version
1 parent e0000e8 commit 838b340

47 files changed

Lines changed: 577 additions & 326 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/pull_request_template.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Description
2+
3+
## Checklist before merging
4+
5+
* [ ] applied `ready-to-merge` label
6+
* [ ] updated documentation ([README.md](../README.md))
7+
* [ ] updated version number ([pyproject.toml](../pyproject.toml))

.github/workflows/define-pylint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Define Pylint
1+
name: Define pylint
22

33
on:
44
workflow_call:
@@ -29,7 +29,7 @@ jobs:
2929
run: |
3030
python -m pip install --upgrade pip
3131
pip install pylint
32-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
32+
if [ -f requirements.txt ]; then pip install --upgrade -r requirements.txt; fi
3333
- name: Analysing the code with pylint
3434
run: |
3535
pylint $(git ls-files '*.py')

.github/workflows/define-pytest.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
name: Define Pytest
1+
name: Define pytest
22

33
on:
44
workflow_call:
55
inputs:
66
python-version:
77
required: true
88
type: string
9+
pytest-args:
10+
required: false
11+
type: string
12+
default: ""
913

1014
defaults:
1115
run:
@@ -29,11 +33,11 @@ jobs:
2933
run: |
3034
python -m pip install --upgrade pip
3135
pip install pytest
32-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
36+
if [ -f requirements.txt ]; then pip install --upgrade -r requirements.txt; fi
3337
- name: Install node
3438
uses: actions/setup-node@v4
3539
with:
36-
node-version: 20
40+
node-version: 22
3741
- name: Install mineflayer
3842
run: |
3943
npm install mineflayer
@@ -49,6 +53,6 @@ jobs:
4953
touch password.txt
5054
echo $USERNAME >> password.txt
5155
echo $PASSWORD >> password.txt
52-
- name: Run all tests with pytest
56+
- name: Run tests with pytest
5357
run: |
54-
pytest -rs
58+
pytest src -rs --skip-linting ${{ inputs.pytest-args }}

.github/workflows/release_package.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
pylint:
1111
strategy:
1212
matrix:
13-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
13+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
1414
uses: ./.github/workflows/define-pylint.yml
1515
with:
1616
python-version: ${{ matrix.python-version }}
@@ -19,7 +19,7 @@ jobs:
1919
pytest:
2020
strategy:
2121
matrix:
22-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
22+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
2323
uses: ./.github/workflows/define-pytest.yml
2424
with:
2525
python-version: ${{ matrix.python-version }}
@@ -29,7 +29,7 @@ jobs:
2929
runs-on: self-hosted
3030
strategy:
3131
matrix:
32-
python-version: ["3.13"]
32+
python-version: ["3.14"]
3333
steps:
3434
- uses: actions/checkout@v4
3535
- name: Set up Python ${{ matrix.python-version }}
@@ -56,10 +56,10 @@ jobs:
5656
release-tag: ${{ steps.read-tag.outputs.release-tag }}
5757
steps:
5858
- uses: actions/checkout@v4
59-
- name: Set up Python 3.13
59+
- name: Set up Python 3.14
6060
uses: actions/setup-python@v5
6161
with:
62-
python-version: "3.13"
62+
python-version: "3.14"
6363
- name: Install dependencies
6464
run: |
6565
python -m pip install --upgrade pip
@@ -73,17 +73,17 @@ jobs:
7373
echo "release-tag=$(echo $TAG)" >> $GITHUB_OUTPUT
7474
- uses: mukunku/tag-exists-action@v1.6.0
7575
id: check-tag
76-
with:
76+
with:
7777
tag: ${{ steps.read-tag.outputs.release-tag }}
7878
- name: Fail if tag exists
7979
run: |
8080
echo "Tag ${{ steps.read-tag.outputs.release-tag }} exists!"
8181
exit 1
82-
if: steps.check-tag.outputs.exists == 'true'
82+
if: steps.check-tag.outputs.exists == 'true'
8383
- name: Print tag if it doesn't exist
8484
run: |
8585
echo "Tag ${{ steps.read-tag.outputs.release-tag }} doesn't yet exist and can be created"
86-
if: steps.check-tag.outputs.exists == 'false'
86+
if: steps.check-tag.outputs.exists == 'false'
8787

8888
release:
8989
needs: [pylint, pytest, build, tag]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Remove 'ready to merge' label
2+
3+
on:
4+
pull_request:
5+
types: [closed, synchronize]
6+
7+
permissions:
8+
contents: read
9+
id-token: write
10+
pull-requests: write
11+
12+
jobs:
13+
remove_label:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions-ecosystem/action-remove-labels@v1
18+
if: (github.event.action == 'synchronize') || (github.event.pull_request.merged == true)
19+
with:
20+
labels: 'ready to merge'
21+
fail_on_error: false
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Run all tests on label apply
2+
3+
on:
4+
pull_request:
5+
types: [labeled]
6+
7+
jobs:
8+
pylint:
9+
if: github.event.label.name == 'ready to merge'
10+
strategy:
11+
matrix:
12+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
13+
uses: ./.github/workflows/define-pylint.yml
14+
with:
15+
python-version: ${{ matrix.python-version }}
16+
secrets: inherit
17+
18+
pytest:
19+
if: github.event.label.name == 'ready to merge'
20+
strategy:
21+
matrix:
22+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
23+
uses: ./.github/workflows/define-pytest.yml
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
secrets: inherit

.github/workflows/run-tests.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Run Tests
22

3-
on:
3+
on:
44
push:
55
branches: [main]
66
pull_request:
@@ -10,7 +10,7 @@ jobs:
1010
pylint:
1111
strategy:
1212
matrix:
13-
python-version: ["3.8", "3.13"]
13+
python-version: ["3.14"]
1414
uses: ./.github/workflows/define-pylint.yml
1515
with:
1616
python-version: ${{ matrix.python-version }}
@@ -19,7 +19,7 @@ jobs:
1919
pytest:
2020
strategy:
2121
matrix:
22-
python-version: ["3.8", "3.13"]
22+
python-version: ["3.9", "3.14"]
2323
needs: pylint
2424
if: |
2525
(github.event_name == 'push' && github.ref_name == 'main') ||
@@ -28,4 +28,5 @@ jobs:
2828
uses: ./.github/workflows/define-pytest.yml
2929
with:
3030
python-version: ${{ matrix.python-version }}
31+
pytest-args: "--skip-test-all"
3132
secrets: inherit

.gitignore

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
.vscode/
2-
venv*/
3-
testdir/
4-
testdir_persistent/
5-
__pycache__/
6-
mcserverwrapper/test/temp/
7-
*.egg-info/
8-
.pytest_cache/
9-
examples/temp/
10-
dist/
1+
*\__pycache__
2+
*\.pytest_cache
3+
*\.mypy_cache
4+
*\.ruff_cache
5+
*\.vscode
6+
*\venv*
7+
*\dist
8+
*\temp
119
*.pyc
10+
*.egg-info
1211
password.txt

.pre-commit-config.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v6.0.0
4+
hooks:
5+
- id: check-yaml
6+
- id: end-of-file-fixer
7+
- id: trailing-whitespace
8+
- repo: https://github.com/codespell-project/codespell
9+
rev: v2.4.1
10+
hooks:
11+
- id: codespell
12+
files: ^.*\.(py|md|yml)$
13+
exclude: >
14+
(?x)^(
15+
src/test/fuzzy_test.py|
16+
src/test/alg_test.py
17+
)$
18+
additional_dependencies:
19+
- tomli
20+
- repo: https://github.com/astral-sh/ruff-pre-commit
21+
# Ruff version.
22+
rev: v0.12.10
23+
hooks:
24+
- id: ruff-check
25+
args:
26+
- --fix
27+
- --unsafe-fixes
28+
- repo: https://github.com/pycqa/isort
29+
rev: 6.0.1
30+
hooks:
31+
- id: isort
32+
name: isort (python)
33+
- repo: https://github.com/pycqa/pylint
34+
rev: v3.3.8
35+
hooks:
36+
- id: pylint
37+
args:
38+
- -d import-error
39+
- -sn

.pylintrc

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
[MAIN]
2-
max-line-length=150
1+
[MASTER]
2+
3+
init-hook="from pylint.config import find_default_config_files; import os, sys; sys.path.append(f'{os.path.dirname(next(find_default_config_files()))}/src')"
4+
5+
# ignore=test
36

47
[MESSAGES CONTROL]
58

@@ -17,11 +20,19 @@ confidence=
1720
# no Warning level messages displayed, use "--disable=all --enable=classes
1821
# --disable=W".
1922
disable=too-many-arguments,
23+
invalid-name,
2024
fixme,
21-
bare-except,
2225
duplicate-code,
2326
too-few-public-methods,
24-
global-statement,
27+
too-many-instance-attributes,
28+
too-many-positional-arguments,
29+
logging-fstring-interpolation,
2530
too-many-branches,
31+
too-many-locals,
2632
broad-exception-raised,
27-
relative-beyond-top-level
33+
global-statement,
34+
wrong-import-order
35+
36+
[FORMAT]
37+
38+
max-line-length=120

0 commit comments

Comments
 (0)