-
Notifications
You must be signed in to change notification settings - Fork 12
134 lines (114 loc) · 4.1 KB
/
ci.yml
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
124
125
126
127
128
129
130
131
132
133
134
name: CI
on:
push:
pull_request:
permissions:
contents: read
jobs:
go-lint:
if: github.event_name == 'push' || github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id
name: Go Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
id: setup-go
uses: ./.github/actions/setup-go
with:
cache-prefix: go-lint
- name: Compute tools cache info
id: tools-cache-info
run: |
echo path=$(go env GOPATH)/bin >> $GITHUB_OUTPUT
echo make-hash=$(make -n install-tools | sha256sum | cut -d' ' -f1) >> $GITHUB_OUTPUT
- name: Setup tools cache
uses: actions/cache@v4
id: tools-cache
with:
path: ${{ steps.tools-cache-info.outputs.path }}
key: tools-go-${{ steps.setup-go.outputs.go-version }}-make-${{ steps.tools-cache-info.outputs.make-hash }}
- name: Install tools
if: steps.tools-cache.outputs.cache-hit != 'true'
env:
GOCACHE: /tmp/tools/go-build
GOMODCACHE: /tmp/tools/go-mod
run: make install-tools
- name: Check formatting
run: gofmt -l . | wc -l | xargs -I {} test {} -eq 0 || (gofmt -l . && exit 1)
- name: Check module files
run: |
go mod tidy
modified=$(git ls-files --modified -- go.{mod,sum})
if [ -n "$modified" ]; then
for file in $modified; do
echo "::error file=$file::$file is not up to date (hint: run \"go mod tidy\" to fix this)"
done
exit 1
fi
- name: Compute golangci-lint cache info
id: golangci-lint-cache-info
run: |
version_regex=" v([0-9]+\.[0-9]+\.[0-9]+) "
[[ "$(golangci-lint version)" =~ $version_regex ]]
echo version=${BASH_REMATCH[1]} >> $GITHUB_OUTPUT
cache_regex='Dir: (.*)\n'
[[ "$(golangci-lint cache status)" =~ $cache_regex ]]
echo path=${BASH_REMATCH[1]} >> $GITHUB_OUTPUT
- name: Setup golangci-lint cache
uses: actions/cache@v4
with:
path: ${{ steps.golangci-lint-cache-info.outputs.path }}
key: golangci-lint-${{ steps.golangci-lint-cache-info.outputs.version }}-go-${{ steps.setup-go.outputs.go-version }}-mod-${{ hashFiles('go.sum') }}
- name: Run golangci-lint
run: make go-lint
build:
if: github.event_name == 'push' || github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id
name: Build (${{ matrix.os }}/${{ matrix.arch }})
strategy:
matrix:
os: [ linux ]
arch: [ amd64, arm64 ]
include:
- os: linux
runner: ubuntu-latest
fail-fast: true
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: ./.github/actions/setup-go
with:
cache-prefix: build-${{ matrix.os }}-${{ matrix.arch }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker metadata
id: docker-metadata
uses: docker/metadata-action@v5
with:
images: yunikorn-history-server
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=edge
- name: Build software distribution
run: make dist
env:
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
DOCKER_METADATA: ${{ steps.docker-metadata.outputs.json }}
DOCKER_OUTPUT: type=oci,dest=yunikorn-history-server-oci-${{ matrix.arch }}.tar
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: yunikorn-history-server-archives-${{ matrix.os }}-${{ matrix.arch }}
path: build/*
- name: Upload Docker artifact
uses: actions/upload-artifact@v4
with:
name: yunikorn-history-server-oci-images-${{ matrix.arch }}
path: yunikorn-history-server-oci-*.tar