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 uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 - name: Unshallow run: git fetch --prune --unshallow - name: Set up Go uses: actions/setup-go@d0a58c1c4d2b25278816e339b944508c875f3613 # v3.4.0 with: go-version: ~1.18.6 - name: Cache Go modules uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # pin@v3 with: path: | ~/.cache/go-build ~/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 export TEST_GIT_BRANCH=${GITHUB_REF##*/} elif [[ ${{ github.event_name }} == "pull_request" ]] then export TEST_GIT_BRANCH=${{ github.event.pull_request.base.ref }} fi make -j4 test-cli CLI_PATH=$PWD/cmd/cli/kubectl-kyverno/kubectl-kyverno $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