-
Notifications
You must be signed in to change notification settings - Fork 107
193 lines (162 loc) · 5.3 KB
/
router-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
name: Router CI
on:
pull_request:
paths:
- "composition-go/**/*"
- "demo/**/*"
- "router/**/*"
- "router-tests/**/*"
- "connect/**/*"
- ".github/workflows/router-ci.yaml"
concurrency:
group: ${{github.workflow}}-${{github.head_ref}}
cancel-in-progress: true
env:
CI: true
ROUTER_REGISTRATION: false
# Both jobs need to kept in sync. We need to distinguish between forks and people with write access to the repository.
jobs:
# Runs for forks without access to repository secrets
build_test_fork:
if: github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
timeout-minutes: 15
services:
redis:
# Docker Hub image
image: redis:7
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
# The go install / version instructions are inside the Makefile, so we need to cache the Makefile.
key: ${{ runner.os }}-go-${{ hashFiles('router/go.sum') }}-makefile-${{ hashFiles('Makefile') }}
restore-keys: |
${{ runner.os }}-go-
- uses: ./.github/actions/go
with:
cache-dependency-path: router/go.sum
- uses: ./.github/actions/go-mod-tidy
with:
working-directory: ./router
- name: Install tools
run: make setup-build-tools
- name: Generate code
run: make generate-go
- name: Check if git is not dirty after generating files
run: git diff --no-ext-diff --exit-code
- name: Install dependencies
working-directory: ./router
run: go mod download
- name: Run linters on router-tests
uses: ./.github/actions/go-linter
with:
working-directory: ./router-tests
- name: Run linters on router
uses: ./.github/actions/go-linter
with:
working-directory: ./router
- name: Test
working-directory: ./router
run: make test
- name: Run Integration tests
working-directory: ./router-tests
run: make test
- name: Build
working-directory: ./router
run: make build
# Runs for people with write access to the repository
# that have access to the secrets
build_test:
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
timeout-minutes: 15
services:
redis:
# Docker Hub image
image: redis:7
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
credentials:
username: ${{secrets.DOCKER_USERNAME}}
password: ${{secrets.DOCKER_PASSWORD}}
ports:
- 6379:6379
steps:
- uses: actions/checkout@v4
- name: Log in to Docker Container registry (With write access)
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{secrets.DOCKER_USERNAME}}
password: ${{secrets.DOCKER_PASSWORD}}
- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
# The go install / version instructions are inside the Makefile, so we need to cache the Makefile.
key: ${{ runner.os }}-go-${{ hashFiles('router/go.sum') }}-makefile-${{ hashFiles('Makefile') }}
restore-keys: |
${{ runner.os }}-go-
- uses: ./.github/actions/go
with:
cache-dependency-path: router/go.sum
- uses: ./.github/actions/go-mod-tidy
with:
working-directory: ./router
- name: Install tools
run: make setup-build-tools
- name: Generate code
run: make generate-go
- name: Check if git is not dirty after generating files
run: git diff --no-ext-diff --exit-code
- name: Install dependencies
working-directory: ./router
run: go mod download
- name: Run linters on router-tests
uses: ./.github/actions/go-linter
with:
working-directory: ./router-tests
- name: Run linters on router
uses: ./.github/actions/go-linter
with:
working-directory: ./router
- name: Test
working-directory: ./router
run: make test
- name: Run Integration tests
working-directory: ./router-tests
run: make test
- name: Build
working-directory: ./router
run: make build
build_push_image:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/build-push-image
with:
docker_username: ${{secrets.DOCKER_USERNAME}}
docker_password: ${{secrets.DOCKER_PASSWORD}}
docker_context: router
dockerfile: router/Dockerfile
token: ${{secrets.GITHUB_TOKEN}}
image_name: router
image_description: "Cosmo Router"