-
Notifications
You must be signed in to change notification settings - Fork 9
193 lines (178 loc) · 5.96 KB
/
build.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
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
name: Go
on:
push:
branches: [ main ]
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
pull_request:
branches: [ main ]
env:
GO_VERSION: 1.18
jobs:
# run change detection
changes:
runs-on: ubuntu-latest
# Set job outputs to values from filter step
outputs:
customer: ${{ steps.filter.outputs.customer }}
driver: ${{ steps.filter.outputs.driver }}
frontend: ${{ steps.filter.outputs.frontend }}
route: ${{ steps.filter.outputs.route }}
steps:
# The paths-filter action requires a checkout step for push events.
- if: ${{ github.event_name == 'push' }}
uses: actions/checkout@v2
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
customer:
- 'services/customer/**'
- 'cmd/customer.go'
- 'pkg/**'
driver:
- 'services/driver/**'
- 'cmd/driver.go'
- 'pkg/**'
frontend:
- 'services/frontend/**'
- 'cmd/frontend.go'
- 'pkg/**'
route:
- 'services/route/**'
- 'cmd/route.go'
- 'pkg/**'
build:
runs-on: ubuntu-latest
needs: [ changes ]
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
steps:
- uses: actions/checkout@v2
with:
# Goreleaser needs to see git history and tags.
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Go Mod Cache
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-mod-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ env.GO_VERSION }}-mod-
- name: Go Build Cache
uses: actions/cache@v2
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-build-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ env.GO_VERSION }}-build-
- name: Setup qemu
uses: docker/setup-qemu-action@v1
- name: Docker Login
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Tag
env:
GIT_SHA: ${{ github.sha }}
run: |
# Make a fake tag so goreleaser will actually push images.
git tag v0.0.1-snapshot.${GIT_SHA}
- name: GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GIT_SHA: ${{ github.sha }}
run_integration_tests:
if: ${{ github.event_name == 'pull_request' && needs.changes.outputs.route == 'true' }}
runs-on: ubuntu-latest
needs: [ build, changes ]
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Go Mod Cache
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-mod-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ env.GO_VERSION }}-mod-
- name: Go Build Cache
uses: actions/cache@v2
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-build-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ env.GO_VERSION }}-build-
- name: Run Integration test on Route service
env:
SIGNADOT_API_KEY: ${{ secrets.SIGNADOT_API_KEY }}
ROUTE_SERVICE_IMAGE: signadot/hotrod:${{ github.sha }}
run: |
echo "Image name: $ROUTE_SERVICE_IMAGE"
cd test/api-test/
SIGNADOT_API_KEY=${{ secrets.SIGNADOT_API_KEY }} gradle test
- name: Publish Route Service Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
if: always()
with:
comment_title: Route Service Test Result
check_name: Route Service Test Result
comment_mode: "create new"
files: test/api-test/build/test-results/**/*.xml
cli-sandbox:
runs-on: ubuntu-latest
needs: [ build, changes ]
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Create Sandbox
env:
SIGNADOT_ORG: signadot
SIGNADOT_API_KEY: ${{ secrets.SIGNADOT_API_KEY }}
IMAGE_TAG: ${{ github.sha }}
run: |
# run the cli
# setting the gitsha to a short version to respect the name
# limit (30 chars)
docker run -i \
-e SIGNADOT_ORG=${SIGNADOT_ORG} \
-e SIGNADOT_API_KEY=${SIGNADOT_API_KEY} \
signadot/signadot-cli \
/signadot sandbox apply \
--set image=signadot/hotrod:${IMAGE_TAG} \
--set git-short-commit=${IMAGE_TAG:0:6} \
-f - \
-o yaml \
< ${GITHUB_WORKSPACE}/.signadot/frontend-template.yaml \
> ${GITHUB_WORKSPACE}/.signadot/frontend.yaml
- name: Test Sandbox
run: |
go install github.com/mikefarah/yq/v4@latest
endpoint=$(yq '.endpoints[0].url' ${GITHUB_WORKSPACE}/.signadot/frontend.yaml)
curl -H "signadot-api-key: ${{ secrets.SIGNADOT_API_KEY }}" $endpoint
- name: Delete Sandbox
env:
SIGNADOT_ORG: signadot
SIGNADOT_API_KEY: ${{ secrets.SIGNADOT_API_KEY }}
run: |
docker run -i \
-e SIGNADOT_ORG=${SIGNADOT_ORG} \
-e SIGNADOT_API_KEY=${SIGNADOT_API_KEY} \
signadot/signadot-cli \
/signadot sandbox apply \
-f - \
< ${GITHUB_WORKSPACE}/.signadot/frontend.yaml