-
Notifications
You must be signed in to change notification settings - Fork 22
55 lines (50 loc) · 1.85 KB
/
check_diff_action.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
name: Check for diff after go mod tidy and generated targets
on:
pull_request: {}
workflow_call:
jobs:
diff-check-manifests:
name: Check for diff
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: '${{ github.workspace }}/go.mod'
cache: false
- name: Get go environment for use with cache
run: |
echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV
echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV
# This step will only reuse the go mod and build cache from main made during the Build,
# see lint_and_test.yaml => "test" Job
# This means it never caches by itself and PRs cannot cause cache pollution / thrashing
# This is because we have huge storage requirements for our cache because of the mass of dependencies
- name: Restore / Reuse Cache from central build
id: cache-golang-restore
uses: actions/cache/restore@v4 # Only Restore, not build another cache (too big)
with:
path: |
${{ env.go_cache }}
${{ env.go_modcache }}
key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }}
restore-keys: |
${{ env.cache_name }}-${{ runner.os }}-go-
env:
cache_name: run-tests-go-cache # needs to be the same key in the end as in the build step
- name: Make generate and deepcopy
run: |
make -f hack/Makefile mdref && make -f hack/Makefile go-bindata && make generate && make generate-deepcopy
- name: go mod tidy
run: |
go mod tidy
- name: Check for diff
run: |
gitStatus="$(git status --porcelain)"
if [[ -z "${gitStatus}" ]]; then
exit 0
fi
echo "${gitStatus}"
exit 1