Skip to content

Commit

Permalink
Add installation tests and refactor some CI jobs (#188)
Browse files Browse the repository at this point in the history
* Skip the docker build task in post-submit job

* Refactor the linter and unit test jobs

* Add installation test CI job

* Add users container image build & push
  • Loading branch information
Jeffwan authored Sep 19, 2024
1 parent 1bc20e1 commit 012a7c0
Show file tree
Hide file tree
Showing 9 changed files with 143 additions and 34 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docker-build-images.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Docker Build Images

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

Expand All @@ -20,3 +18,5 @@ jobs:
run: make docker-build-plugins
- name: Docker Build - Runtime
run: make docker-build-runtime
- name: Docker Build - Users
run: make docker-build-users
4 changes: 4 additions & 0 deletions .github/workflows/docker-push-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ jobs:
run: make docker-build-plugins
- name: Docker Build - Runtime
run: make docker-build-runtime
- name: Docker Build - Users
run: make docker-build-users
# push container image to dockerhub
- name: Push Image - Controller Manager
run: make docker-push
- name: Push Image - Gateway Plugins
run: make docker-push-plugins
- name: Push Image - Runtime
run: make docker-push-runtime
- name: Push Image - Users
run: make docker-push-users
67 changes: 67 additions & 0 deletions .github/workflows/installation-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Installation Tests

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
installation-test:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Install kind
run: |
[ $(uname -m) = x86_64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.24.0/kind-linux-amd64
chmod +x ./kind
mv ./kind /usr/local/bin/kind
kind version
- name: Install kustomize
run: |
curl -L https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v5.4.3/kustomize_v5.4.3_$(go env GOOS)_$(go env GOARCH).tar.gz | tar -xz -C /usr/local/bin/
kustomize version
- name: Set up testing environment
run: |
# Set up the cluster with kind or other Kubernetes environment needed
kind create cluster --name installation-test
kubectl cluster-info --context kind-installation-test
- name: Build container images
run: |
IMG=aibrix/controller-manager:${{ github.sha }} make docker-build
PLUGINS_IMG=aibrix/plugins:${{ github.sha }} make docker-build-plugins
RUNTIME_IMG=aibrix/runtime:${{ github.sha }} make docker-build-runtime
USERS_IMG=aibrix/users:${{ github.sha }} make docker-build-users
- name: Load image into Kind
run: |
kind load docker-image aibrix/controller-manager:${{ github.sha }} --name installation-test
kind load docker-image aibrix/plugins:${{ github.sha }} --name installation-test
kind load docker-image aibrix/runtime:${{ github.sha }} --name installation-test
kind load docker-image aibrix/users:${{ github.sha }} --name installation-test
- name: Deploy controller with the built image
run: |
kubectl create -k config/dependency
cd config/manager && kustomize edit set image controller=aibrix/controller-manager:${{ github.sha }}
cd ${{ github.workspace }}
cd config/gateway && kustomize edit set image plugins=aibrix/plugins:${{ github.sha }} && kustomize edit set image users=aibrix/users:${{ github.sha }}
cd ${{ github.workspace }}
kubectl apply -k config/default
- name: Check pod status
run: |
sleep 60s
kubectl get pods --all-namespaces
kubectl wait pod --all --for=condition=ready --all-namespaces --timeout=300s
- name: Clean up
run: kind delete cluster --name installation-test
53 changes: 53 additions & 0 deletions .github/workflows/lint-and-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Linter and Unit Tests

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Lint
run: make lint-all

verify:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Verify Codegen
run: bash ${GITHUB_WORKSPACE}/hack/verify-codegen.sh

test:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Cache Go modules
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run Unit Tests
run: make test
24 changes: 0 additions & 24 deletions .github/workflows/tests.yml

This file was deleted.

6 changes: 3 additions & 3 deletions config/gateway/gateway-plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ spec:
image: busybox
command: ['sh', '-c', "until nslookup aibrix-redis-master.aibrix-system.svc.cluster.local; do echo waiting for service aibrix-redis-master; sleep 2; done"]
containers:
- name: golang-app-container
image: aibrix/plugins:nightly
imagePullPolicy: Always
- name: gateway-plugin
image: plugins:latest
imagePullPolicy: IfNotPresent
ports:
- containerPort: 50052
env:
Expand Down
9 changes: 9 additions & 0 deletions config/gateway/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,12 @@ resources:
- gateway-plugin.yaml
- users.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: plugins
newName: aibrix/plugins
newTag: nightly
- name: users
newName: aibrix/users
newTag: nightly
8 changes: 4 additions & 4 deletions config/gateway/users.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ spec:
spec:
initContainers:
- name: init-c
image: busybox
image: busybox:stable
command: ['sh', '-c', "until nslookup aibrix-redis-master.aibrix-system.svc.cluster.local; do echo waiting for service aibrix-redis-master; sleep 2; done"]
containers:
- name: golang-app-container
image: aibrix/users:nightly
imagePullPolicy: Always
- name: gateway-users
image: users:latest
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8090
env:
Expand Down
2 changes: 1 addition & 1 deletion config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ spec:
securityContext:
runAsNonRoot: true
containers:
- imagePullPolicy: Always
- imagePullPolicy: IfNotPresent
command:
- /manager
args:
Expand Down

0 comments on commit 012a7c0

Please sign in to comment.