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

ci migrated (#1015)

* ci migrated

* remove travis ci

* typo fix

* delete size labeler

* fix test issues

* test ci added

* rename build workflow
This commit is contained in:
Yuvraj 2020-08-05 09:02:45 -07:00 committed by GitHub
parent 7195b20e90
commit bad0dab175
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 138 additions and 51 deletions

40
.github/workflows/go.sum vendored Normal file
View file

@ -0,0 +1,40 @@
name: gosum
on:
pull_request:
branches:
- 'master'
paths:
- '.github/workflows/gosum.yml'
- 'go.mod'
- 'go.sum'
jobs:
fix:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.14
-
name: Tidy
run: |
rm -f go.sum
go mod tidy
-
name: Create Pull Request
uses: peter-evans/create-pull-request@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "fix: go mod tidy"
title: "fix: go mod tidy"
body: |
Current `go.mod` and `go.sum` don't match the source code.
branch: go-mod-tidy
branch-suffix: timestamp
labels: automerge

View file

@ -28,12 +28,43 @@ jobs:
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
- name : binary build & kustomize
run: |
make kyverno
make initContainer
-
uses: docker/build-push-action@v1
name: kyverno docker build and publish
with:
username: ${{ secrets.DOCKERIO_USERNAME }}
password: ${{ secrets.DOCKERIO_PASSWORD }}
repository: "nirmata/kyverno"
tag_with_sha: true
push: true
path: cmd/kyverno/
dockerfile: cmd/kyverno/Dockerfile
-
uses: docker/build-push-action@v1
name: kyvernopre docker build and publish
with:
username: ${{ secrets.DOCKERIO_USERNAME }}
password: ${{ secrets.DOCKERIO_PASSWORD }}
repository: "nirmata/kyvernopre"
tag_with_sha: true
push: true
path: cmd/initContainer/
dockerfile: cmd/initContainer/Dockerfile
- uses: J12934/helm-gh-pages-action@master
name: Run Helm Publish
with:
access-token: ${{ secrets.ACCESS_TOKEN }}
deploy-branch: gh-pages
charts-folder: charts
- name: Update new version in krew-index
uses: rajatjindal/krew-release-bot@v0.0.38

58
.github/workflows/test.yaml vendored Normal file
View file

@ -0,0 +1,58 @@
name: test
on:
push:
branches:
- master
pull_request:
branches:
- master
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.ACCESS_TOKEN }}
-
name: Kyverno Test
run: |
export PROJECT_PATH=$(pwd)
make test-all

View file

@ -1,49 +0,0 @@
language: go
go:
- "1.13"
cache:
directories:
- $HOME/.cache/go-build
- $GOPATH/pkg/mod
# safelist
branches:
only:
- master
before_install:
- |
if ! git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qvE '(.md)|^(LICENSE)'
then
echo "Not running CI since only docs were changed."
exit
fi
install: go get ./...
script:
# build initContainer
- make initContainer || travis_terminate 1;
# build kyverno container
- make kyverno || travis_terminate 1;
# tests
- make test-all || travis_terminate 1;
after_script:
- curl -d "repo=https://github.com/nirmata/kyverno" https://goreportcard.com/checks
# only push images if the branch is master
after_success:
- |
if [ $TRAVIS_PULL_REQUEST == 'false' ]
then
git checkout -f
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD || travis_terminate 1
echo "pushing Kyverno image"
make docker-publish-initContainer || travis_terminate 1
echo "pushing Kyverno init container image"
make docker-publish-kyverno || travis_terminate 1
fi

View file

@ -8,8 +8,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/log"
)
const (
projectPath = "src/github.com/nirmata/kyverno"
var (
projectPath = envOr("PROJECT_PATH", "src/github.com/nirmata/kyverno")
)
// LoadFile loads file in byte buffer
@ -47,3 +47,10 @@ func ConvertToUnstructured(data []byte) (*unstructured.Unstructured, error) {
}
return resource, nil
}
func envOr(name, def string) string {
if v, ok := os.LookupEnv(name); ok {
return v
}
return def
}