Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/auto_pr_assign.yml
Original file line number Diff line number Diff line change
@@ -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) == '[]' }}
58 changes: 58 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -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'
33 changes: 33 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ logs/

# プログラムで自動生成されるファイル
src/generated_map/
*.map
src/__pycache__/
*.map
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ profile = "black"
[tool.mypy]
python_version = 3.9
strict = true
exclude = ['.venv', '__pycache__', '.git', '.mypy_cache', 'tests']
11 changes: 11 additions & 0 deletions src/tests/RandomMapGenerator_test.py
Original file line number Diff line number Diff line change
@@ -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)