Continuous Integration #173
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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@v3 | |
# Download pre-reqs | |
- name: Install k8s clis | |
run: ./ci/setup.sh | |
# Configure language versions | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: 'core/go.mod' | |
cache-dependency-path: 'core/go.sum' | |
- name: Setup Java | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
- name: Setup JavaScript | |
uses: actions/setup-node@v3 | |
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@v3 | |
# Download pre-reqs | |
- name: Install k8s clis | |
run: ./ci/setup.sh | |
# Configure language versions | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: 'core/go.mod' | |
cache-dependency-path: 'core/go.sum' | |
- name: Setup Java | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
- name: Setup JavaScript | |
uses: actions/setup-node@v3 | |
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@v3 | |
# Download pre-reqs | |
- name: Install k8s clis | |
run: ./ci/setup.sh | |
# Configure language versions | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: 'core/go.mod' | |
cache-dependency-path: 'core/go.sum' | |
- name: Setup Java | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
- name: Setup JavaScript | |
uses: actions/setup-node@v3 | |
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@v3 | |
- name: Docker Login | |
if: ${{ env.PUSH_LATEST == 'true' || env.PUSH_RELEASE == 'true' }} | |
uses: docker/login-action@v2 | |
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 |