-
Notifications
You must be signed in to change notification settings - Fork 12
210 lines (184 loc) · 5.92 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
204
205
206
207
208
209
210
#
# Copyright IBM Corporation 2020,2023
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
name: Continuous Integration
on:
push:
branches: [ main ]
tags: [ '*' ]
pull_request:
branches: [ main ]
types: [ opened, synchronize, reopened ]
schedule:
- cron: '30 11 * * 1,3,5'
permissions: read-all
jobs:
ci-local:
runs-on: ubuntu-22.04
env:
KAR_JAVA_SDK_OVERRIDE: -Dversion.kar-java-sdk=99.99.99-SNAPSHOT
steps:
# Checkout repo
- name: Checkout repo
uses: actions/checkout@v4
# Download pre-reqs
- name: Install k8s clis
run: ./ci/setup.sh
# Configure language versions
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'core/go.mod'
cache-dependency-path: 'core/go.sum'
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
- name: Setup JavaScript
uses: actions/setup-node@v4
with:
node-version: 18.x
# Deploy Kafka and Redis (add a sleep to because docker compose doesn't have readiness probes)
- name: Start Kafka and Redis
run: |
./scripts/docker-compose-start.sh
sleep 5
# Build KAR locally
- name: Make KAR cli
run: make cli
- name: Build Java SDK
working-directory: sdk-java
run: |
mvn --batch-mode versions:set -DnewVersion=99.99.99-SNAPSHOT
mvn --batch-mode install
- name: Setup yalc to use local JavaScript SDK
run: |
npm i -g yalc
./scripts/setup-yalc.sh
# Run tests
- name: rpclib unit tests
run: |
. ./scripts/kar-env-local.sh
make check-rpc
shell: bash
- name: Run JavaScript tests
run: ./ci/testJSLocal.sh
- name: Run Java tests
run: ./ci/testJavaLocal.sh
ci-local-released:
runs-on: ubuntu-22.04
steps:
# Checkout repo
- name: Checkout repo
uses: actions/checkout@v4
# Download pre-reqs
- name: Install k8s clis
run: ./ci/setup.sh
# Configure language versions
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'core/go.mod'
cache-dependency-path: 'core/go.sum'
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
- name: Setup JavaScript
uses: actions/setup-node@v4
with:
node-version: 16.x
# Deploy Kafka and Redis (add a sleep to because docker compose doesn't have readiness probes)
- name: Start Kafka and Redis
run: |
./scripts/docker-compose-start.sh
sleep 5
# Build KAR locally
- name: Make KAR cli
run: make cli
# Run tests
- name: Run JavaScript tests
run: ./ci/testJSLocal.sh
- name: Run Java tests
run: ./ci/testJavaLocal.sh
ci-in-cluster:
runs-on: ubuntu-22.04
steps:
# Checkout repo
- name: Checkout repo
uses: actions/checkout@v4
# Download pre-reqs
- name: Install k8s clis
run: ./ci/setup.sh
# Configure language versions
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'core/go.mod'
cache-dependency-path: 'core/go.sum'
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
- name: Setup JavaScript
uses: actions/setup-node@v4
with:
node-version: 18.x
# Start kind (need registry running to push images)
- name: Start kind
run: ./scripts/kind-start.sh
# Build KAR locally
- name: Make KAR cli
run: make cli
- name: Make Java images
run: make docker-java
- name: Make JavaScript images
run: make docker-js
- name: Make Python images
run: make docker-python
# Delopy KAR on kind
- name: Deploy KAR
run: ./scripts/kar-k8s-deploy.sh
# Run in cluster tests
- name: Run Tests
run: ./ci/testInCluster.sh
push-images:
needs: [ci-local, ci-local-released, ci-in-cluster]
runs-on: ubuntu-22.04
if: github.repository == 'IBM/kar'
env:
PUSH_LATEST: ${{ (github.event_name == 'push' || github.event_name == 'schedule') && github.ref == 'refs/heads/main' }}
PUSH_RELEASE: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
steps:
# Checkout repo
- name: Checkout repo
if: ${{ env.PUSH_LATEST == 'true' || env.PUSH_RELEASE == 'true' }}
uses: actions/checkout@v4
- name: Docker Login
if: ${{ env.PUSH_LATEST == 'true' || env.PUSH_RELEASE == 'true' }}
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
- name: Push Latest Images
if: ${{ env.PUSH_LATEST == 'true' }}
run: KAR_VERSION=$(git rev-parse --short "$GITHUB_SHA") DOCKER_REGISTRY=quay.io DOCKER_NAMESPACE=ibm DOCKER_IMAGE_TAG=latest make docker
- name: Push Release Images
if: ${{ env.PUSH_RELEASE == 'true' }}
run: KAR_VERSION=${GITHUB_REF_NAME#v} DOCKER_REGISTRY=quay.io DOCKER_NAMESPACE=ibm DOCKER_IMAGE_TAG=${GITHUB_REF_NAME#v} make docker