-
Notifications
You must be signed in to change notification settings - Fork 51
113 lines (98 loc) · 3.21 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: Validate PRs
on:
pull_request:
branches: [ main ]
jobs:
go:
name: Check sources
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version-file: 'go.mod'
- name: Check go.mod
shell: bash
run: |
go mod tidy
if ! git diff --quiet; then
echo "Go modules need tidying (go mod tidy)"
exit 1
fi
- name: Check format
shell: bash
run: |
go fmt ./...
if ! git diff --quiet; then
echo "Files are not formatted (go fmt ./...)"
exit 1
fi
- name: Check license headers
shell: bash
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: Install Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version-file: './frontend/dev-mode/.nvmrc'
- name: Install pnpm
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
version: 8.0.0
- name: Generate embeds
run: |
go generate ./...
- name: Check build
shell: bash
run: |
if ! go build -o kit; then
echo "Project does not build"
exit 1
fi
- name: Run tests
shell: bash
run: |
if ! go test ./... -v; then
echo "Project tests failed"
exit 1
fi
- name: Test Vitepress includes
shell: bash
run: |
grep -rnw '@include' --exclude-dir docs/node_modules docs | while read -r line; do
file="${line%%:*}"
include="${line##*@include: }"
include="${include%%-->}"
expected="$(dirname "$file")/$include"
if [ ! -f "$expected" ]; then
echo "Broken include in $file: path $expected does exist"
exit 1
fi
done
- name: Check for trailing whitespace
shell: bash
run: |
files=$(grep -E -lI --exclude '*.svg' --exclude 'docs/*' --exclude 'frontend/*' " +$" $(git ls-files) || true)
if [ ! -z $files ]; then
echo "Trailing whitespace in files:"
echo "$files"
exit 1
fi
- name: Upload build artifacts
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: pr-artifacts-${{ matrix.os }}
retention-days: 3
path: |
./kit*