Skip to content

Commit

Permalink
add helm test step to gh-actions
Browse files Browse the repository at this point in the history
    and remove local helm testing in favor of ct in PRs
  • Loading branch information
knelasevero committed Aug 1, 2022
1 parent 0d1d485 commit 183c857
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 91 deletions.
1 change: 1 addition & 0 deletions .github/ci/ct.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
chart-dirs:
- charts
helm-extra-args: "--timeout=5m"
helm-extra-set-args: "--set=kind=Deployment --set=podSecurityPolicy.create=false"
check-version-increment: false
target-branch: master
35 changes: 34 additions & 1 deletion .github/workflows/helm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ on:
- release-*
paths:
- 'charts/**'
- '.github/workflows/helm.yaml'
pull_request:
paths:
- 'charts/**'
- '.github/workflows/helm.yaml'

jobs:
lint-and-test:
Expand All @@ -23,14 +25,16 @@ jobs:
- name: Set up Helm
uses: azure/[email protected]
with:
version: v3.4.2
version: v3.9.2

- uses: actions/[email protected]
with:
python-version: 3.7

- name: Set up chart-testing
uses: helm/[email protected]
with:
version: v3.7.0

- name: Run chart-testing (list-changed)
id: list-changed
Expand All @@ -39,6 +43,35 @@ jobs:
if [[ -n "$changed" ]]; then
echo "::set-output name=changed::true"
fi
# Force linting/test in debug runs with a change (this action only runs on chart and helm.yaml workflow diffs anyways)
- name: Change Kind to deployment
run: "sed -i \"s|kind: [^ ]*|kind: Deployment|g\" charts/descheduler/values.yaml"

- name: Run chart-testing (lint)
run: ct lint --config=.github/ci/ct.yaml --validate-maintainers=false

# Need a multi node cluster so descheduler runs until evictions
- name: Create multi node Kind cluster
run: |
cat > kind-config.yaml <<EOF
# three node (two workers) cluster config
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
EOF
kind create cluster --name kind --config kind-config.yaml --wait 2m
# helm-extra-set-args only available after ct 3.6.0
- name: Run chart-testing (install)
run: ct install --config=.github/ci/ct.yaml

- name: E2E after chart install
env:
KUBERNETES_VERSION: "v1.24.0"
KIND_E2E: true
SKIP_INSTALL: true
run: make test-e2e
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,3 @@ lint-chart: ensure-helm-install

build-helm:
helm package ./charts/descheduler --dependency-update --destination ./bin/chart

test-helm: ensure-helm-install
./test/run-helm-tests.sh
30 changes: 0 additions & 30 deletions charts/descheduler/templates/tests/test-descheduler-pod.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions docs/contributor-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,6 @@ make test-unit
make test-e2e
```

## Run Helm Tests
Run the helm test for a particular descheduler release by setting below variables,
```
HELM_IMAGE_REPO="descheduler"
HELM_IMAGE_TAG="helm-test"
HELM_CHART_LOCATION="./charts/descheduler"
```
The helm tests runs as part of descheduler CI. But, to run it manually from the descheduler root,

```
make test-helm
```

## Build Helm Package locally

If you made some changes in the chart, and just want to check if templating is ok, or if the chart is buildable, you can run this command to have a package built from the `./charts` directory.
Expand Down
20 changes: 13 additions & 7 deletions test/run-e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,21 @@ set -x
set -o errexit
set -o nounset

# Set to mepty if unbound/empty
SKIP_INSTALL=${SKIP_INSTALL:-}

# This just runs e2e tests.
if [ -n "$KIND_E2E" ]; then
K8S_VERSION=${KUBERNETES_VERSION:-v1.24.0}
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/amd64/kubectl && chmod +x kubectl && mv kubectl /usr/local/bin/
wget https://github.com/kubernetes-sigs/kind/releases/download/v0.13.0/kind-linux-amd64
chmod +x kind-linux-amd64
mv kind-linux-amd64 kind
export PATH=$PATH:$PWD
kind create cluster --image kindest/node:${K8S_VERSION} --config=./hack/kind_config.yaml
# If we did not set SKIP_INSTALL
if [ -z "$SKIP_INSTALL" ]; then
K8S_VERSION=${KUBERNETES_VERSION:-v1.24.0}
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/amd64/kubectl && chmod +x kubectl && mv kubectl /usr/local/bin/
wget https://github.com/kubernetes-sigs/kind/releases/download/v0.13.0/kind-linux-amd64
chmod +x kind-linux-amd64
mv kind-linux-amd64 kind
export PATH=$PATH:$PWD
kind create cluster --image kindest/node:${K8S_VERSION} --config=./hack/kind_config.yaml
fi
docker pull kubernetes/pause
kind load docker-image kubernetes/pause
kind get kubeconfig > /tmp/admin.conf
Expand Down
37 changes: 0 additions & 37 deletions test/run-helm-tests.sh

This file was deleted.

0 comments on commit 183c857

Please sign in to comment.