forked from banzaicloud/koperator
-
Notifications
You must be signed in to change notification settings - Fork 17
124 lines (103 loc) · 3.4 KB
/
ci.yml
File metadata and controls
124 lines (103 loc) · 3.4 KB
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
114
115
116
117
118
119
120
121
122
123
name: CI
on:
push:
branches:
- master
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check-integrity:
name: Check integrity
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
- name: Check Go modules dependency file integrity
run: |
find . -type f -name go.mod | while read module_file; do
module=$(dirname "$module_file")
pushd "$module" > /dev/null
go mod tidy
if [ "$(git status --porcelain)" != "" ]; then
printf >&2 '\n`go mod tidy` in module `%s` results in a dirty state, Go mod files are not in sync with the source code files, differences:\n\n%s\n\n' "$module" "$(git diff)"
git reset --hard
exit 1
fi
popd > /dev/null
done
- name: Check generated file integrity
run: |
make generate manifests
if [ "$(git status --porcelain)" != "" ]; then
printf >&2 '\ngenerating code files and manifests results in a dirty state, generated files are not in sync with the source code files, differences:\n\n%s\n\n' "$(git diff)"
git reset --hard
exit 1
fi
build:
name: Build
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
- name: Clean Go module and build cache
run: |
# Clean any existing Go module and build cache to avoid conflicts
sudo rm -rf ~/go/pkg/mod || true
sudo rm -rf ~/.cache/go-build || true
mkdir -p ~/go/pkg/mod
mkdir -p ~/.cache/go-build
# Ensure proper permissions
chmod -R 755 ~/go/pkg/mod
chmod -R 755 ~/.cache/go-build
- name: License cache
uses: actions/cache/restore@v5
with:
path: .licensei.cache
key: ci-license-v1-${{ hashFiles('**/go.sum') }}
restore-keys: |
ci-license-v1-
license-v1-
enableCrossOsArchive: false
fail-on-cache-miss: false
- name: Download license information for dependencies
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: make license-cache
- name: Vendor dependencies to retrieve licenses locally
# Vendor deps before running https://github.com/goph/licensei
# to avoid false-positive when modules github repo could not be determined
run: go mod vendor
- name: Check licenses
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: make license-check
- name: Check license header
env:
GOTEMPLATE_DEBUG: true
GOTEMPLATE_INTERNAL_LOG_LEVEL: debug
GOTEMPLATE_TEMPLATE_LOG_LEVEL: debug
run: make license-header-check
- name: Build
run: |
make generate
- name: Lint
run: |
make lint
- name: Run tests
run: |
make test
- name: Save license cache
uses: actions/cache/save@v5
with:
path: .licensei.cache
key: ci-license-v1-${{ hashFiles('**/go.sum') }}