2020-08-05 23:26:31 -07:00
|
|
|
name: build
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
2020-11-03 13:56:57 -08:00
|
|
|
- 'main'
|
2020-08-05 23:26:31 -07:00
|
|
|
pull_request:
|
|
|
|
branches:
|
2020-11-03 13:56:57 -08:00
|
|
|
- 'main'
|
2020-08-05 23:26:31 -07:00
|
|
|
|
|
|
|
jobs:
|
2021-02-23 04:18:11 +05:30
|
|
|
pre-checks:
|
2020-08-05 23:26:31 -07:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2020-12-16 01:16:53 +05:30
|
|
|
- name: Checkout
|
2020-08-05 23:26:31 -07:00
|
|
|
uses: actions/checkout@v2
|
2020-12-16 01:16:53 +05:30
|
|
|
|
|
|
|
- name: Unshallow
|
2020-08-05 23:26:31 -07:00
|
|
|
run: git fetch --prune --unshallow
|
2020-12-16 01:16:53 +05:30
|
|
|
|
|
|
|
- name: Set up Go
|
2020-08-05 23:26:31 -07:00
|
|
|
uses: actions/setup-go@v2
|
|
|
|
with:
|
2021-07-09 18:01:46 -07:00
|
|
|
go-version: 1.16
|
2020-08-05 23:26:31 -07:00
|
|
|
|
2020-12-16 01:16:53 +05:30
|
|
|
- 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-
|
|
|
|
|
2021-02-10 01:04:13 +05:30
|
|
|
- name: gofmt check
|
|
|
|
run: |
|
2021-02-23 04:18:11 +05:30
|
|
|
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
|
2021-02-10 01:04:13 +05:30
|
|
|
|
2021-10-29 11:24:26 +01:00
|
|
|
- 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
|
|
|
|
|
2020-12-16 01:16:53 +05:30
|
|
|
- name: golangci-lint
|
|
|
|
uses: reviewdog/action-golangci-lint@v1
|
|
|
|
|
2021-03-11 23:44:46 +05:30
|
|
|
- name: Checking unused pkgs using go mod tidy
|
|
|
|
run: |
|
|
|
|
make unused-package-check
|
|
|
|
|
2021-02-23 04:18:11 +05:30
|
|
|
build-init-kyverno:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: pre-checks
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Unshallow
|
|
|
|
run: git fetch --prune --unshallow
|
|
|
|
|
|
|
|
- name: Set up Go
|
|
|
|
uses: actions/setup-go@v2
|
|
|
|
with:
|
2021-07-09 18:01:46 -07:00
|
|
|
go-version: 1.16
|
2021-02-23 04:18:11 +05:30
|
|
|
|
|
|
|
- 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 Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
id: buildx
|
|
|
|
with:
|
|
|
|
install: true
|
|
|
|
|
|
|
|
- name: docker images build
|
|
|
|
run: |
|
|
|
|
make docker-build-initContainer
|
|
|
|
|
|
|
|
build-kyverno:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: pre-checks
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Unshallow
|
|
|
|
run: git fetch --prune --unshallow
|
|
|
|
|
|
|
|
- name: Set up Go
|
|
|
|
uses: actions/setup-go@v2
|
|
|
|
with:
|
2021-07-09 18:01:46 -07:00
|
|
|
go-version: 1.16
|
2021-02-23 04:18:11 +05:30
|
|
|
|
|
|
|
- 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-
|
|
|
|
|
2021-02-19 07:39:01 +05:30
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
id: buildx
|
|
|
|
with:
|
|
|
|
install: true
|
|
|
|
|
2020-10-09 18:49:29 -07:00
|
|
|
- name: docker images build
|
2020-08-11 22:02:51 +05:30
|
|
|
run: |
|
2021-02-23 04:18:11 +05:30
|
|
|
make docker-build-kyverno
|
|
|
|
|
2021-10-05 11:52:06 +05:30
|
|
|
- name: Trivy Scan Image
|
|
|
|
uses: aquasecurity/trivy-action@master
|
2021-10-29 11:24:26 +01:00
|
|
|
with:
|
2021-11-22 18:27:51 +05:30
|
|
|
scan-type: 'fs'
|
2021-10-05 11:52:06 +05:30
|
|
|
format: 'table'
|
|
|
|
exit-code: '1'
|
|
|
|
ignore-unfixed: true
|
|
|
|
vuln-type: 'os,library'
|
|
|
|
severity: 'CRITICAL,HIGH'
|
|
|
|
|
2021-02-23 04:18:11 +05:30
|
|
|
build-kyverno-cli:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: pre-checks
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Unshallow
|
|
|
|
run: git fetch --prune --unshallow
|
|
|
|
|
|
|
|
- name: Set up Go
|
|
|
|
uses: actions/setup-go@v2
|
|
|
|
with:
|
2021-07-09 18:01:46 -07:00
|
|
|
go-version: 1.16
|
2021-02-23 04:18:11 +05:30
|
|
|
|
|
|
|
- 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 Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
id: buildx
|
|
|
|
with:
|
|
|
|
install: true
|
|
|
|
|
|
|
|
- name: docker images build
|
|
|
|
run: |
|
|
|
|
make docker-build-cli
|
|
|
|
|
|
|
|
tests:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: pre-checks
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Unshallow
|
|
|
|
run: git fetch --prune --unshallow
|
|
|
|
|
|
|
|
- name: Set up Go
|
|
|
|
uses: actions/setup-go@v2
|
|
|
|
with:
|
2021-07-09 18:01:46 -07:00
|
|
|
go-version: 1.16
|
2021-02-23 04:18:11 +05:30
|
|
|
|
|
|
|
- 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-
|
2020-08-11 22:02:51 +05:30
|
|
|
|
2020-12-16 01:16:53 +05:30
|
|
|
- name: Kyverno unit test
|
2020-08-05 23:26:31 -07:00
|
|
|
run: |
|
2020-12-16 01:16:53 +05:30
|
|
|
export PROJECT_PATH=$(pwd)
|
2021-07-09 18:01:46 -07:00
|
|
|
make test-unit
|