open-cluster-management.io/governance-policy-propagator@v0.13.0/.github/workflows/kind.yml (about) 1 name: KinD tests 2 3 on: 4 push: 5 branches: 6 - main 7 - release-[0-9]+.[0-9]+ 8 pull_request: 9 branches: 10 - main 11 - release-[0-9]+.[0-9]+ 12 13 defaults: 14 run: 15 shell: bash 16 17 jobs: 18 unit-tests: 19 runs-on: ubuntu-latest 20 name: Unit Tests 21 steps: 22 - name: Checkout Governance Policy Propagator 23 uses: actions/checkout@v4 24 25 - name: Set up Go 26 uses: actions/setup-go@v5 27 with: 28 go-version-file: go.mod 29 30 - name: Verify modules 31 run: | 32 go mod verify 33 34 - name: Verify format 35 run: | 36 make fmt 37 git diff --exit-code 38 make lint 39 40 - name: Verify deploy/operator.yaml 41 run: | 42 make generate 43 make generate-operator-yaml 44 git diff --exit-code 45 46 - name: Unit and Integration Tests 47 run: | 48 make test 49 50 - name: Unit Test Coverage 51 if: ${{ github.event_name == 'pull_request' }} 52 run: | 53 make test-coverage 54 55 - name: Upload Unit Test Coverage 56 if: ${{ github.event_name == 'pull_request' }} 57 uses: actions/upload-artifact@v4 58 with: 59 name: coverage_unit 60 path: coverage_unit.out 61 62 kind-tests: 63 runs-on: ubuntu-latest 64 env: 65 REGISTRY: localhost:5000 66 strategy: 67 fail-fast: false 68 matrix: 69 # Run tests on minimum and newest supported OCP Kubernetes 70 # The "minimum" tag is set in the Makefile 71 # KinD tags: https://hub.docker.com/r/kindest/node/tags 72 kind: 73 - 'minimum' 74 - 'latest' 75 name: KinD tests 76 steps: 77 - name: Checkout Governance Policy Propagator 78 uses: actions/checkout@v4 79 80 - name: Set up Go 81 uses: actions/setup-go@v5 82 with: 83 go-version-file: go.mod 84 85 - name: Create K8s KinD Cluster - ${{ matrix.kind }} 86 env: 87 KIND_VERSION: ${{ matrix.kind }} 88 run: | 89 make kind-bootstrap-cluster-dev 90 91 - name: Ensure Service Account kubeconfig 92 run: | 93 KUBECONFIG=${PWD}/kubeconfig_hub make kind-ensure-sa 94 95 - name: E2E Tests 96 run: | 97 export GOPATH=$(go env GOPATH) 98 KUBECONFIG=${PWD}/kubeconfig_hub make e2e-test-coverage 99 100 - name: Upload E2E Test Coverage 101 if: ${{ github.event_name == 'pull_request' && matrix.kind == 'latest'}} 102 uses: actions/upload-artifact@v4 103 with: 104 name: coverage_e2e 105 path: coverage_e2e.out 106 107 - name: E2E Tests for Compliance Events API 108 run: | 109 KUBECONFIG=${PWD}/kubeconfig_hub make e2e-test-coverage-compliance-events-api 110 111 - name: Upload Compliance Events API Test Coverage 112 if: ${{ github.event_name == 'pull_request' && matrix.kind == 'latest'}} 113 uses: actions/upload-artifact@v4 114 with: 115 name: coverage_e2e_compliance_events_api 116 path: coverage_e2e_compliance_events_api.out 117 118 - name: Verify Deployment Configuration 119 run: | 120 make webhook 121 make build-images 122 KUBECONFIG=${PWD}/kubeconfig_hub_e2e make kind-deploy-controller-dev 123 124 - name: E2E Tests for Webhook 125 run: | 126 KUBECONFIG=${PWD}/kubeconfig_hub make e2e-test-webhook 127 128 - name: Debug 129 if: ${{ failure() }} 130 run: | 131 make e2e-debug 132 133 - name: Clean up cluster 134 if: ${{ always() }} 135 run: | 136 make kind-delete-cluster 137 138 policyautomation-tests: 139 runs-on: ubuntu-latest 140 env: 141 REGISTRY: localhost:5000 142 strategy: 143 fail-fast: false 144 matrix: 145 # Run tests on minimum and newest supported OCP Kubernetes 146 # The "minimum" tag is set in the Makefile 147 # KinD tags: https://hub.docker.com/r/kindest/node/tags 148 kind: 149 - 'minimum' 150 - 'latest' 151 name: PolicyAutomation tests 152 steps: 153 - name: Checkout Governance Policy Propagator 154 uses: actions/checkout@v4 155 156 - name: Set up Go 157 uses: actions/setup-go@v5 158 id: go 159 with: 160 go-version-file: go.mod 161 162 - name: Create K8s KinD Cluster - ${{ matrix.kind }} 163 env: 164 KIND_VERSION: ${{ matrix.kind }} 165 run: | 166 make kind-bootstrap-cluster-dev 167 168 - name: PolicyAutomation E2E Tests 169 run: | 170 export GOPATH=$(go env GOPATH) 171 KUBECONFIG=${PWD}/kubeconfig_hub make e2e-test-coverage-policyautomation 172 173 - name: Upload PolicyAutomation Test Coverage 174 if: ${{ github.event_name == 'pull_request' && matrix.kind == 'latest'}} 175 uses: actions/upload-artifact@v4 176 with: 177 name: coverage_e2e_policyautomation 178 path: coverage_e2e_policyautomation.out 179 180 - name: Debug 181 if: ${{ failure() }} 182 run: | 183 make e2e-debug 184 185 - name: Clean up cluster 186 if: ${{ always() }} 187 run: | 188 make kind-delete-cluster 189 190 coverage-verification: 191 defaults: 192 run: 193 working-directory: '.' 194 runs-on: ubuntu-latest 195 name: Test Coverage Verification 196 if: ${{ github.event_name == 'pull_request' }} 197 needs: [unit-tests, kind-tests, policyautomation-tests] 198 199 steps: 200 - name: Checkout Governance Policy Propagator 201 uses: actions/checkout@v4 202 203 - name: Set up Go 204 uses: actions/setup-go@v5 205 with: 206 go-version-file: go.mod 207 208 - name: Download Unit Coverage Result 209 uses: actions/download-artifact@v4 210 with: 211 name: coverage_unit 212 213 - name: Download E2E Coverage Result 214 uses: actions/download-artifact@v4 215 with: 216 name: coverage_e2e 217 218 - name: Download Compliance Events Coverage Result 219 uses: actions/download-artifact@v4 220 with: 221 name: coverage_e2e_compliance_events_api 222 223 - name: Download PolicyAutomation Coverage Result 224 uses: actions/download-artifact@v4 225 with: 226 name: coverage_e2e_policyautomation 227 228 - name: Test Coverage Verification 229 run: | 230 make coverage-verify 231 make gosec-scan