Skip to content

Commit

Permalink
👷 ci: Implement test pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
MfCrizz committed Nov 17, 2023
1 parent cab248d commit 9f3138f
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 49 deletions.
30 changes: 0 additions & 30 deletions .github/workflows/build-images.yaml

This file was deleted.

55 changes: 55 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Run Skaffold Pipeline, Deploy to Minikube Cluster and run Unguard Helm Test
on:
pull_request:
paths:
- src/**
- skaffold.yaml
- chart/**

jobs:
lint-build-run-test-unguard:
runs-on: ubuntu-22.04
timeout-minutes: 30
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Set up Helm
uses: azure/[email protected]
with:
version: v3.12.3

- name: Kubectl tool installer
uses: Azure/setup-kubectl@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
check-latest: true

- name: Set up chart-testing
uses: helm/[email protected]

- name: Run chart-testing (lint)
run: ct lint --chart-dirs . --charts ./chart --validate-maintainers=false --check-version-increment=false --target-branch ${{ github.event.repository.default_branch }}

- name: Set up Minikube
uses: medyagh/[email protected]
with:
addons: ingress

- name: Cache Skaffold layers
uses: actions/cache@v3
with:
path: ~/.skaffold/
key: fixed-${{ github.sha }}

- name: Run Skaffold and Deploy to Minikube Cluster
uses: hiberbee/[email protected]
with:
command: run
skip-tests: true

- name: Run chart-testing
run: helm test unguard --namespace unguard --timeout 10m0s --logs
22 changes: 22 additions & 0 deletions chart/templates/tests/test-frontend-connection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: v1
kind: Pod
metadata:
name: unguard-frontend-connection
labels:
app.kubernetes.io/name: unguard-frontend-connection
app.kubernetes.io/part-of: unguard
annotations:
"helm.sh/hook": test
spec:
containers:
- name: unguard-{{.Values.userSimulator.name}}
image: {{.Values.userSimulator.cronJob.jobTemplate.container.image.repository}}:{{.Values.userSimulator.cronJob.jobTemplate.container.image.tag}}
imagePullPolicy: {{.Values.userSimulator.cronJob.jobTemplate.container.image.pullPolicy}}
env:
- name: FRONTEND_ADDR
value: {{quote .Values.userSimulator.cronJob.jobTemplate.container.env.FRONTEND_ADDR}}
- name: SIMULATE_PRIVATE_RANGES
value: {{quote .Values.userSimulator.cronJob.jobTemplate.container.env.SIMULATE_PRIVATE_RANGES}}
command: ["/bin/sh"]
args: ["-c", "node_modules/.bin/element run default-user-sim.perf.ts --export 2>&1 && jq -e '.testScripts[].iterationResults[].stepResults[] | select(.status == \"failed\") | .name' reports/default-user-sim.perf/*/data.json >/dev/null && exit 1 || exit 0"]
restartPolicy: Never
36 changes: 18 additions & 18 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ userAuthService:
secretKeyRef:
name: "{{ .Values.mariaDB.serviceName }}"
key: "{{ .Values.mariaDB.password }}"
JAEGER_AGENT_HOST: agent # change depending on your jaeger deployment
JAEGER_AGENT_HOST: agent # change depending on your jaeger deployment
JAEGER_SAMPLER_TYPE: const
JAEGER_SAMPLER_PARAM: 0
JAEGER_DISABLED: true
Expand Down Expand Up @@ -207,7 +207,7 @@ adService:
ports:
containerPort: 8082
env:
JAEGER_AGENT_HOST: agent # change depending on your jaeger deployment
JAEGER_AGENT_HOST: agent # change depending on your jaeger deployment
JAEGER_SAMPLER_TYPE: const
JAEGER_SAMPLER_PARAM: 0
JAEGER_DISABLED: true
Expand Down Expand Up @@ -266,7 +266,7 @@ microblogService:
containerPort: 8080
env:
SERVER_PORT: 8080
JAEGER_AGENT_HOST: agent # change depending on your jaeger deployment
JAEGER_AGENT_HOST: agent # change depending on your jaeger deployment
JAEGER_SAMPLER_TYPE: const
JAEGER_SAMPLER_PARAM: 0
OPENTRACING_JAEGER_ENABLED: false
Expand All @@ -289,12 +289,12 @@ statusService:
role:
name: status-role
rules:
- apiGroups: [ "apps" ]
resources: [ "deployments" ]
verbs: [ "get", "list" ]
- apiGroups: [ "" ]
resources: [ "pods" ]
verbs: [ "get", "list" ]
- apiGroups: ["apps"]
resources: ["deployments"]
verbs: ["get", "list"]
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list"]

roleBindings:
name: status-rolebinding
Expand All @@ -321,7 +321,7 @@ statusService:
SERVER_PORT: 8083
API_PATH: /status-service
KUBERNETES_NAMESPACE: unguard
IGNORED_DEPLOYMENTS: unguard-user-simulator # add deployments to ignore separated by spaces
IGNORED_DEPLOYMENTS: unguard-user-simulator # add deployments to ignore separated by spaces
MARIADB_SERVICE: "{{ .Values.mariaDB.serviceName }}"
MARIADB_PASSWORD:
secretKeyRef:
Expand All @@ -344,12 +344,12 @@ proxyService:
role:
name: proxy-role
rules:
- apiGroups: [ "" ] # "" indicates the core API group
resources: [ "pods" ]
verbs: [ "create", "list", "get" ]
- apiGroups: [ "" ]
resources: [ "pods/exec" ]
verbs: [ "create" ]
- apiGroups: [""] # "" indicates the core API group
resources: ["pods"]
verbs: ["create", "list", "get"]
- apiGroups: [""]
resources: ["pods/exec"]
verbs: ["create"]

roleBindings:
name: proxy-rolebinding
Expand All @@ -374,7 +374,7 @@ proxyService:
containerPort: 8081
env:
SERVER_PORT: 8081
JAEGER_AGENT_HOST: agent # change depending on your jaeger deployment
JAEGER_AGENT_HOST: agent # change depending on your jaeger deployment
JAEGER_SAMPLER_TYPE: const
JAEGER_SAMPLER_PARAM: 0
OPENTRACING_JAEGER_ENABLED: false
Expand All @@ -400,7 +400,7 @@ frontend:
ports:
containerPort: 3000
env:
JAEGER_AGENT_HOST: agent # change depending on your jaeger deployment
JAEGER_AGENT_HOST: agent # change depending on your jaeger deployment
JAEGER_SAMPLER_TYPE: const
JAEGER_SAMPLER_PARAM: 0
JAEGER_DISABLED: true
Expand Down
2 changes: 1 addition & 1 deletion src/user-simulator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN apt-get update \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 libxshmfence1 \
&& apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 libxshmfence1 jq \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*

Expand Down

0 comments on commit 9f3138f

Please sign in to comment.