From 41bb299c4dc2c7d0bcc35279f6d51c522e869107 Mon Sep 17 00:00:00 2001 From: noko1024 Date: Sun, 13 Apr 2025 05:44:58 +0900 Subject: [PATCH 1/4] =?UTF-8?q?=E5=90=84=E7=A8=AEactions=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/auto_pr_assign.yml | 20 ++++++++++ .github/workflows/lint.yml | 58 ++++++++++++++++++++++++++++ .github/workflows/pytest.yml | 33 ++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 .github/workflows/auto_pr_assign.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/pytest.yml diff --git a/.github/workflows/auto_pr_assign.yml b/.github/workflows/auto_pr_assign.yml new file mode 100644 index 0000000..cb2714e --- /dev/null +++ b/.github/workflows/auto_pr_assign.yml @@ -0,0 +1,20 @@ +name: Auto PR Assign + +on: + pull_request: + types: [opened, unassigned] + +permissions: + pull-requests: write + repository-projects: read + +jobs: + assign: + name: Assign + runs-on: ubuntu-latest + steps: + - name: Set assignees + run: gh pr edit ${{ github.event.number }} --add-assignee ${{ github.actor }} --repo ${{ github.repository }} + env: + GH_TOKEN: ${{ github.token }} + if: ${{ github.event.pull_request.user.type != 'Bot' && toJSON(github.event.pull_request.assignees) == '[]' }} \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..36a75d2 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,58 @@ +name: Lint + +on: + push: + paths: + - .github/workflows/lint.yml + - "**/*.py" +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + pull-requests: write + contents: read + +jobs: + lint: + runs-on: ubuntu-latest + if: ${{ !contains(github.event.commits.*.message, '[skip lint]') }} + timeout-minutes: 10 + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up reviewdog + uses: reviewdog/action-setup@v1 + with: + reviewdog_version: latest + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12.2' + + - run: | + python -m pip install --upgrade pip + pip install poetry + poetry install --no-interaction + + - name: flake8 + uses: reviewdog/action-flake8@v3 + with: + github_token: ${{ secrets.github_token }} + reporter: github-pr-review + level: warning + fail_level: warning + filter_mode: nofilter + workdir: src + + - name: mypy + uses: tsuyoshicho/action-mypy@v4 + with: + github_token: ${{ secrets.github_token }} + reporter: github-pr-review + level: warning + filter_mode: nofilter + workdir: src + execute_command: 'poetry run mypy' \ No newline at end of file diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml new file mode 100644 index 0000000..0077f55 --- /dev/null +++ b/.github/workflows/pytest.yml @@ -0,0 +1,33 @@ +name: Test + +on: + push: + paths: + - .github/workflows/pytest.yml + - "**/*.py" + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + runs-on: ubuntu-latest + if: ${{ !contains(github.event.commits.*.message, '[skip test]') }} + timeout-minutes: 10 + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12.2' + + - run: | + python -m pip install --upgrade pip + pip install poetry + poetry install --no-interaction + + - name: pytest + run: poetry run pytest \ No newline at end of file From 59ac938aa780e1e0cd36bc016711fe0cf15fbce6 Mon Sep 17 00:00:00 2001 From: noko1024 Date: Sun, 13 Apr 2025 06:12:30 +0900 Subject: [PATCH 2/4] =?UTF-8?q?=E3=81=A8=E3=82=8A=E3=81=82=E3=81=88?= =?UTF-8?q?=E3=81=9A=E3=83=86=E3=82=B9=E3=83=88=E3=82=921=E3=81=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- src/tests/RandomMapGenerator_test.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/tests/RandomMapGenerator_test.py diff --git a/.gitignore b/.gitignore index 65f608a..d931486 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,5 @@ logs/ # プログラムで自動生成されるファイル src/generated_map/ -*.map \ No newline at end of file +src/__pycache__/ +*.map diff --git a/src/tests/RandomMapGenerator_test.py b/src/tests/RandomMapGenerator_test.py new file mode 100644 index 0000000..25bcbbe --- /dev/null +++ b/src/tests/RandomMapGenerator_test.py @@ -0,0 +1,11 @@ +import numpy as np +import pytest + +import src.RandomMapGenerator + + +def test_rotateMap(): + small_map = np.array([[1, 2], [3, 4]]) + expected_result = np.array([[2, 4], [1, 3]]) + result = src.RandomMapGenerator.rotateMap(small_map) + assert np.array_equal(result, expected_result) From fa767469a85074c7db293352994a94636db4e899 Mon Sep 17 00:00:00 2001 From: noko1024 Date: Sun, 13 Apr 2025 06:37:10 +0900 Subject: [PATCH 3/4] =?UTF-8?q?tests=E7=AD=89=E3=82=92mypy=E3=81=8B?= =?UTF-8?q?=E3=82=89=E9=99=A4=E5=A4=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 7aadb84..4c7e4b8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,3 +35,4 @@ profile = "black" [tool.mypy] python_version = 3.9 strict = true +exclude = ['.venv', '__pycache__', '.git', '.mypy_cache', 'tests'] From a2b5359349cc85387d2e001fde49b95e4651d1a4 Mon Sep 17 00:00:00 2001 From: noko1024 Date: Sun, 13 Apr 2025 06:47:42 +0900 Subject: [PATCH 4/4] =?UTF-8?q?linter=E3=81=AE=E6=9D=A1=E4=BB=B6=E3=82=92?= =?UTF-8?q?=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 36a75d2..11f5d07 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,7 +1,7 @@ name: Lint on: - push: + pull_request: paths: - .github/workflows/lint.yml - "**/*.py"