Update dependencies #329
Workflow file for this run
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
name: Build and Test Helm | |
on: | |
pull_request: | |
paths-ignore: | |
- docs/** | |
- README.md | |
- deploy/helm/*.md | |
- build/** | |
- src/** | |
branches: | |
- master | |
- release/** | |
jobs: | |
helm_verify: | |
name: Helm Lint and Unit tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Helm | |
uses: azure/setup-helm@v3 | |
with: | |
version: v3.8.2 | |
- name: Add dependency chart repos | |
run: | | |
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts | |
helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts | |
helm repo add jetstack https://charts.jetstack.io | |
- name: Download chart dependencies before linting | |
run: helm dependency build deploy/helm | |
- name: Lint helm | |
run: helm lint deploy/helm --with-subcharts | |
- name: Lint template | |
run: helm template deploy/helm --include-crds --no-hooks | |
- name: Install Unit test plugin | |
run: helm plugin install https://github.com/helm-unittest/helm-unittest.git | |
- name: Run unit tests | |
run: helm unittest deploy/helm | |
# Verify whether Helm chart works with image published in DockerHub | |
helm_e2e: | |
runs-on: ubuntu-latest | |
needs: helm_verify | |
name: Helm e2e tests | |
outputs: | |
image_tag: ${{ steps.generate-tag.outputs.value }} | |
strategy: | |
matrix: | |
# Kubernetes versions to test on | |
kubernetes_version: | |
- v1.25.16 | |
- v1.26.15 | |
- v1.27.16 | |
- v1.28.13 | |
- v1.29.8 | |
- v1.30.4 | |
- v1.31.0 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Deploy skaffold | |
uses: ./.github/actions/deploy-skaffold | |
- name: Create k8s Kind Cluster | |
uses: helm/kind-action@v1.10.0 | |
with: | |
version: v0.24.0 | |
kubectl_version: ${{ matrix.kubernetes_version }} | |
node_image: kindest/node:${{ matrix.kubernetes_version }} | |
cluster_name: kind | |
- name: Add dependency chart repos | |
run: | | |
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts | |
helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts | |
helm repo add jetstack https://charts.jetstack.io | |
- name: Build | |
run: skaffold build -p=ci-helm-e2e --file-output=/tmp/tags.json | |
- name: Copy image to Kind cluster | |
run: | | |
kind load docker-image $(jq -r '.builds[] | select(.imageName=="integration-test") | .tag' /tmp/tags.json) | |
- name: Setup kubetail | |
run: | | |
curl -Lo kubetail https://raw.githubusercontent.com/johanhaleby/kubetail/master/kubetail && sudo install kubetail /usr/local/bin/ | |
shell: bash | |
- name: Deploy services using Skaffold | |
run: | | |
skaffold deploy -p=ci-helm-e2e \ | |
--build-artifacts=/tmp/tags.json \ | |
--kube-context kind-kind | |
- name: Show all resources | |
run: | | |
kubectl get all -n test-namespace | |
- name: Run integration tests | |
uses: ./.github/actions/run-integration-tests | |
helm_test_auto_update_against_last_published: | |
runs-on: ubuntu-latest | |
name: Helm auto update test | |
needs: helm_verify | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Deploy Kubernetes | |
uses: ./.github/actions/deploy-kubernetes | |
- name: Add dependency chart repos | |
run: | | |
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts | |
helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts | |
helm repo add jetstack https://charts.jetstack.io | |
helm repo add solarwinds https://helm.solarwinds.com | |
helm repo update | |
- name: Deploy mocks.yaml | |
run: kubectl apply -f tests/deploy/base/mocks.yaml | |
- name: Create Dockerfile with Helm repository | |
run: | | |
cat <<EOF > Dockerfile | |
FROM python:3.12-alpine3.19 | |
WORKDIR /app | |
COPY . . | |
EXPOSE 5000 | |
CMD ["python", "-m", "http.server", "5000"] | |
EOF | |
- name: Package and build Helm repository image | |
run: | | |
helm dependency build deploy/helm | |
helm package deploy/helm | |
helm repo index . | |
docker build -t helm-repo:latest . | |
- name: Deploy Helm repository in Kubernetes cluster | |
run: | | |
cat <<EOF | kubectl apply -f - | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: helm-repo | |
spec: | |
selector: | |
matchLabels: | |
app: helm-repo | |
replicas: 1 | |
template: | |
metadata: | |
labels: | |
app: helm-repo | |
spec: | |
containers: | |
- name: helm-repo | |
image: helm-repo:latest | |
imagePullPolicy: Never | |
ports: | |
- containerPort: 5000 | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: helm-repo | |
spec: | |
selector: | |
app: helm-repo | |
ports: | |
- protocol: TCP | |
port: 5000 | |
targetPort: 5000 | |
type: ClusterIP | |
EOF | |
- name: Deploy swo-k8s-collector Helm chart | |
run: | | |
helm install swo-k8s-collector solarwinds/swo-k8s-collector \ | |
--create-namespace \ | |
--namespace swo-k8s-collector \ | |
--set cluster.name=test-cluster \ | |
--set otel.endpoint=timeseries-mock-service:9082 \ | |
--set otel.api_token=not_set \ | |
--set autoupdate.enabled=true \ | |
--set autoupdate.devel=true \ | |
--set otel.metrics.swi_endpoint_check=false \ | |
--set otel.metrics.prometheus_check=false \ | |
--set otel.metrics.resources.requests.memory=100Mi \ | |
--set otel.events.resources.requests.memory=100Mi \ | |
--set otel.logs.resources.requests.memory=100Mi \ | |
--atomic | |
- name: Update AutoUpdate ConfigMap to use local Helm repository | |
run: | | |
kubectl get configmap swo-k8s-collector-autoupdate-script -n swo-k8s-collector -o yaml > autoupdate-script.yaml | |
sed -i 's|https://helm.solarwinds.com|http://helm-repo.default.svc.cluster.local:5000|' autoupdate-script.yaml | |
kubectl apply -f autoupdate-script.yaml | |
cat autoupdate-script.yaml | |
- name: Trigger helm-autoupdate CronJob and verify | |
run: | | |
# Trigger the CronJob | |
kubectl create job --from=cronjob/helm-autoupdate helm-autoupdate-manual-trigger -n swo-k8s-collector | |
# Wait for the job to complete | |
kubectl wait --for=condition=complete --timeout=300s job/helm-autoupdate-manual-trigger -n swo-k8s-collector | |
# Get the job's success and failure status | |
JOB_SUCCEEDED=$(kubectl get job helm-autoupdate-manual-trigger -n swo-k8s-collector -o=jsonpath='{.status.succeeded}') | |
JOB_FAILED=$(kubectl get job helm-autoupdate-manual-trigger -n swo-k8s-collector -o=jsonpath='{.status.failed}') | |
# Check if the job succeeded or failed | |
if [ "$JOB_SUCCEEDED" == "1" ]; then | |
echo "Job completed successfully." | |
elif [ "$JOB_FAILED" != "" ]; then | |
echo "Job failed." | |
exit 1 | |
else | |
echo "Job did not complete successfully. Status is ambiguous." | |
exit 1 | |
fi | |
- name: Trigger helm-autoupdate CronJob logs | |
if: ${{ always() }} | |
run: | | |
kubectl logs jobs/helm-autoupdate-manual-trigger -n swo-k8s-collector --all-containers=true |