2022-02-18 01:47:35 +00:00
|
|
|
name: cli
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- 'main'
|
|
|
|
- 'release*'
|
|
|
|
paths-ignore:
|
|
|
|
- 'README.md'
|
|
|
|
- 'docs/**'
|
|
|
|
- '.github/config.yml'
|
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- 'main'
|
|
|
|
- 'release*'
|
|
|
|
paths-ignore:
|
|
|
|
- 'README.md'
|
|
|
|
- '.github/config.yml'
|
|
|
|
|
|
|
|
permissions: read-all
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
cli-test:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2022-12-13 14:01:51 +00:00
|
|
|
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3.2.0
|
2022-02-18 01:47:35 +00:00
|
|
|
|
|
|
|
- name: Unshallow
|
|
|
|
run: git fetch --prune --unshallow
|
|
|
|
|
|
|
|
- name: Set up Go
|
2022-12-14 08:47:55 +00:00
|
|
|
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
|
2022-02-18 01:47:35 +00:00
|
|
|
with:
|
2022-12-20 13:51:55 +00:00
|
|
|
go-version: ~1.19.4
|
2022-02-18 01:47:35 +00:00
|
|
|
|
|
|
|
- name: Cache Go modules
|
2022-12-28 06:45:49 +00:00
|
|
|
uses: actions/cache@4723a57e26efda3a62cbde1812113b730952852d # pin@v3
|
2022-02-18 01:47:35 +00:00
|
|
|
with:
|
2022-09-01 17:41:48 +00:00
|
|
|
path: |
|
|
|
|
~/.cache/go-build
|
|
|
|
~/go/pkg/mod
|
2022-02-18 01:47:35 +00:00
|
|
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-go-
|
|
|
|
|
|
|
|
- name: Test Policy
|
|
|
|
run: |
|
|
|
|
if [[ ${{ github.event_name }} == "push" ]]
|
|
|
|
then
|
2022-02-24 15:34:12 +00:00
|
|
|
export TEST_GIT_BRANCH=${GITHUB_REF##*/}
|
2022-02-18 01:47:35 +00:00
|
|
|
elif [[ ${{ github.event_name }} == "pull_request" ]]
|
|
|
|
then
|
2022-02-24 15:34:12 +00:00
|
|
|
export TEST_GIT_BRANCH=${{ github.event.pull_request.base.ref }}
|
2022-02-18 01:47:35 +00:00
|
|
|
fi
|
2022-02-24 15:34:12 +00:00
|
|
|
make -j4 test-cli
|
2022-08-30 15:30:28 +00:00
|
|
|
CLI_PATH=$PWD/cmd/cli/kubectl-kyverno/kubectl-kyverno
|
2022-02-18 01:47:35 +00:00
|
|
|
$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
|