diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 0d23cae..1c53200 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -1,11 +1,6 @@ -# This workflow will install Python dependencies, run tests and lint with a single version of Python -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python - name: Python Tests on: - push: - branches-ignore: [ "main" ] pull_request: branches: [ "**" ] @@ -15,7 +10,20 @@ permissions: pull-requests: write jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@09d2acae674a48949e3602304ab46fd20ae0c42f + - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 + with: + python-version: '3.13' + - uses: launchbynttdata/actions-asdf-install_tools@v0.2.0 + with: + exclude_tools: "python" + - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd + run-tests: + needs: [ pre-commit ] runs-on: ubuntu-latest strategy: matrix: @@ -29,9 +37,6 @@ jobs: uses: astral-sh/setup-uv@445689ea25e0de0a23313031f5fe577c74ae45a1 with: python-version: ${{ matrix.python-version }} - - name: Ruff check - run: | - uvx ruff check - name: Install dependencies run: | uv sync diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..fd0ab6c --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,43 @@ +repos: + - repo: https://github.com/astral-sh/uv-pre-commit + rev: ac44eab0cf35cf4268a18f1e7c20e0980550d6fa # 0.7.15 + hooks: + - id: uv-lock + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # v5.0.0 + hooks: + - id: trailing-whitespace + - id: check-case-conflict + - id: check-executables-have-shebangs + - id: check-json + - id: check-merge-conflict + - id: check-shebang-scripts-are-executable + - id: check-yaml + args: + - --allow-multiple-documents + - id: end-of-file-fixer + - id: mixed-line-ending + args: + - --fix=auto + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: 8a948e557ca98afa9489998ad0b85515964df9c4 # v0.12.0 + hooks: + - id: ruff-check + types_or: [python, pyi] + args: [--fix] + - id: ruff-format + types_or: [python, pyi] + - repo: https://github.com/RobertCraigie/pyright-python + rev: 708a9d4a964376a7be931b7721d315ef1d2db31d # v1.1.402 + hooks: + - id: pyright + - repo: https://github.com/antonbabenko/pre-commit-terraform + rev: 2f8bda194a420ad77a050a9de627d77a74841fdc # v1.99.4 + hooks: + - id: terragrunt_fmt + - id: terragrunt_validate_inputs + exclude: "^[^/]+$" + args: + - --env-vars=TF_VAR_organization_tag="THIS_ORGANIZATION" + - --env-vars=TF_VAR_repository_tag="THIS_REPOSITORY" + - --env-vars=TF_VAR_commit_hash_tag="THIS_COMMIT_HASH" diff --git a/.tool-versions b/.tool-versions index 3b06445..e400a79 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,3 +1,4 @@ +pre-commit 3.3.3 python 3.13.1 terraform 1.5.5 terragrunt 0.54.11 diff --git a/pyproject.toml b/pyproject.toml index 7816a03..6c82dc3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,3 +54,8 @@ exclude = [ "site-packages", ".venv", ] + +[tool.pyright] +# ... +venvPath = "." +venv = ".venv"