Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

(feat): add integration tests running on k8s #58

(feat): add integration tests running on k8s

(feat): add integration tests running on k8s #58

Workflow file for this run

name: Run tests
on:
pull_request:
push:
branches:
- master
env:
TYK_STACK_NS: tyk-stack
TIMEOUT: 10m
jobs:
run-tests:
runs-on: ubuntu-latest
outputs:
latest-version: ${{ steps.get-latest-version.outputs.version }}
steps:
- name: Checkout Tyk Sync
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Setup Golang
uses: actions/setup-go@v5
with:
go-version: 1.21.x
- name: Get latest version
id: get-latest-version
run: |
go build && go install
version=$(./tyk-sync v)
echo "version=$version"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Run unit tests
run: go test ./...
integration:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
k8s_version: [ "v1.29.1" ]
steps:
- name: Checkout Tyk Sync
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Setup Golang
uses: actions/setup-go@v5
with:
go-version: 1.21.x
- name: Get latest version
id: get-latest-version
run: |
go build && go install
version=$(tyk-sync v)
echo "version=$version"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Create Kind Cluster
uses: helm/kind-action@v1.9.0
with:
node_image: "kindest/node:${{ matrix.k8s_version }}"
- name: Install helm
uses: azure/setup-helm@v4
- name: Deploy Tyk Stack and dependencies
id: deploy-stack
run: |
kubectl create namespace ${{ env.TYK_STACK_NS }}
# Do not change the name
# Install redis
helm install redis oci://registry-1.docker.io/bitnamicharts/redis --wait -n ${{ env.TYK_STACK_NS }} --timeout ${{ env.TIMEOUT }} --version 19.0.2
# Install mongo
helm install mongo oci://registry-1.docker.io/bitnamicharts/mongodb --wait -n ${{ env.TYK_STACK_NS }} --timeout ${{ env.TIMEOUT }} --version 15.1.3
MONGODB_ROOT_PASSWORD=$(kubectl get secret -n ${{ env.TYK_STACK_NS }} mongo-mongodb -o jsonpath="{.data.mongodb-root-password}" | base64 -d)
helm dependency update ./tyk-stack
helm install --namespace ${{ env.TYK_STACK_NS }} tyk-stack ./tyk-stack \
--set "global.mongo.mongoURL=mongodb://root:$MONGODB_ROOT_PASSWORD@mongo-mongodb.${{ env.TYK_STACK_NS }}.svc:27017/tyk_analytics?authSource=admin" \
--set "global.redis.addrs={redis-master.${{ env.TYK_STACK_NS }}.svc:6379"} \
--set "global.redis.passSecret.name=redis" \
--set "global.redis.passSecret.keyName=redis-password" \
--set "global.license.dashboard=${{ secrets.DASH_LICENSE }}" \
--set "global.storageType=mongo" \
--timeout=${{ env.TIMEOUT }}
- name: Checkout Tyk Sync Integration Tests
uses: actions/checkout@v4
with:
repository: "TykTechnologies/tyk-sync-tests"
path: sync-tests
depth: 1
- name: Run integration tests
run: |
echo $(pwd)
echo $(ls -la)
echo $(ls ../ -la)
echo "waiting for dashboard to be ready..."
kubectl rollout status -n ${{ env.TYK_STACK_NS }} deployment dashboard-tyk-stack-tyk-dashboard
kubectl port-forward -n ${{ env.TYK_STACK_NS }} services/dashboard-svc-tyk-stack-tyk-dashboard 3000
TYK_AUTH=${{ secrets.DASH_LICENSE }} TYK_URL=http://localhost:3000 ./sync-tests/init.sh
sbom:
uses: TykTechnologies/github-actions/.github/workflows/sbom.yaml@main
needs: run-tests
if: ${{ github.event_name == 'pull_request' || github.event_name == 'push' }}
secrets:
TF_API_TOKEN: ${{ secrets.TF_API_TOKEN }}
DEPDASH_URL: ${{ secrets.DEPDASH_URL }}
DEPDASH_KEY: ${{ secrets.DEPDASH_KEY }}
ORG_GH_TOKEN: ${{ secrets.ORG_GH_TOKEN }}
DOCKER_IMAGE: "tykio/tyk-sync:${{needs.run-tests.outputs.latest-version}}"