Skip to content

Commit 73e2929

Browse files
committed
feat: Adding pre-commit hooks
1 parent f53e2a9 commit 73e2929

File tree

2 files changed

+66
-7
lines changed

2 files changed

+66
-7
lines changed

.github/workflows/build-no-proxy.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,13 @@ jobs:
4444
- id: go-cache-paths
4545
run: |
4646
echo "go-build=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
47-
echo "go-mod=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT"
4847
4948
- name: Go Build Cache
5049
uses: actions/cache@v4
5150
with:
5251
path: ${{ steps.go-cache-paths.outputs.go-build }}
5352
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}-${{ matrix.os }}-${{ matrix.arch }}
5453

55-
- name: Go Mod Cache
56-
uses: actions/cache@v4
57-
with:
58-
path: ${{ steps.go-cache-paths.outputs.go-mod }}
59-
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}-${{ matrix.os }}-${{ matrix.arch }}
60-
6154
- name: Build Terragrunt without Go proxy
6255
env:
6356
GOPROXY: direct

.github/workflows/precommit.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Build Without Go Proxy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
10+
jobs:
11+
precommit:
12+
name: Run pre-commit hooks
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Append python to mise.toml
20+
run: |
21+
echo "python = \"3.13.3\"" >> mise.toml
22+
23+
- name: Create default packages file
24+
run: |
25+
# Unlike the Python one below, this one can't be at
26+
# a configurable location, so we always write it to the home dir.
27+
cat <<EOF > ~/.default-go-packages
28+
golang.org/x/tools/cmd/goimports@latest
29+
EOF
30+
31+
echo "$HOME/go/bin" >> "$GITHUB_PATH"
32+
33+
cat <<EOF > .mise-python-default-packages
34+
pre-commit==1.21.0
35+
cfgv==2.0.1
36+
zipp==1.1.0
37+
EOF
38+
39+
echo "MISE_PYTHON_DEFAULT_PACKAGES_FILE=.mise-python-default-packages" >> "$GITHUB_ENV"
40+
41+
- name: Use mise to install dependencies
42+
uses: jdx/mise-action@v2
43+
with:
44+
version: 2025.4.4
45+
env:
46+
# Adding token here to reduce the likelihood of hitting rate limit issues.
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
49+
- id: go-cache-paths
50+
run: |
51+
echo "go-build=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
52+
53+
- name: Go Build Cache
54+
uses: actions/cache@v4
55+
with:
56+
path: ${{ steps.go-cache-paths.outputs.go-build }}
57+
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}-${{ matrix.os }}-${{ matrix.arch }}
58+
59+
- name: Run pre-commit hooks
60+
env:
61+
GOPROXY: direct
62+
GOOS: ${{ matrix.os }}
63+
GOARCH: ${{ matrix.arch }}
64+
run: |
65+
pre-commit install
66+
pre-commit run --all-files

0 commit comments

Comments
 (0)