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 60262a0
Show file tree
Hide file tree
Showing 7 changed files with 56 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
26 changes: 25 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,26 @@ 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: |
kind create cluster --name kind --config ./hack/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
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,8 @@ 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
kind-multi-node:
kind create cluster --name kind --config ./hack/kind_config.yaml --wait 2m

ct-helm:
./hack/verify-chart.sh
30 changes: 0 additions & 30 deletions charts/descheduler/templates/tests/test-descheduler-pod.yaml

This file was deleted.

26 changes: 12 additions & 14 deletions docs/contributor-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,14 @@ View all CLI options.
## Run Tests
```
GOOS=linux make dev-image
kind create cluster --config hack/kind_config.yaml
make kind-multi-node
kind load docker-image <image name>
kind get kubeconfig > /tmp/admin.conf
export KUBECONFIG=/tmp/admin.conf
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 All @@ -68,5 +55,16 @@ To check linting of your changes in the helm chart locally you can run:
make lint-helm
```

## Test helm changes locally with kind and ct

You will need kind and docker (or equivalent) installed. We can use ct public image to avoid installing ct and all its dependencies.


```
make kind-multi-node
make ct-helm
```


### Miscellaneous
See the [hack directory](https://github.com/kubernetes-sigs/descheduler/tree/master/hack) for additional tools and scripts used for developing the descheduler.
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 empty 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 60262a0

Please sign in to comment.