2024-01-27 22:32:42 +00:00
|
|
|
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
|
|
|
|
|
2022-02-18 01:47:35 +00:00
|
|
|
name: cli
|
2023-01-05 09:37:41 +00:00
|
|
|
|
2023-06-30 11:44:57 +00:00
|
|
|
permissions: {}
|
|
|
|
|
2022-02-18 01:47:35 +00:00
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
branches:
|
2024-09-10 14:52:09 +00:00
|
|
|
- main
|
|
|
|
- release-*
|
2022-02-18 01:47:35 +00:00
|
|
|
|
2023-01-06 15:24:55 +00:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2022-02-18 01:47:35 +00:00
|
|
|
jobs:
|
|
|
|
cli-test:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2024-10-24 09:42:17 +00:00
|
|
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
2023-09-27 08:24:27 +00:00
|
|
|
- name: Setup caches
|
|
|
|
uses: ./.github/actions/setup-caches
|
|
|
|
timeout-minutes: 5
|
|
|
|
continue-on-error: true
|
|
|
|
with:
|
|
|
|
build-cache-key: cli-test
|
2023-01-05 15:52:52 +00:00
|
|
|
- name: Setup build env
|
|
|
|
uses: ./.github/actions/setup-build-env
|
2023-08-30 20:44:51 +00:00
|
|
|
timeout-minutes: 10
|
2023-01-05 09:37:41 +00:00
|
|
|
- name: Setup TEST_GIT_BRANCH
|
2022-02-18 01:47:35 +00:00
|
|
|
run: |
|
|
|
|
if [[ ${{ github.event_name }} == "push" ]]
|
|
|
|
then
|
2023-06-20 12:04:06 +00:00
|
|
|
echo "TEST_GIT_BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
|
2022-02-18 01:47:35 +00:00
|
|
|
elif [[ ${{ github.event_name }} == "pull_request" ]]
|
|
|
|
then
|
2023-06-20 12:04:06 +00:00
|
|
|
echo "TEST_GIT_BRANCH=${{ github.event.pull_request.base.ref }}" >> $GITHUB_ENV
|
2022-02-18 01:47:35 +00:00
|
|
|
fi
|
2023-01-05 09:37:41 +00:00
|
|
|
- name: Test CLI
|
|
|
|
run: |
|
2023-12-20 08:37:26 +00:00
|
|
|
KYVERNO_KUBECTL_VALIDATE=false VERSION=${{ github.ref_name }} make test-cli
|
2023-01-05 09:37:41 +00:00
|
|
|
- name: Test CLI (failures)
|
|
|
|
run: |
|
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
|
2023-09-14 19:04:55 +00:00
|
|
|
|
|
|
|
kubectl-validate-cli-test:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2024-10-24 09:42:17 +00:00
|
|
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
2023-09-27 08:24:27 +00:00
|
|
|
- name: Setup caches
|
|
|
|
uses: ./.github/actions/setup-caches
|
|
|
|
timeout-minutes: 5
|
|
|
|
continue-on-error: true
|
|
|
|
with:
|
|
|
|
build-cache-key: cli-test
|
2023-09-14 19:04:55 +00:00
|
|
|
- name: Setup build env
|
|
|
|
uses: ./.github/actions/setup-build-env
|
|
|
|
timeout-minutes: 10
|
|
|
|
- name: Setup TEST_GIT_BRANCH
|
|
|
|
run: |
|
|
|
|
if [[ ${{ github.event_name }} == "push" ]]
|
|
|
|
then
|
|
|
|
echo "TEST_GIT_BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
|
|
|
|
elif [[ ${{ github.event_name }} == "pull_request" ]]
|
|
|
|
then
|
|
|
|
echo "TEST_GIT_BRANCH=${{ github.event.pull_request.base.ref }}" >> $GITHUB_ENV
|
|
|
|
fi
|
|
|
|
- name: Test CLI
|
|
|
|
run: |
|
2023-12-20 08:37:26 +00:00
|
|
|
VERSION=${{ github.ref_name }} make test-cli
|
2023-09-14 19:04:55 +00:00
|
|
|
- name: Test CLI (failures)
|
|
|
|
run: |
|
|
|
|
CLI_PATH=$PWD/cmd/cli/kubectl-kyverno/kubectl-kyverno
|
|
|
|
KYVERNO_KUBECTL_VALIDATE=true $CLI_PATH test ./test/cli/test-fail/missing-policy && exit 1 || exit 0
|
|
|
|
KYVERNO_KUBECTL_VALIDATE=true $CLI_PATH test ./test/cli/test-fail/missing-rule && exit 1 || exit 0
|
|
|
|
KYVERNO_KUBECTL_VALIDATE=true $CLI_PATH test ./test/cli/test-fail/missing-resource && exit 1 || exit 0
|