forked from jozu-ai/kitops
-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (58 loc) · 1.76 KB
/
pr.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: Validate PRs
on:
pull_request:
branches: [ main ]
jobs:
go:
name: Check sources
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Check go.mod
run: |
go mod tidy
if ! git diff --quiet; then
echo "Go modules need tidying (go mod tidy)"
exit 1
fi
- name: Check format
run: |
go fmt ./...
if ! git diff --quiet; then
echo "Files are not formatted (go fmt ./...)"
exit 1
fi
- name: Check license headers
run: |
go install github.com/google/addlicense@latest
if ! addlicense --check -s -l apache -c "The KitOps Authors." $(find . -name '*.go'); then
echo "License headers missing from Go files (see above)."
echo "Install addlicense via 'go install github.com/google/addlicense@latest'"
echo "And run 'addlicense -s -l apache -c "The KitOps Authors." $(find . -name '*.go')"
exit 1
fi
- name: Check build
run: |
if ! go build -o kit; then
echo "Project does not build"
exit 1
fi
- name: Run tests
run: |
if ! go test ./... -v; then
echo "Project tests failed"
exit 1
fi
- name: Check for trailing whitespace
run: |
files=$(grep -E -lI --exclude '*.svg' --exclude 'docs/*' " +$" $(git ls-files) || true)
if [ ! -z $files ]; then
echo "Trailing whitespace in files:"
echo "$files"
exit 1
fi