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..11f5d07 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,58 @@ +name: Lint + +on: + pull_request: + 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 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/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'] 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)