1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-16 20:48:42 +00:00

Improve github action (#1385)

* Improve github action

Improve the github action

fix issue

Trigger Krew on relese and skip prerelease

Updated create infrastructure script

* More changes

* More changes

* Added check for prerelease

* Added check for prerelease

* Revert change
This commit is contained in:
Yuvraj 2020-12-16 01:16:53 +05:30 committed by GitHub
parent 6e25ef8af3
commit 5ecdfda4e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 115 additions and 125 deletions

View file

@ -8,38 +8,38 @@ on:
- 'main' - 'main'
jobs: jobs:
releaser: build-kyverno:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- - name: Checkout
name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
-
name: Unshallow - name: Unshallow
run: git fetch --prune --unshallow run: git fetch --prune --unshallow
-
name: Set up Go - name: Set up Go
uses: actions/setup-go@v2 uses: actions/setup-go@v2
with: with:
go-version: 1.14 go-version: 1.14
- name: Cache Go modules
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: golangci-lint
uses: reviewdog/action-golangci-lint@v1
- name: docker images build - name: docker images build
run: | run: |
make docker-build-all make docker-build-all
- name : Create Kind Cluster and setup kustomize - name: Kyverno unit test
run: | run: |
make ci export PROJECT_PATH=$(pwd)
make test-all
- name: e2e testing
run: |
echo ">>> Install Kyverno"
sed 's/imagePullPolicy:.*$/imagePullPolicy: IfNotPresent/g' ${GITHUB_WORKSPACE}/definitions/install.yaml | kubectl apply -f -
kubectl apply -f ${GITHUB_WORKSPACE}/definitions/github/rbac.yaml
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
echo ">>> Run Kyverno e2e test"
make test-e2e

66
.github/workflows/e2e.yaml vendored Normal file
View file

@ -0,0 +1,66 @@
name: build
on:
push:
branches:
- 'main'
paths-ignore:
- 'README.md'
- 'samples/**'
- 'charts/**'
- 'documentation/**'
pull_request:
branches:
- 'main'
paths-ignore:
- 'README.md'
- 'samples/**'
- 'charts/**'
- 'documentation/**'
jobs:
e2e-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Unshallow
run: git fetch --prune --unshallow
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.14
- name: Cache Go modules
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: golangci-lint
uses: reviewdog/action-golangci-lint@v1
- name: docker images build
run: |
make docker-build-all
- name : Create Kind Cluster and setup kustomize
run: |
make create-e2e-infrastruture
- name: e2e testing
run: |
echo ">>> Install Kyverno"
sed 's/imagePullPolicy:.*$/imagePullPolicy: IfNotPresent/g' ${GITHUB_WORKSPACE}/definitions/install.yaml | kubectl apply -f -
kubectl apply -f ${GITHUB_WORKSPACE}/definitions/github/rbac.yaml
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
echo ">>> Run Kyverno e2e test"
make test-e2e

View file

@ -4,7 +4,7 @@ on:
branches: branches:
- 'main' - 'main'
jobs: jobs:
push-images: push-docker-images:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout

View file

@ -1,9 +1,8 @@
name: prereleaser name: release kyverno-cli plugin
on: on:
push: release:
tags: types:
- 'v*' - published
- '!v*-rc*'
jobs: jobs:
release-cli-via-krew: release-cli-via-krew:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -15,4 +14,5 @@ jobs:
run: git fetch --prune --unshallow run: git fetch --prune --unshallow
- name: Update new version in krew-index - name: Update new version in krew-index
if: "!github.event.release.prerelease"
uses: rajatjindal/krew-release-bot@v0.0.38 uses: rajatjindal/krew-release-bot@v0.0.38

View file

@ -1,18 +1,30 @@
name: prereleaser name: releaser
on: on:
push: push:
tags: tags:
- 'v*' - 'v*'
jobs: jobs:
docker-and-e2e: create-release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Unshallow - name: Set up Go
run: git fetch --prune --unshallow uses: actions/setup-go@v2
with:
go-version: 1.14
- name: Cache Go modules
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v2 uses: actions/setup-go@v2
@ -27,36 +39,6 @@ jobs:
run: | run: |
make docker-publish-all make docker-publish-all
- name : Create Kind Cluster and setup kustomize
run: |
make ci
- name: e2e testing
run: |
echo ">>> Install Kyverno"
sed 's/imagePullPolicy:.*$/imagePullPolicy: IfNotPresent/g' ${GITHUB_WORKSPACE}/definitions/install.yaml | kubectl apply -f -
kubectl apply -f ${GITHUB_WORKSPACE}/definitions/github/rbac.yaml
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
echo ">>> Run Kyverno e2e test"
make test-e2e
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.14
- name: Run GoReleaser - name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2 uses: goreleaser/goreleaser-action@v2
with: with:
@ -79,3 +61,4 @@ jobs:
uses: helm/chart-releaser-action@v1.1.0 uses: helm/chart-releaser-action@v1.1.0
env: env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

View file

@ -1,58 +0,0 @@
name: test
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
releaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Unshallow
run: git fetch --prune --unshallow
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.14
-
name: Cache Go modules
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: golangci-lint
uses: reviewdog/action-golangci-lint@v1
-
name: Go Get
run: |
go get ./...
-
name: Build
run: |
make initContainer
make kyverno
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: --rm-dist --skip-publish --snapshot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
name: Kyverno Test
run: |
export PROJECT_PATH=$(pwd)
make test-all

View file

@ -116,13 +116,12 @@ docker-build-all: docker-build-initContainer docker-build-kyverno docker-build-c
docker-tag-all: docker-tag-repo-initContainer docker-tag-repo-kyverno docker-tag-repo-cli docker-tag-all: docker-tag-repo-initContainer docker-tag-repo-kyverno docker-tag-repo-cli
################################## ##################################
# CI Testing # Create e2e Infrastruture
################################## ##################################
ci: create-e2e-infrastruture:
echo "kustomize input" chmod a+x $(PWD)/scripts/create-e2e-infrastruture.sh
chmod a+x $(PWD)/scripts/ci.sh $(PWD)/scripts/create-e2e-infrastruture.sh
$(PWD)/scripts/ci.sh
################################## ##################################

View file

@ -20,4 +20,4 @@ echo "Installing kustomize"
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
kustomize edit set image ghcr.io/kyverno/kyverno:$hash kustomize edit set image ghcr.io/kyverno/kyverno:$hash
kustomize edit set image ghcr.io/kyverno/kyvernopre:$hash kustomize edit set image ghcr.io/kyverno/kyvernopre:$hash
kustomize build $pwd/definitions/ > $pwd/definitions/install.yaml kustomize build $pwd/definitions/ -o $pwd/definitions/install.yaml