-
Notifications
You must be signed in to change notification settings - Fork 109
213 lines (180 loc) · 5.95 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
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
permissions:
contents: read # for actions/checkout to fetch code
pull-requests: write # required for adding pull request comments
packages: write # required for publishing packages
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: ./.github/actions/go
with:
cache-dependency-path: |
router/go.sum
router-tests/go.sum
demo/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: ./.github/actions/go
with:
cache-dependency-path: |
router/go.sum
router-tests/go.sum
demo/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
image_scan:
if: github.event.pull_request.head.repo.full_name == github.repository
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"
image_platforms: 'linux/amd64'
load_Image: 'true'
push: 'false'
- uses: ./.github/actions/image-scan
with:
name: "Router"
github_token: ${{secrets.GITHUB_TOKEN}}
image_ref: 'ghcr.io/wundergraph/cosmo/router:sha-${{ github.sha }}'
build_push_image:
# This is a limitation of GitHub. Only organization members can push to GitHub Container Registry
# For now, we will disable the push to the GitHub Container Registry for external contributors
if: github.event.pull_request.head.repo.full_name == github.repository
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"