Skip to content

Commit 12dc28d

Browse files
committed
try new pre-commit
1 parent 0e74526 commit 12dc28d

File tree

14 files changed

+111
-732
lines changed

14 files changed

+111
-732
lines changed

.githooks/detect-ethereum-keys

Lines changed: 0 additions & 18 deletions
This file was deleted.

.githooks/detect-rpc-urls

Lines changed: 0 additions & 17 deletions
This file was deleted.

.githooks/go-lint

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,2 @@
11
#!/bin/bash
2-
3-
# Find all 'go.mod' files, get their directories, and run 'go mod tidy'
4-
find "./" -type f -name 'go.mod' -print0 | while IFS= read -r -d $'\0' file; do
5-
directory=$(dirname "$file")
6-
cd "$directory" || exit 1
7-
8-
# Run linter and capture exit status
9-
set +e
10-
golangci-lint run -v
11-
linting_result=$?
12-
set -e
13-
14-
# Check linting result
15-
if [[ $linting_result -ne 0 ]]; then
16-
echo -e "Executing linters in $directory... \e[31mNOK!\e[0m\n"
17-
echo -e "Run \`cd $directory && golangci-lint run --fix -v\` and fix the issues\n"
18-
exit 1
19-
else
20-
echo -e "Executing linters in $directory... \e[32mOK!\e[0m\n"
21-
fi
22-
cd - || exit 1
23-
done
2+
devbox run lint

.githooks/go-mod-local-replace

Lines changed: 0 additions & 14 deletions
This file was deleted.

.githooks/go-mod-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ find "./" -type f -name 'go.mod' -print0 | while IFS= read -r -d $'\0' file; do
1010
go mod tidy
1111
cd - || exit 1
1212
done
13+
1314
# pre-commit stashes changes before running the hooks so we can use git to check for changes here
1415
# Run git diff and capture output
1516
output=$(git diff --stat)

.githooks/go-test-build

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
set -e
44

5-
# Find all 'go.mod' files, get their directories, and run an empty 'go test' in them to compile the tests.
6-
find "./" -type f -name 'go.mod' -print0 | while IFS= read -r -d $'\0' file; do
5+
# Find all 'go.mod' files, excluding the 'seth' directory, get their directories, and run an empty 'go test' in them to compile the tests.
6+
# Seth is excluded because it can't be tested like this, env vars are required and setup
7+
find "./" -path "./seth" -prune -o -type f -name 'go.mod' -print0 | while IFS= read -r -d $'\0' file; do
78
dir=$(dirname "$file")
89
echo "Executing cd \"$dir\" && go test -run=^# ./..."
910
cd "$dir"
1011
go test -run=^# ./...
1112
cd -
12-
done
13+
done

.githooks/run-unit-tests

Lines changed: 0 additions & 5 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 7 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -4,69 +4,22 @@ repos:
44
- repo: local
55
hooks:
66
- id: go-lint
7-
name: Check go lint
7+
name: Check Go Lint
88
entry: ./.githooks/go-lint
99
language: script
1010
pass_filenames: false
11-
- id: go-mod-local-replace
12-
name: Check for local replaces in go.mod
13-
entry: ./.githooks/go-mod-local-replace
14-
language: script
15-
files: 'go\.mod$'
16-
- id: detect-etherum-keys
17-
name: Detect ethereum keys
18-
entry: ./.githooks/detect-ethereum-keys
19-
language: script
20-
- id: detect-rpc-urls
21-
name: Check for RPC URLs
22-
entry: ./.githooks/detect-rpc-urls
23-
language: script
24-
- id: detect-typos
25-
name: Check for typos
26-
entry: ./.githooks/typos
27-
language: script
2811
- id: go-mod-tidy
29-
name: Check go mod tidy
12+
name: Check Go Mod Tidy
3013
entry: ./.githooks/go-mod-tidy
3114
language: script
3215
pass_filenames: false
33-
stages: [pre-push]
3416
- id: go-test-build
35-
name: Check go test build
36-
entry: ./.githooks/go-test-build
17+
name: Build Go Tests
18+
entry: ./.githooks/go-mod-tidy
3719
language: script
3820
pass_filenames: false
39-
stages: [pre-push]
40-
- id: run-unit-tests
41-
name: Run unit tests
42-
entry: ./.githooks/run-unit-tests
21+
- id: typos
22+
name: Typos
23+
entry: ./.githooks/typos
4324
language: script
4425
pass_filenames: false
45-
stages: [pre-push]
46-
- repo: https://github.com/pre-commit/pre-commit-hooks
47-
rev: 2c9f875913ee60ca25ce70243dc24d5b6415598c # v4.6.0
48-
hooks:
49-
- id: detect-private-key
50-
- id: detect-aws-credentials
51-
args: [--allow-missing-credentials]
52-
- id: check-added-large-files
53-
- id: check-json
54-
- id: check-toml
55-
- id: end-of-file-fixer
56-
- id: check-case-conflict
57-
- id: check-shebang-scripts-are-executable
58-
- id: check-merge-conflict
59-
- id: trailing-whitespace
60-
- repo: https://github.com/gruntwork-io/pre-commit
61-
rev: e9250bd69bb312d55364213ff5ff037a09be55d9 # v0.1.12
62-
hooks:
63-
# TODO: change to using the same lint a in CI
64-
# - name: Check Helm charts
65-
# id: helmlint
66-
- name: Check shell scripts
67-
id: shellcheck
68-
- repo: https://github.com/pre-commit/mirrors-prettier
69-
rev: bc48c541add1551be726f23c4294c773442341cb # v2.3.2
70-
hooks:
71-
- name: Prettier
72-
id: prettier

framework/examples/myproject/chaos/chaos_k8s_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ package chaos
22

33
import (
44
"context"
5-
f "github.com/smartcontractkit/chainlink-testing-framework/framework"
6-
gf "github.com/smartcontractkit/chainlink-testing-framework/framework/grafana"
7-
"github.com/smartcontractkit/chainlink-testing-framework/framework/rpc"
8-
"github.com/smartcontractkit/chainlink-testing-framework/havoc"
95
"math/big"
106
"os"
117
"testing"
128
"time"
139

10+
f "github.com/smartcontractkit/chainlink-testing-framework/framework"
11+
gf "github.com/smartcontractkit/chainlink-testing-framework/framework/grafana"
12+
"github.com/smartcontractkit/chainlink-testing-framework/framework/rpc"
13+
"github.com/smartcontractkit/chainlink-testing-framework/havoc"
14+
1415
"github.com/stretchr/testify/require"
1516
)
1617

0 commit comments

Comments
 (0)