|
| 1 | +name: Run Regression tests |
| 2 | +run-name: Run NIC Regression workflow, triggered from ${{ github.event_name }} by @${{ github.actor }} |
| 3 | + |
| 4 | +on: |
| 5 | + schedule: |
| 6 | + - cron: 00 03 * * * |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + branch: |
| 10 | + type: string |
| 11 | + description: "Branch to run regression workflow on" |
| 12 | + default: main |
| 13 | + |
| 14 | +defaults: |
| 15 | + run: |
| 16 | + shell: bash |
| 17 | + |
| 18 | +concurrency: |
| 19 | + group: ${{ github.ref_name }}-regression |
| 20 | + cancel-in-progress: true |
| 21 | + |
| 22 | +permissions: |
| 23 | + contents: read |
| 24 | + |
| 25 | +jobs: |
| 26 | + checks: |
| 27 | + name: Checks and variables |
| 28 | + runs-on: ubuntu-22.04 |
| 29 | + permissions: |
| 30 | + contents: read |
| 31 | + id-token: write |
| 32 | + outputs: |
| 33 | + k8s_latest: ${{ steps.vars.outputs.k8s_latest }} |
| 34 | + latest_kindest_node_versions: ${{ steps.vars.outputs.latest_kindest_node_versions }} |
| 35 | + stable_tag: ${{ steps.vars.outputs.stable_tag }} |
| 36 | + branch: ${{ steps.vars.outputs.branch }} |
| 37 | + steps: |
| 38 | + - name: Checkout Repository |
| 39 | + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 |
| 40 | + with: |
| 41 | + ref: ${{ inputs.branch && inputs.branch || github.event.repository.default_branch }} |
| 42 | + |
| 43 | + - name: Output Variables |
| 44 | + id: vars |
| 45 | + run: | |
| 46 | + kindest_latest=$(curl -s "https://hub.docker.com/v2/repositories/kindest/node/tags" \ |
| 47 | + | grep -o '"name": *"[^"]*' \ |
| 48 | + | grep -o '[^"]*$' \ |
| 49 | + | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' \ |
| 50 | + | sort -rV \ |
| 51 | + | head -n 1 \ |
| 52 | + | sed 's/^.\{1\}//' \ |
| 53 | + | tr -d '\n') |
| 54 | + echo "k8s_latest=$kindest_latest" >> $GITHUB_OUTPUT |
| 55 | + kindest_versions=$(curl -s "https://hub.docker.com/v2/repositories/kindest/node/tags" \ |
| 56 | + | grep -o '"name": *"[^"]*' \ |
| 57 | + | grep -o '[^"]*$' \ |
| 58 | + | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' \ |
| 59 | + | sort -rV \ |
| 60 | + | awk -F. '!seen[$1"."$2]++' \ |
| 61 | + | head -n 7 \ |
| 62 | + | sort -V \ |
| 63 | + | sed 's/v//g' \ |
| 64 | + | sed 's/$//' \ |
| 65 | + | sed 's/, $//' \ |
| 66 | + | jq -R -s -c 'split("\n")[:-1]') |
| 67 | + echo "latest_kindest_node_versions=$kindest_versions" >> $GITHUB_OUTPUT |
| 68 | + source .github/data/version.txt |
| 69 | + ./.github/scripts/variables.sh stable_tag >> $GITHUB_OUTPUT |
| 70 | + branch=${{ github.event.repository.default_branch }} |
| 71 | + if [ -n "${{ inputs.branch }}" ]; then |
| 72 | + branch=${{ inputs.branch }} |
| 73 | + fi |
| 74 | + echo "branch=${branch}" >> $GITHUB_OUTPUT |
| 75 | +
|
| 76 | + - name: Output variables |
| 77 | + run: | |
| 78 | + echo k8s_latest: ${{ steps.vars.outputs.k8s_latest }} |
| 79 | + echo latest_kindest_node_versions: ${{ steps.vars.outputs.latest_kindest_node_versions }} |
| 80 | + echo stable_tag: ${{ steps.vars.outputs.stable_tag }} |
| 81 | + echo branch: ${{ steps.vars.outputs.branch }} |
| 82 | +
|
| 83 | + helm-tests: |
| 84 | + name: Helm Tests ${{ matrix.base-os }} |
| 85 | + runs-on: ubuntu-22.04 |
| 86 | + needs: [checks] |
| 87 | + strategy: |
| 88 | + fail-fast: false |
| 89 | + matrix: |
| 90 | + include: |
| 91 | + - base-os: debian |
| 92 | + image: gcr.io/f5-gcs-7899-ptg-ingrss-ctlr/dev/nginx-ic/nginx-ingress |
| 93 | + tag: ${{ needs.checks.outputs.stable_tag }} |
| 94 | + type: oss |
| 95 | + - base-os: debian-plus |
| 96 | + image: gcr.io/f5-gcs-7899-ptg-ingrss-ctlr/dev/nginx-ic/nginx-plus-ingress |
| 97 | + tag: ${{ needs.checks.outputs.stable_tag }} |
| 98 | + type: plus |
| 99 | + permissions: |
| 100 | + contents: read |
| 101 | + id-token: write |
| 102 | + steps: |
| 103 | + - name: Checkout Repository |
| 104 | + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 |
| 105 | + with: |
| 106 | + ref: ${{ needs.checks.outputs.branch }} |
| 107 | + |
| 108 | + - name: Authenticate to Google Cloud |
| 109 | + id: auth |
| 110 | + uses: google-github-actions/auth@71fee32a0bb7e97b4d33d548e7d957010649d8fa # v2.1.3 |
| 111 | + with: |
| 112 | + token_format: access_token |
| 113 | + workload_identity_provider: ${{ secrets.GCR_WORKLOAD_IDENTITY }} |
| 114 | + service_account: ${{ secrets.GCR_SERVICE_ACCOUNT }} |
| 115 | + |
| 116 | + - name: Login to GCR |
| 117 | + uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0 |
| 118 | + with: |
| 119 | + registry: gcr.io |
| 120 | + username: oauth2accesstoken |
| 121 | + password: ${{ steps.auth.outputs.access_token }} |
| 122 | + |
| 123 | + - name: Pull build image |
| 124 | + run: | |
| 125 | + docker pull ${{ matrix.image }}:${{ matrix.tag }} |
| 126 | +
|
| 127 | + - name: Deploy Kubernetes |
| 128 | + id: k8s |
| 129 | + run: | |
| 130 | + kind create cluster --name ${{ github.run_id }} --image=kindest/node:v${{ needs.checks.outputs.k8s_latest }} --wait 75s |
| 131 | + kind load docker-image "${{ matrix.image }}:${{ matrix.tag }}" --name ${{ github.run_id }} |
| 132 | +
|
| 133 | + - name: Install Chart |
| 134 | + run: > |
| 135 | + helm install |
| 136 | + ${{ matrix.type }} |
| 137 | + . |
| 138 | + --set controller.image.repository=${{ matrix.image }} |
| 139 | + --set controller.image.tag=${{ matrix.tag }} |
| 140 | + --set controller.service.type=NodePort |
| 141 | + --set controller.nginxplus=${{ contains(matrix.type, 'plus') && 'true' || 'false' }} |
| 142 | + --set controller.telemetryReporting.enable=false |
| 143 | + --wait |
| 144 | + working-directory: ${{ github.workspace }}/charts/nginx-ingress |
| 145 | + |
| 146 | + - name: Expose Test Ingresses |
| 147 | + run: | |
| 148 | + kubectl port-forward service/${{ matrix.type }}-nginx-ingress-controller 8080:80 8443:443 & |
| 149 | +
|
| 150 | + - name: Test HTTP |
| 151 | + run: | |
| 152 | + counter=0 |
| 153 | + max_attempts=5 |
| 154 | + until [ $(curl --write-out %{http_code} -s --output /dev/null http://localhost:8080) -eq 404 ]; do |
| 155 | + if [ ${counter} -eq ${max_attempts} ]; then |
| 156 | + exit 1 |
| 157 | + fi |
| 158 | + printf '.'; counter=$(($counter+1)); sleep 5; |
| 159 | + done |
| 160 | +
|
| 161 | + - name: Test HTTPS |
| 162 | + run: | |
| 163 | + counter=0 |
| 164 | + max_attempts=5 |
| 165 | + until [ $(curl --write-out %{http_code} -ks --output /dev/null https://localhost:8443) -eq 000 ]; do |
| 166 | + if [ ${counter} -eq ${max_attempts} ]; then |
| 167 | + exit 1 |
| 168 | + fi |
| 169 | + printf '.'; counter=$(($counter+1)); sleep 5; |
| 170 | + done |
| 171 | +
|
| 172 | + setup-regression-matrix: |
| 173 | + name: Setup Matrix for Smoke Tests |
| 174 | + runs-on: ubuntu-22.04 |
| 175 | + needs: [checks] |
| 176 | + permissions: |
| 177 | + contents: read |
| 178 | + id-token: write |
| 179 | + outputs: |
| 180 | + matrix: ${{ steps.set-matrix.outputs.matrix }} |
| 181 | + steps: |
| 182 | + - name: Checkout Repository |
| 183 | + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 |
| 184 | + with: |
| 185 | + ref: ${{ needs.checks.outputs.branch }} |
| 186 | + |
| 187 | + - id: set-matrix |
| 188 | + run: | |
| 189 | + echo "matrix=$(cat .github/data/matrix-regression.json | jq -c --argjson latest '${{ needs.checks.outputs.latest_kindest_node_versions }}' '.k8s += $latest'))" >> $GITHUB_OUTPUT |
| 190 | +
|
| 191 | + regression-tests: |
| 192 | + name: ${{ matrix.images.label }} ${{ matrix.images.image }} ${{ matrix.k8s }} regression tests |
| 193 | + runs-on: ubuntu-22.04 |
| 194 | + needs: [checks,setup-regression-matrix] |
| 195 | + strategy: |
| 196 | + fail-fast: false |
| 197 | + matrix: ${{ fromJSON(needs.setup-regression-matrix.outputs.matrix) }} |
| 198 | + permissions: |
| 199 | + contents: read |
| 200 | + id-token: write |
| 201 | + steps: |
| 202 | + - name: Checkout Repository |
| 203 | + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 |
| 204 | + with: |
| 205 | + ref: ${{ needs.checks.outputs.branch }} |
| 206 | + |
| 207 | + - name: Set image variables |
| 208 | + id: image_details |
| 209 | + run: | |
| 210 | + echo "name=gcr.io/f5-gcs-7899-ptg-ingrss-ctlr/dev/nginx-ic${{ contains(matrix.images.nap_modules, 'dos') && '-dos' || '' }}${{ contains(matrix.images.nap_modules, 'waf') && '-nap' || '' }}/nginx${{ contains(matrix.images.image, 'plus') && '-plus' || '' }}-ingress" >> $GITHUB_OUTPUT |
| 211 | + echo "tag=${{ needs.checks.outputs.stable_tag }}${{ contains(matrix.images.image, 'ubi') && '-ubi' || '' }}${{ contains(matrix.images.image, 'alpine') && '-alpine' || '' }}${{ contains(matrix.images.target, 'aws') && '-mktpl' || '' }}${{ contains(matrix.images.image, 'fips') && '-fips' || ''}}" >> $GITHUB_OUTPUT |
| 212 | +
|
| 213 | + - name: Authenticate to Google Cloud |
| 214 | + id: auth |
| 215 | + uses: google-github-actions/auth@71fee32a0bb7e97b4d33d548e7d957010649d8fa # v2.1.3 |
| 216 | + with: |
| 217 | + token_format: access_token |
| 218 | + workload_identity_provider: ${{ secrets.GCR_WORKLOAD_IDENTITY }} |
| 219 | + service_account: ${{ secrets.GCR_SERVICE_ACCOUNT }} |
| 220 | + |
| 221 | + - name: Login to GCR |
| 222 | + uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0 |
| 223 | + with: |
| 224 | + registry: gcr.io |
| 225 | + username: oauth2accesstoken |
| 226 | + password: ${{ steps.auth.outputs.access_token }} |
| 227 | + |
| 228 | + - name: NAP modules |
| 229 | + id: nap_modules |
| 230 | + run: | |
| 231 | + [[ "${{ matrix.images.nap_modules }}" == "waf,dos" ]] && modules="waf-dos" || modules="${{ matrix.images.nap_modules }}" |
| 232 | + echo "modules=${modules}" >> $GITHUB_OUTPUT |
| 233 | + if: ${{ matrix.images.nap_modules }} |
| 234 | + |
| 235 | + - name: Pull build image |
| 236 | + run: | |
| 237 | + docker pull ${{ steps.image_details.outputs.name }}:${{ steps.image_details.outputs.tag }} |
| 238 | +
|
| 239 | + - name: Run Regression Tests |
| 240 | + id: regression-tests |
| 241 | + uses: ./.github/actions/smoke-tests |
| 242 | + with: |
| 243 | + image-type: ${{ matrix.images.image }} |
| 244 | + image-name: ${{ steps.image_details.outputs.name }} |
| 245 | + tag: ${{ steps.image_details.outputs.tag }} |
| 246 | + marker: ${{ matrix.images.marker != '' && matrix.images.marker || '' }} |
| 247 | + k8s-version: ${{ matrix.k8s }} |
| 248 | + azure-ad-secret: ${{ secrets.AZURE_AD_AUTOMATION }} |
| 249 | + test-image: "gcr.io/f5-gcs-7899-ptg-ingrss-ctlr/dev/test-runner:${{ hashFiles('./tests/requirements.txt') || 'latest' }}" |
| 250 | + |
| 251 | + - name: Upload Test Results |
| 252 | + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 |
| 253 | + with: |
| 254 | + name: ${{ steps.regression-tests.outputs.test-results-name }}-${{ matrix.k8s }} |
| 255 | + path: ${{ github.workspace }}/tests/${{ steps.regression-tests.outputs.test-results-name }}-${{ matrix.k8s }}.html |
| 256 | + if: always() |
| 257 | + |
| 258 | + tag-stable: |
| 259 | + name: Tag tested image as nightly |
| 260 | + needs: [checks, regression-tests] |
| 261 | + permissions: |
| 262 | + contents: read # To checkout repository |
| 263 | + id-token: write # To sign into Google Container Registry |
| 264 | + uses: ./.github/workflows/retag-images.yml |
| 265 | + with: |
| 266 | + source_tag: ${{ needs.checks.outputs.stable_tag }} |
| 267 | + target_tag: nightly |
| 268 | + dry_run: false |
| 269 | + secrets: inherit |
| 270 | + |
| 271 | + release-oss: |
| 272 | + # pushes nightly images to docker hub |
| 273 | + name: Release Docker OSS |
| 274 | + needs: [checks, regression-tests] |
| 275 | + uses: ./.github/workflows/oss-release.yml |
| 276 | + with: |
| 277 | + gcr_release_registry: false |
| 278 | + ecr_public_registry: true |
| 279 | + dockerhub_public_registry: true |
| 280 | + quay_public_registry: true |
| 281 | + github_public_registry: true |
| 282 | + source_tag: ${{ needs.checks.outputs.stable_tag }} |
| 283 | + target_tag: "nightly" |
| 284 | + dry_run: false |
| 285 | + permissions: |
| 286 | + contents: read |
| 287 | + id-token: write |
| 288 | + packages: write |
| 289 | + secrets: inherit |
| 290 | + |
| 291 | + release-plus: |
| 292 | + # pushes plus nightly images to nginx registry |
| 293 | + name: Release Docker Plus |
| 294 | + needs: [checks, regression-tests] |
| 295 | + uses: ./.github/workflows/plus-release.yml |
| 296 | + with: |
| 297 | + nginx_registry: true |
| 298 | + gcr_release_registry: false |
| 299 | + gcr_mktpl_registry: false |
| 300 | + ecr_mktpl_registry: false |
| 301 | + az_mktpl_registry: false |
| 302 | + source_tag: ${{ needs.checks.outputs.stable_tag }} |
| 303 | + target_tag: "nightly" |
| 304 | + dry_run: false |
| 305 | + permissions: |
| 306 | + contents: read |
| 307 | + id-token: write |
| 308 | + secrets: inherit |
0 commit comments