Skip to content

Commit 8d35b96

Browse files
Install pre-commit for repository
- Ensure we are formatting properly and consistently - Users can in principle choose to opt out of automatic hooks by not installing the tool in the repo - Simplicity of incluing linting into CI - For stability we run them initially in parallel to existing linting scripts - Scalability and futher development is simple as we can use existing solutions instead of implementing our own linting setup
1 parent b4dd889 commit 8d35b96

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

.github/workflows/lint.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,17 @@ jobs:
7070
terraform_version: 1.10.5
7171
- name: Check formatting
7272
run: terraform fmt -check -recursive
73+
74+
pre-commit:
75+
name: Pre-commit
76+
runs-on: ubuntu-latest
77+
78+
steps:
79+
- uses: actions/checkout@v4
80+
- uses: hashicorp/setup-terraform@v3
81+
with:
82+
terraform_version: 1.10.5
83+
- uses: actions/setup-python@v5
84+
with:
85+
python-version-file: .tool-versions
86+
- uses: pre-commit/action@v3.0.1

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
repos:
2+
- repo: https://github.com/antonbabenko/pre-commit-terraform
3+
rev: v1.99.0
4+
hooks:
5+
- id: terraform_fmt
6+
files: \.(tf|tfvars|hcl)$

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ aws-copilot 1.34.0
55
awscli 2.13.31
66
terraform 1.10.5
77
tflint 0.55.1
8+
python 3.13.2

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,14 +309,34 @@ brew install libyaml
309309
# Dependencies for postgres
310310
brew install gcc readline zlib curl ossp-uuid icu4c pkg-config
311311

312+
# Install pre-commit tool
313+
brew install pre-commit
314+
312315
# Env vars for postgres
313316
export OPENSSL_PATH=$(brew --prefix openssl)
314317
export CMAKE_PREFIX_PATH=$(brew --prefix icu4c)
315318
export PATH="$OPENSSL_PATH/bin:$CMAKE_PREFIX_PATH/bin:$PATH"
316319
export LDFLAGS="-L$OPENSSL_PATH/lib $LDFLAGS"
317320
export CPPFLAGS="-I$OPENSSL_PATH/include $CPPFLAGS"
318321
export PKG_CONFIG_PATH="$CMAKE_PREFIX_PATH/lib/pkgconfig"
322+
```
323+
324+
For ubuntu run
325+
326+
```shell
327+
apt install curl libyaml-dev libreadline-dev zlib1g-dev \
328+
libssl-dev libicu-dev cmake pkg-config uuid-dev flex bison \
329+
pre-commit
330+
331+
export OPENSSL_PATH="/usr"
332+
export CMAKE_PREFIX_PATH="/usr"
333+
export PATH="$OPENSSL_PATH/bin:$CMAKE_PREFIX_PATH/bin:$PATH"
334+
export LDFLAGS="-L$OPENSSL_PATH/lib $LDFLAGS"
335+
export CPPFLAGS="-I$OPENSSL_PATH/include $CPPFLAGS"
336+
export PKG_CONFIG_PATH="$CMAKE_PREFIX_PATH/lib/pkgconfig"
337+
```
319338

339+
```shell
320340
# Version manager
321341
brew install mise
322342

@@ -329,6 +349,13 @@ Then to install the required tools (or update, following a change to
329349

330350
```shell
331351
mise install
352+
mise exec python -- pip install pre-commit
353+
```
354+
355+
Next ensure you have the pre-commit hook installed by running
356+
357+
```shell
358+
pre-commit install
332359
```
333360

334361
After installing Postgres via `mise`, run the database in the background, and

0 commit comments

Comments
 (0)