Skip to content

Commit 0234dab

Browse files
committed
Update pyproject.toml and github workflows
Signed-off-by: Dalwar Hossain <5631766+dalwar23@users.noreply.github.com>
1 parent 88884ea commit 0234dab

4 files changed

Lines changed: 58 additions & 6 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
name: kumaone python package
3+
4+
on:
5+
push:
6+
branches:
7+
- dev
8+
pull_request:
9+
branches:
10+
- dev
11+
- main
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
python-version: ["pypy3.10", "3.9", "3.10", "3.11", "3.12"]
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
cache: pip
26+
- name: Display Python version
27+
run: python -c "import sys; print(sys.version)"
28+
- name: Upgrade pip
29+
run: python -m pip install --upgrade pip pre-commit hatch
30+
- name: Install dependencies
31+
run: python -m pip install -r requirements.txt -r requirements_dev.txt
32+
- name: Install hooks
33+
run: pre-commit install
34+
- name: Run pre-commit hooks
35+
run: pre-commit run --all-files
36+
- name: Build tf-pre-commit python package
37+
run: hatch build
38+
- name: Install tf-pre-commit package
39+
run: python -m pip install .
40+
- name: Check tf-pre-commit version
41+
run: tf-fmt --version

.pre-commit-hooks.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
- id: terraform-fmt
22
name: Lint terraform files
33
description: Prevent malformed terraform script being commited
4-
entry: fmt
4+
entry: tf-fmt
55
language: python
66
require_serial: true
77
stages: [pre-commit]

pyproject.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Issues = "https://github.com/devopsforhumans/tf-pre-commit/issues"
3232
Source = "https://github.com/devopsforhumans/tf-pre-commit"
3333

3434
[project.scripts]
35-
fmt = "src.tf_pre_commit.fmt:main"
35+
tf-fmt = "src.tf_pre_commit.fmt:main"
3636

3737
[tool.hatch.version]
3838
path = "src/tf_pre_commit/__about__.py"
@@ -48,6 +48,12 @@ exclude = [
4848
"docs/",
4949
]
5050

51+
[tool.hatch.build.targets.wheel]
52+
exclude = [
53+
".github/",
54+
"docs/",
55+
]
56+
5157
[[tool.hatch.envs.all.matrix]]
5258
python = ["3.9", "3.10", "3.11", "3.12"]
5359

src/tf_pre_commit/fmt.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import subprocess
99
from collections.abc import Sequence
1010

11+
from .__about__ import __version__ as app_version
12+
1113
# Source code meta data
1214
__author__ = "Dalwar Hossain"
1315
__email__ = "dalwar23@pm.me"
@@ -77,10 +79,13 @@ def main(argv: Sequence[str] | None = None) -> int:
7779
:return: exit code of terraform linting
7880
"""
7981

80-
parser = argparse.ArgumentParser(description="Run terraform linting")
81-
parser.add_argument("--global-options", help="Global options for terraform")
82-
parser.add_argument("--options", help="Options for terraform fmt")
83-
parser.add_argument("filenames", nargs="*", help="Filenames to run")
82+
parser = argparse.ArgumentParser(description="Run terraform linting with terraform fmt command")
83+
parser.add_argument("-v", "--version", action="version", version=f"v{app_version}")
84+
parser.add_argument(
85+
"--global-options", help="Global options for terraform, try (terraform -help) to see the global options"
86+
)
87+
parser.add_argument("--options", help="Options for terraform fmt, (try terraform fmt -help) to see the options")
88+
parser.add_argument("filenames", nargs="*", help="Filenames to run linting on")
8489
args = parser.parse_args(argv)
8590
exit_code = 0
8691
if args.filenames:

0 commit comments

Comments
 (0)