From edef01f05cbbc487a37ce4adc70c737a570f3c5b Mon Sep 17 00:00:00 2001 From: Laszlo Fogas Date: Wed, 24 Feb 2021 16:06:38 +0100 Subject: [PATCH] Helm unit testing --- .github/workflows/build.yml | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..8dee51b --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,52 @@ +name: Build +on: + push: + branches: + - '*' + pull_request: + branches: + - '*' + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.16 + + - name: Deps + run: | + curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 + chmod 700 get_helm.sh + ./get_helm.sh + + wget https://github.com/instrumenta/kubeval/releases/latest/download/kubeval-linux-amd64.tar.gz + tar xf kubeval-linux-amd64.tar.gz + sudo cp kubeval /usr/local/bin + + git clone https://github.com/DataDog/helm-unittest.git + cd helm-unittest + export VERSION=$(sed -n -e 's/version:[ "]*\([^"]*\).*/\1/p' plugin.yaml) + export LDFLAGS="-X main.version=$VERSION -extldflags '-static'" + echo $LDFLAGS + go build -o untt -ldflags "$LDFLAGS" ./main.go + export HELM_PLUGINS=$(helm env | grep "HELM_PLUGINS" | awk -F"=" '{print $2;}' | awk -F\" '{print $2;}') + export HELM_PLUGIN_DIR=$HELM_PLUGINS/helm-unittest + mkdir -p $HELM_PLUGIN_DIR + cp untt $HELM_PLUGIN_DIR + cp plugin.yaml $HELM_PLUGIN_DIR + + - name: Check out + uses: actions/checkout@v1 + with: + fetch-depth: 1 + + - name: Test + run: | + make lint + make kubeval + make test