-
Notifications
You must be signed in to change notification settings - Fork 24
203 lines (196 loc) · 6.69 KB
/
ci.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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v3
with:
go-version: "1.21"
- uses: golangci/golangci-lint-action@v3
with:
version: v1.55
- run: make test
integration:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
k8s_version:
- 1.24.13 # current version at GKE stable channel (https://cloud.google.com/kubernetes-engine/docs/release-notes#current_versions)
- 1.25.8 # current version at GKE regular channel (https://cloud.google.com/kubernetes-engine/docs/release-notes#current_versions)
steps:
- uses: actions/checkout@master
- name: Running up Kubernetes (using Minikube)
uses: medyagh/setup-minikube@master
with:
kubernetes-version: v${{ matrix.k8s_version }}
- uses: azure/setup-helm@v1
with:
version: v3.7.0
- uses: actions/setup-go@v3
with:
go-version: "1.21"
- uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-goleak-${{ hashFiles('**/go.sum') }}-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-goleak-${{ hashFiles('**/go.sum') }}-
${{ runner.os }}-goleak-
- name: Run integration tests
env:
GOPATH: /tmp/go
INSTALL_CERT_MANAGER: "true"
CLUSTER_PROVIDER: minikube
DEBUG: "true"
run: |
./scripts/localkube-integration.sh
rpaas-api-docker-image:
name: "Publish rpaas-api image on dockerhub"
needs:
- test
- integration
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- uses: Surgo/docker-smart-tag-action@v1
id: smarttag
with:
docker_image: tsuru/rpaas-api
default_branch: main
tag_with_sha: "true"
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- uses: docker/build-push-action@v5
with:
file: ./Dockerfile.api
push: true
tags: ${{ steps.smarttag.outputs.tag }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
platforms: linux/amd64,linux/arm64
rpaas-operator-docker-image:
name: "Publish rpaas-operator image on dockerhub"
needs:
- test
- integration
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- uses: Surgo/docker-smart-tag-action@v1
id: smarttag
with:
docker_image: tsuru/rpaas-operator
default_branch: main
tag_with_sha: "true"
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- uses: docker/build-push-action@v5
with:
file: ./Dockerfile.operator
push: true
tags: ${{ steps.smarttag.outputs.tag }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
platforms: linux/amd64,linux/arm64
rpaas-purger-docker-image:
name: "Publish rpaas-purger image on dockerhub"
needs:
- test
- integration
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- uses: Surgo/docker-smart-tag-action@v1
id: smarttag
with:
docker_image: tsuru/rpaas-purger
default_branch: main
tag_with_sha: "true"
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- uses: docker/build-push-action@v5
with:
file: ./Dockerfile.purger
push: true
tags: ${{ steps.smarttag.outputs.tag }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
platforms: linux/amd64,linux/arm64
release:
name: "Release artifacts on github"
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/')
needs:
- test
- integration
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: git fetch --prune --unshallow
- name: Set VERSION env
run: echo "VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV
- name: generate manifest.json
env:
VERSION: ${{ env.VERSION }}
run: |
cat >manifest.json <<EOF
{
"SchemaVersion": "1.0",
"Metadata": {
"Name": "rpaasv2",
"Version": "${VERSION}"
},
"URLPerPlatform": {
"darwin/arm64": "https://github.com/tsuru/rpaas-operator/releases/download/v${VERSION}/rpaasv2_${VERSION}_Darwin_arm64.tar.gz",
"darwin/amd64": "https://github.com/tsuru/rpaas-operator/releases/download/v${VERSION}/rpaasv2_${VERSION}_Darwin_x86_64.tar.gz",
"linux/arm64": "https://github.com/tsuru/rpaas-operator/releases/download/v${VERSION}/rpaasv2_${VERSION}_Linux_arm64.tar.gz",
"linux/386": "https://github.com/tsuru/rpaas-operator/releases/download/v${VERSION}/rpaasv2_${VERSION}_Linux_i386.tar.gz",
"linux/amd64": "https://github.com/tsuru/rpaas-operator/releases/download/v${VERSION}/rpaasv2_${VERSION}_Linux_x86_64.tar.gz",
"windows/386": "https://github.com/tsuru/rpaas-operator/releases/download/v${VERSION}/rpaasv2_${VERSION}_Windows_i386.zip",
"windows/amd64": "https://github.com/tsuru/rpaas-operator/releases/download/v${VERSION}/rpaasv2_${VERSION}_Windows_x86_64.zip"
}
}
EOF
- uses: actions/setup-go@v3
with:
go-version: "1.21"
- uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}