2021-06-08 01:06:00 +05:30
|
|
|
name: e2e
|
2020-12-16 01:16:53 +05:30
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- 'main'
|
2021-12-20 11:39:53 +05:30
|
|
|
- 'release*'
|
2020-12-16 01:16:53 +05:30
|
|
|
paths-ignore:
|
|
|
|
- 'README.md'
|
2021-01-07 21:17:03 -08:00
|
|
|
- 'docs/**'
|
2021-09-20 23:04:16 +01:00
|
|
|
- '.github/config.yml'
|
2020-12-16 01:16:53 +05:30
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- 'main'
|
2021-12-20 11:39:53 +05:30
|
|
|
- 'release*'
|
2020-12-16 01:16:53 +05:30
|
|
|
paths-ignore:
|
|
|
|
- 'README.md'
|
2021-01-07 21:17:03 -08:00
|
|
|
- 'docs/**'
|
2021-09-20 23:04:16 +01:00
|
|
|
- '.github/config.yml'
|
2020-12-16 01:16:53 +05:30
|
|
|
|
|
|
|
jobs:
|
|
|
|
e2e-test:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2022-01-13 10:53:05 +05:30
|
|
|
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0
|
2020-12-16 01:16:53 +05:30
|
|
|
|
|
|
|
- name: Unshallow
|
|
|
|
run: git fetch --prune --unshallow
|
|
|
|
|
2021-03-17 03:05:32 +05:30
|
|
|
- name: Set up Go
|
2022-01-13 10:53:05 +05:30
|
|
|
uses: actions/setup-go@424fc82d43fa5a37540bae62709ddcc23d9520d4 # v2.1.5
|
2020-12-16 01:16:53 +05:30
|
|
|
with:
|
2021-07-09 18:01:46 -07:00
|
|
|
go-version: 1.16
|
2020-12-16 01:16:53 +05:30
|
|
|
|
2021-04-13 13:39:27 -04:00
|
|
|
- name: Set up Helm
|
2022-01-13 10:53:05 +05:30
|
|
|
uses: azure/setup-helm@18bc76811624f360dbd7f18c2d4ecb32c7b87bab # v1.1
|
2021-04-13 13:39:27 -04:00
|
|
|
with:
|
|
|
|
version: v3.5.0
|
|
|
|
|
|
|
|
- name: Set up chart-testing
|
2022-01-13 10:53:05 +05:30
|
|
|
uses: helm/chart-testing-action@b0d4458c71155b54fcf33e11dd465dc923550009 # v2.0.1
|
2021-04-13 13:39:27 -04:00
|
|
|
|
2020-12-16 01:16:53 +05:30
|
|
|
- name: Cache Go modules
|
2022-01-13 10:53:05 +05:30
|
|
|
uses: actions/cache@d9747005de0f7240e5d35a68dca96b3f41b8b340 # v1.2.0
|
2020-12-16 01:16:53 +05:30
|
|
|
with:
|
|
|
|
path: ~/go/pkg/mod
|
|
|
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-go-
|
2021-03-17 03:05:32 +05:30
|
|
|
|
|
|
|
- name: Test Policy
|
|
|
|
run: |
|
2021-12-20 11:39:53 +05:30
|
|
|
if [[ ${{ github.event_name }} == "push" ]]
|
|
|
|
then
|
|
|
|
GIT_BRANCH=${GITHUB_REF##*/}
|
|
|
|
elif [[ ${{ github.event_name }} == "pull_request" ]]
|
|
|
|
then
|
|
|
|
GIT_BRANCH=${{ github.event.pull_request.base.ref }}
|
|
|
|
fi
|
|
|
|
|
|
|
|
CLI_PATH=cmd/cli/kubectl-kyverno
|
|
|
|
|
|
|
|
go run $PWD/$CLI_PATH/main.go test https://github.com/kyverno/policies/$GIT_BRANCH
|
|
|
|
go run $PWD/$CLI_PATH/main.go test https://github.com/kyverno/policies --git-branch $GIT_BRANCH
|
|
|
|
go run $PWD/$CLI_PATH/main.go test https://github.com/kyverno/policies/pod-security/restricted -b $GIT_BRANCH
|
|
|
|
go run $PWD/$CLI_PATH/main.go test ./test/cli/test-mutate
|
|
|
|
go run $PWD/$CLI_PATH/main.go test ./test/cli/test
|
|
|
|
go run $PWD/$CLI_PATH/main.go test ./test/cli/test-fail/missing-policy && exit 1 || exit 0
|
|
|
|
go run $PWD/$CLI_PATH/main.go test ./test/cli/test-fail/missing-rule && exit 1 || exit 0
|
|
|
|
go run $PWD/$CLI_PATH/main.go test ./test/cli/test-fail/missing-resource && exit 1 || exit 0
|
2021-02-10 01:04:13 +05:30
|
|
|
|
|
|
|
- name: gofmt check
|
|
|
|
run: |
|
|
|
|
if [ "$(gofmt -s -l . | wc -l)" -ne 0 ]
|
|
|
|
then
|
|
|
|
echo "The following files were found to be not go formatted:"
|
|
|
|
gofmt -s -l .
|
|
|
|
echo "Please run 'make fmt' to go format the above files."
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-12-16 01:16:53 +05:30
|
|
|
|
|
|
|
- name: golangci-lint
|
2022-01-13 10:53:05 +05:30
|
|
|
uses: reviewdog/action-golangci-lint@02bcf8c1a9febe8620f1ca523b18dd64f82296db # v1.25.0
|
2020-12-16 01:16:53 +05:30
|
|
|
|
2021-02-19 07:39:01 +05:30
|
|
|
- name: docker images build (AMD64)
|
2020-12-16 01:16:53 +05:30
|
|
|
run: |
|
2021-02-19 07:39:01 +05:30
|
|
|
make docker-build-all-amd64
|
2020-12-16 01:16:53 +05:30
|
|
|
|
|
|
|
- name : Create Kind Cluster and setup kustomize
|
|
|
|
run: |
|
|
|
|
make create-e2e-infrastruture
|
|
|
|
|
|
|
|
- name: e2e testing
|
|
|
|
run: |
|
|
|
|
echo ">>> Install Kyverno"
|
2021-10-29 18:13:20 +02:00
|
|
|
sed 's/imagePullPolicy:.*$/imagePullPolicy: IfNotPresent/g' ${GITHUB_WORKSPACE}/config/install.yaml | kubectl apply -f -
|
|
|
|
kubectl apply -f ${GITHUB_WORKSPACE}/config/github/rbac.yaml
|
2020-12-16 01:16:53 +05:30
|
|
|
chmod a+x ${GITHUB_WORKSPACE}/scripts/verify-deployment.sh
|
|
|
|
sleep 50
|
|
|
|
echo ">>> Check kyverno"
|
|
|
|
kubectl get pods -n kyverno
|
|
|
|
${GITHUB_WORKSPACE}/scripts/verify-deployment.sh -n kyverno kyverno
|
2021-03-30 16:46:01 -04:00
|
|
|
sleep 20
|
2021-05-14 04:46:24 +05:30
|
|
|
echo ">>> Expose the Kyverno's service's metric server to the host"
|
2021-10-07 08:47:58 +05:30
|
|
|
kubectl port-forward svc/kyverno-svc-metrics -n kyverno 8000:8000 &
|
2020-12-16 01:16:53 +05:30
|
|
|
echo ">>> Run Kyverno e2e test"
|
|
|
|
make test-e2e
|
2021-10-29 18:13:20 +02:00
|
|
|
kubectl delete -f ${GITHUB_WORKSPACE}/config/install.yaml
|
2020-12-16 01:16:53 +05:30
|
|
|
|
2021-04-13 13:39:27 -04:00
|
|
|
- name: Update chart values
|
|
|
|
run: |
|
|
|
|
sed -i -e "s|nameOverride:.*|nameOverride: kyverno|g" charts/kyverno/values.yaml
|
|
|
|
sed -i -e "s|fullnameOverride:.*|fullnameOverride: kyverno|g" charts/kyverno/values.yaml
|
|
|
|
sed -i -e "s|namespace:.*|namespace: kyverno|g" charts/kyverno/values.yaml
|
2021-09-22 01:37:46 +05:30
|
|
|
sed -i -e "s|tag: # replaced in e2e tests|tag: $(git describe --match "v[0-9]*")|" charts/kyverno/values.yaml
|
2021-04-13 13:39:27 -04:00
|
|
|
|
|
|
|
- name: Run chart-testing (install)
|
|
|
|
run: |
|
|
|
|
kubectl create namespace kyverno
|
2021-08-12 16:54:17 -04:00
|
|
|
ct install --target-branch=main --namespace=kyverno --charts charts/kyverno
|
2021-06-15 18:39:22 -07:00
|
|
|
|
2021-09-22 16:56:10 -04:00
|
|
|
- name: Run chart-testing (policies)
|
|
|
|
run: |
|
|
|
|
helm install kyverno charts/kyverno -n kyverno
|
|
|
|
helm install kyverno-policies charts/kyverno-policies -n kyverno
|
|
|
|
|
2021-06-15 18:39:22 -07:00
|
|
|
- name: Debug failure
|
|
|
|
if: failure()
|
|
|
|
run: |
|
|
|
|
kubectl get mutatingwebhookconfigurations,validatingwebhookconfigurations
|
|
|
|
kubectl -n kyverno get pod
|
|
|
|
kubectl -n kyverno describe pod | grep -i events -A10
|
2021-10-29 18:13:20 +02:00
|
|
|
kubectl -n kyverno logs deploy/kyverno
|