Skip to content

Lint and Test Common Services Charts #270

Lint and Test Common Services Charts

Lint and Test Common Services Charts #270

name: Lint and Test Common Services Charts
on:
workflow_dispatch:
pull_request:
paths:
- 'charts/common-services/**'
env:
HELM_VERSION: v3.14.4
PYTHON_VERSION: 3.9
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
jobs:
lint:
runs-on: ubuntu-latest
outputs:
changed: ${{ steps.list-changed.outputs.changed }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: ${{ env.HELM_VERSION }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Cache Helm plugins
uses: actions/cache@v3
with:
path: ~/.local/share/helm/plugins
key: ${{ runner.os }}-helm-plugins-${{ hashFiles('**/requirements.txt') }}
- name: Set up chart-testing
uses: helm/chart-testing-action@v2.7.0
- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --target-branch ${{ env.DEFAULT_BRANCH }})
if [[ -n "$changed" ]]; then
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "changed=false" >> $GITHUB_OUTPUT
fi
- name: Add helm repos
run: |
helm repo add prometheus https://prometheus-community.github.io/helm-charts
helm repo add grafana https://grafana.github.io/helm-charts
helm repo add elastic https://helm.elastic.co
helm repo add kibana https://helm.elastic.co
helm repo add argo-cd https://argoproj.github.io/argo-helm
helm repo add haproxy https://haproxytech.github.io/helm-charts
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo add runix https://helm.runix.net
helm repo add opensearch https://opensearch-project.github.io/helm-charts
helm repo add fluent https://fluent.github.io/helm-charts
helm repo add velero https://vmware-tanzu.github.io/helm-charts
helm repo add cnpg https://cloudnative-pg.github.io/charts
helm repo add velero-ui https://helm.otwld.com
- name: Run chart-testing (lint)
run: ct lint --target-branch ${{ env.DEFAULT_BRANCH }}
test:
needs: lint
runs-on: ubuntu-latest
if: needs.lint.outputs.changed == 'true'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: ${{ env.HELM_VERSION }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Cache Helm plugins
uses: actions/cache@v3
with:
path: ~/.local/share/helm/plugins
key: ${{ runner.os }}-helm-plugins-${{ hashFiles('**/requirements.txt') }}
- name: Set up chart-testing
uses: helm/chart-testing-action@v2.6.1
- name: Create kind cluster
uses: helm/kind-action@v1
with:
config: .config/kind.yaml
- name: Kind cluster-info
run: |
kubectl cluster-info --context kind-chart-testing
kubectl get nodes --context kind-chart-testing
- name: Install Prometheus Operator CRDs
run: |
curl -sSL -o /tmp/prom-crds.yaml https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/main/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml
curl -sSL -o /tmp/prom-podmonitor-crd.yaml https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/main/example/prometheus-operator-crd/monitoring.coreos.com_podmonitors.yaml
curl -sSL -o /tmp/prom-rule-crd.yaml https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/main/example/prometheus-operator-crd/monitoring.coreos.com_prometheusrules.yaml
kubectl apply -f /tmp/prom-crds.yaml
kubectl apply -f /tmp/prom-podmonitor-crd.yaml
kubectl apply -f /tmp/prom-rule-crd.yaml
shell: bash
- name: Run chart-testing (install)
run: |
ct install --charts=charts/common-services \
--helm-extra-args="--timeout=15m0s" \
--helm-extra-set-args="--set=velero-ui.enabled=false \
--set=elasticsearch.replicas=1 \
--set=elasticsearch.clusterHealthCheckParams=wait_for_status=yellow&timeout=60s \
--set=pgadmin4.enabled=false \
--set=slamd.enabled=false \
--set=shellinabox.enabled=false \
--set=curator.enabled=false \
--set=zoonavigator.enabled=false \
--set=backupManager.enabled=false" \
--debug --skip-missing-values
# Temp Helm Chart hosted as an OCI image on ghcr
publish-ghcr:
# depending on default permission settings for your org (contents being read-only or read-write for workloads), you will have to add permissions
# see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
needs: lint
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: read-yaml-file
uses: mikefarah/yq@master
id: read_chart
with:
cmd: yq '.version' charts/common-services/Chart.yaml
- name: Chart | Push
uses: appany/helm-oci-chart-releaser@v0.4.1
with:
name: common-services
repository: helm
tag: ${{ steps.read_chart.outputs.result }}
registry: ghcr.io/${{ github.repository_owner }}
path: charts/common-services
registry_username: ${{ github.actor }}
registry_password: ${{ secrets.GITHUB_TOKEN }}
update_dependencies: 'true' # Defaults to false