diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 672e78e..05b03ef 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -1,6 +1,8 @@ name: Python Package on: + workflow_dispatch: + pull_request: push: branches: - '*' @@ -8,6 +10,74 @@ on: - '*' jobs: + mypy-required: + runs-on: 'ubuntu-latest' + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Workaround for worktree config + run: git config --unset-all extensions.worktreeConfig || true + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + cache: "pip" + + - name: Install Python packages + run: | + python -m pip install -e . + python -m pip install mypy + + - name: Mypy on required files + uses: tsuyoshicho/action-mypy@v5 + with: + github_token: ${{ secrets.github_token }} + # Change reviewdog reporter if you need [github-pr-check,github-check,github-pr-review]. + reporter: github-check + setup_method: nothing + target: --config-file=pyproject.toml + fail_on_error: true + install_types: false + + mypy-modified: + runs-on: 'ubuntu-latest' + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Workaround for worktree config + run: git config --unset-all extensions.worktreeConfig || true + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + cache: "pip" + + - name: Install Python packages + run: | + python -m pip install -e . + python -m pip install mypy + + - name: Mypy on modified files + uses: tsuyoshicho/action-mypy@v5 + with: + github_token: ${{ secrets.github_token }} + # Change reviewdog reporter if you need [github-pr-check,github-check,github-pr-review]. + reporter: github-check + setup_method: nothing + level: warning + fail_on_error: false + install_types: false + build: runs-on: ubuntu-latest name: Wheel @@ -42,7 +112,9 @@ jobs: pypi: runs-on: 'ubuntu-latest' needs: + - mypy-required - build + if: ${{ github.event_name != 'pull_request' }} steps: - name: Download all the dists diff --git a/.github/workflows/workflow-validate.yml b/.github/workflows/workflow-validate.yml new file mode 100644 index 0000000..fb419ab --- /dev/null +++ b/.github/workflows/workflow-validate.yml @@ -0,0 +1,33 @@ +name: Check Workflow Files + +on: + push: + branches: + - main + + merge_group: + pull_request: + +defaults: + run: + shell: bash + +jobs: + actions: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: true + + - name: Install action-validator with asdf + uses: asdf-vm/actions/install@v3 + with: + tool_versions: | + action-validator 0.5.1 + + - name: Lint Actions + run: | + find .github/workflows -type f \( -iname \*.yaml -o -iname \*.yml \) \ + | xargs -I {} action-validator --verbose {} \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8bb3555..fc18165 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.2.2 + rev: v0.8.3 hooks: - id: ruff args: [ --fix, --exit-non-zero-on-fix ]