1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00

Improve E2E test CI timings (#3250)

Signed-off-by: Sambhav Kothari <sambhavs.email@gmail.com>
This commit is contained in:
Sambhav Kothari 2022-02-18 01:47:35 +00:00 committed by GitHub
parent 1631f011b1
commit 8c7f037c72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 162 additions and 76 deletions

63
.github/workflows/cli.yaml vendored Normal file
View file

@ -0,0 +1,63 @@
name: cli
on:
push:
branches:
- 'main'
- 'release*'
paths-ignore:
- 'README.md'
- 'docs/**'
- '.github/config.yml'
pull_request:
branches:
- 'main'
- 'release*'
paths-ignore:
- 'README.md'
- 'docs/**'
- '.github/config.yml'
permissions: read-all
jobs:
cli-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0
- name: Unshallow
run: git fetch --prune --unshallow
- name: Set up Go
uses: actions/setup-go@424fc82d43fa5a37540bae62709ddcc23d9520d4 # v2.1.5
with:
go-version: 1.17
- name: Cache Go modules
uses: actions/cache@d9747005de0f7240e5d35a68dca96b3f41b8b340 # v1.2.0
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Test Policy
run: |
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
make cli
CLI_PATH=$PWD/cmd/cli/kubectl-kyverno/kyverno
$CLI_PATH test https://github.com/kyverno/policies/$GIT_BRANCH
$CLI_PATH test https://github.com/kyverno/policies --git-branch $GIT_BRANCH
$CLI_PATH test https://github.com/kyverno/policies/pod-security/restricted -b $GIT_BRANCH
$CLI_PATH test ./test/cli/test-mutate
$CLI_PATH test ./test/cli/test
$CLI_PATH test ./test/cli/test-fail/missing-policy && exit 1 || exit 0
$CLI_PATH test ./test/cli/test-fail/missing-rule && exit 1 || exit 0
$CLI_PATH test ./test/cli/test-fail/missing-resource && exit 1 || exit 0

View file

@ -50,47 +50,9 @@ jobs:
restore-keys: | restore-keys: |
${{ runner.os }}-go- ${{ runner.os }}-go-
- name: Test Policy - name : Create dev images, kind cluster and setup kustomize
run: | run: |
if [[ ${{ github.event_name }} == "push" ]] make -j4 create-e2e-infrastruture
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
- 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
- name: golangci-lint
uses: reviewdog/action-golangci-lint@02bcf8c1a9febe8620f1ca523b18dd64f82296db # v1.25.0
- name: docker images build (AMD64)
run: |
make docker-build-all-amd64
- name : Create Kind Cluster and setup kustomize
run: |
make create-e2e-infrastruture
- name: e2e testing - name: e2e testing
run: | run: |

View file

@ -1,13 +1,9 @@
name: build name: image-build
on: on:
push: push:
branches: branches:
- 'main' - 'main'
- 'release*' - 'release*'
pull_request:
branches:
- 'main'
- 'release*'
permissions: permissions:
contents: read contents: read
@ -172,31 +168,3 @@ jobs:
- name: docker images build - name: docker images build
run: | run: |
make docker-build-cli make docker-build-cli
tests:
runs-on: ubuntu-latest
needs: pre-checks
steps:
- name: Checkout
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0
- name: Unshallow
run: git fetch --prune --unshallow
- name: Set up Go
uses: actions/setup-go@424fc82d43fa5a37540bae62709ddcc23d9520d4 # v2.1.5
with:
go-version: 1.17
- name: Cache Go modules
uses: actions/cache@d9747005de0f7240e5d35a68dca96b3f41b8b340 # v1.2.0
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Kyverno unit test
run: |
export PROJECT_PATH=$(pwd)
make test-unit

93
.github/workflows/tests.yaml vendored Normal file
View file

@ -0,0 +1,93 @@
name: tests
on:
push:
branches:
- 'main'
- 'release*'
pull_request:
branches:
- 'main'
- 'release*'
permissions:
contents: read
packages: write
id-token: write
jobs:
pre-checks:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0
- name: Unshallow
run: git fetch --prune --unshallow
- name: Set up Go
uses: actions/setup-go@424fc82d43fa5a37540bae62709ddcc23d9520d4 # v2.1.5
with:
go-version: 1.17
- name: Cache Go modules
uses: actions/cache@d9747005de0f7240e5d35a68dca96b3f41b8b340 # v1.2.0
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- 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
- name: goimports
run: |
if [ "$(goimports -l . | wc -l)" -ne 0 ]
then
echo "The following files were found to have import formatting issues:"
goimports -l -l .
echo "Please run 'make fmt' to go format the above files."
exit 1
fi
- name: golangci-lint
uses: reviewdog/action-golangci-lint@02bcf8c1a9febe8620f1ca523b18dd64f82296db # v1.25.0
- name: Checking unused pkgs using go mod tidy
run: |
make unused-package-check
tests:
runs-on: ubuntu-latest
needs: pre-checks
steps:
- name: Checkout
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0
- name: Unshallow
run: git fetch --prune --unshallow
- name: Set up Go
uses: actions/setup-go@424fc82d43fa5a37540bae62709ddcc23d9520d4 # v2.1.5
with:
go-version: 1.17
- name: Cache Go modules
uses: actions/cache@d9747005de0f7240e5d35a68dca96b3f41b8b340 # v1.2.0
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Kyverno unit test
run: |
export PROJECT_PATH=$(pwd)
make test-unit

View file

@ -78,8 +78,8 @@ docker-get-initContainer-digest:
docker-build-initContainer-local: docker-build-initContainer-local:
CGO_ENABLED=0 GOOS=linux go build -o $(PWD)/$(INITC_PATH)/kyvernopre -ldflags=$(LD_FLAGS) $(PWD)/$(INITC_PATH)/main.go CGO_ENABLED=0 GOOS=linux go build -o $(PWD)/$(INITC_PATH)/kyvernopre -ldflags=$(LD_FLAGS) $(PWD)/$(INITC_PATH)/main.go
@docker build -f $(PWD)/$(INITC_PATH)/localDockerfile -t $(REPO)/$(INITC_IMAGE):$(IMAGE_TAG) $(PWD)/$(INITC_PATH) @docker build -f $(PWD)/$(INITC_PATH)/localDockerfile -t $(REPO)/$(INITC_IMAGE):$(IMAGE_TAG_DEV) $(PWD)/$(INITC_PATH)
@docker tag $(REPO)/$(INITC_IMAGE):$(IMAGE_TAG) $(REPO)/$(INITC_IMAGE):latest @docker tag $(REPO)/$(INITC_IMAGE):$(IMAGE_TAG_DEV) $(REPO)/$(INITC_IMAGE):latest
docker-publish-initContainer-dev: docker-buildx-builder docker-push-initContainer-dev docker-publish-initContainer-dev: docker-buildx-builder docker-push-initContainer-dev
@ -187,7 +187,7 @@ docker-build-all-amd64: docker-buildx-builder docker-build-initContainer-amd64 d
# Create e2e Infrastruture # Create e2e Infrastruture
################################## ##################################
create-e2e-infrastruture: create-e2e-infrastruture: docker-build-initContainer-local docker-build-kyverno-local
chmod a+x $(PWD)/scripts/create-e2e-infrastruture.sh chmod a+x $(PWD)/scripts/create-e2e-infrastruture.sh
$(PWD)/scripts/create-e2e-infrastruture.sh $(PWD)/scripts/create-e2e-infrastruture.sh