-
Notifications
You must be signed in to change notification settings - Fork 9
167 lines (144 loc) · 5.54 KB
/
build.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: Build
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
name: Build
runs-on: ubuntu-22.04
if: ${{ github.event.head_commit.message != '[Release] Update Chart.yaml' }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Get merge request latest commit
id: parse-commit
if: ${{ github.event_name == 'pull_request' }}
run: |
msg=$(git show -s --format=%s)
echo "head_commit_message=${msg}" >> $GITHUB_ENV
- name: Setup Go 1.20
uses: actions/setup-go@v2
with:
go-version: "1.20"
- name: Cache Go modules
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-build-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-build-
- name: Build egressd collector go binary amd64
run: go build -ldflags "-s -w -X main.GitCommit=$GITHUB_SHA -X main.GitRef=$GITHUB_REF -X main.Version=${RELEASE_TAG:-commit-$GITHUB_SHA}" -o bin/egressd-amd64 ./cmd/collector
env:
GOOS: linux
GOARCH: amd64
CGO_ENABLED: 0
- name: Build egressd collector go binary arm64
run: go build -ldflags "-s -w -X main.GitCommit=$GITHUB_SHA -X main.GitRef=$GITHUB_REF -X main.Version=${RELEASE_TAG:-commit-$GITHUB_SHA}" -o bin/egressd-arm64 ./cmd/collector
env:
GOOS: linux
GOARCH: arm64
CGO_ENABLED: 0
- name: Build egressd exporter go binary amd64
run: go build -ldflags "-s -w -X main.GitCommit=$GITHUB_SHA -X main.GitRef=$GITHUB_REF -X main.Version=${RELEASE_TAG:-commit-$GITHUB_SHA}" -o bin/egressd-exporter-amd64 ./cmd/exporter
env:
GOOS: linux
GOARCH: amd64
CGO_ENABLED: 0
- name: Build egressd exporter go binary arm64
run: go build -ldflags "-s -w -X main.GitCommit=$GITHUB_SHA -X main.GitRef=$GITHUB_REF -X main.Version=${RELEASE_TAG:-commit-$GITHUB_SHA}" -o bin/egressd-exporter-arm64 ./cmd/exporter
env:
GOOS: linux
GOARCH: arm64
CGO_ENABLED: 0
- name: Run golangci-lint
# You may pin to the exact commit or the version.
# uses: golangci/golangci-lint-action@537aa1903e5d359d0b27dbc19ddd22c5087f3fbc
if: ${{ github.event_name == 'pull_request' && !contains(env.head_commit_message, '#skip-lint') }}
uses: golangci/[email protected]
with:
args: --timeout=5m
skip-pkg-cache: true
skip-build-cache: true
- name: Test
if: ${{ github.event_name == 'pull_request' && !contains(env.head_commit_message, '#skip-test') }}
run: go test -race ./...
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push pr (egressd collector)
if: ${{ github.event_name == 'pull_request' }}
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/arm64,linux/amd64
file: ./Dockerfile
push: ${{ github.event_name == 'pull_request' }}
tags: ghcr.io/castai/egressd/egressd:${{ github.sha }}
- name: Build and push pr (egressd exporter)
if: ${{ github.event_name == 'pull_request' }}
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/arm64,linux/amd64
file: ./Dockerfile.exporter
push: ${{ github.event_name == 'pull_request' }}
tags: ghcr.io/castai/egressd/egressd-exporter:${{ github.sha }}
- name: Build and push main (egressd collector)
if: ${{ github.event_name != 'pull_request' && github.event_name != 'release' }}
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/arm64,linux/amd64
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ghcr.io/castai/egressd/egressd:${{ github.sha }}
- name: Build and push main (egressd exporter)
if: ${{ github.event_name != 'pull_request' && github.event_name != 'release' }}
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/arm64,linux/amd64
file: ./Dockerfile.exporter
push: ${{ github.event_name != 'pull_request' }}
tags: ghcr.io/castai/egressd/egressd-exporter:${{ github.sha }}
e2e:
name: E2E
runs-on: ubuntu-22.04
if: ${{ github.event_name == 'pull_request' }}
needs: build
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Go 1.20
uses: actions/setup-go@v2
with:
go-version: "1.20"
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create kind cluster
uses: helm/[email protected]
with:
config: ./e2e/kind-config.yaml
version: "v0.20.0"
cluster_name: e2e
- name: Run e2e
shell: bash
run: |
KIND_CONTEXT=e2e IMAGE_TAG=${{ github.sha }} ./e2e/run.sh