|
| 1 | +name: Functional Testing |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - release-* |
| 8 | + tags: |
| 9 | + - "v[0-9]+.[0-9]+.[0-9]+*" |
| 10 | + pull_request: |
| 11 | + |
| 12 | +defaults: |
| 13 | + run: |
| 14 | + shell: bash |
| 15 | + |
| 16 | +concurrency: |
| 17 | + group: ${{ github.ref_name }}-functional |
| 18 | + cancel-in-progress: true |
| 19 | + |
| 20 | +permissions: |
| 21 | + contents: read |
| 22 | + |
| 23 | +jobs: |
| 24 | + functional-tests: |
| 25 | + name: Gateway Functional Tests |
| 26 | + runs-on: ubuntu-22.04 |
| 27 | + strategy: |
| 28 | + matrix: |
| 29 | + k8s-version: ["1.23.17", "latest"] |
| 30 | + nginx-image: [nginx, nginx-plus] |
| 31 | + steps: |
| 32 | + - name: Checkout Repository |
| 33 | + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 |
| 34 | + |
| 35 | + - name: Setup Golang Environment |
| 36 | + uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 |
| 37 | + with: |
| 38 | + go-version: stable |
| 39 | + |
| 40 | + - name: Set GOPATH |
| 41 | + run: echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV |
| 42 | + |
| 43 | + - name: Docker Buildx |
| 44 | + uses: docker/setup-buildx-action@0d103c3126aa41d772a8362f6aa67afac040f80c # v3.1.0 |
| 45 | + |
| 46 | + |
| 47 | + - name: NGF Docker meta |
| 48 | + id: ngf-meta |
| 49 | + uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 |
| 50 | + with: |
| 51 | + images: | |
| 52 | + name=ghcr.io/nginxinc/nginx-gateway-fabric |
| 53 | + tags: | |
| 54 | + type=semver,pattern={{version}} |
| 55 | + type=edge |
| 56 | + type=ref,event=pr |
| 57 | + type=ref,event=branch,suffix=-rc,enable=${{ startsWith(github.ref, 'refs/heads/release') }} |
| 58 | +
|
| 59 | + - name: NGINX Docker meta |
| 60 | + id: nginx-meta |
| 61 | + uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 |
| 62 | + with: |
| 63 | + images: | |
| 64 | + name=ghcr.io/nginxinc/nginx-gateway-fabric/${{ matrix.nginx-image }} |
| 65 | + tags: | |
| 66 | + type=semver,pattern={{version}} |
| 67 | + type=edge |
| 68 | + type=ref,event=pr |
| 69 | + type=ref,event=branch,suffix=-rc,enable=${{ startsWith(github.ref, 'refs/heads/release') }} |
| 70 | +
|
| 71 | + - name: Build binary |
| 72 | + uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0 |
| 73 | + with: |
| 74 | + version: latest |
| 75 | + args: build --snapshot --clean |
| 76 | + |
| 77 | + - name: Build NGF Docker Image |
| 78 | + uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0 |
| 79 | + with: |
| 80 | + file: build/Dockerfile |
| 81 | + tags: ${{ steps.ngf-meta.outputs.tags }} |
| 82 | + context: "." |
| 83 | + load: true |
| 84 | + cache-from: type=gha,scope=ngf |
| 85 | + cache-to: type=gha,scope=ngf,mode=max |
| 86 | + pull: true |
| 87 | + target: goreleaser |
| 88 | + |
| 89 | + - name: Build NGINX Docker Image |
| 90 | + uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0 |
| 91 | + with: |
| 92 | + file: build/Dockerfile${{ matrix.nginx-image == 'nginx' && '.nginx' || '' }}${{ matrix.nginx-image == 'nginx-plus' && '.nginxplus' || ''}} |
| 93 | + tags: ${{ steps.nginx-meta.outputs.tags }} |
| 94 | + context: "." |
| 95 | + load: true |
| 96 | + cache-from: type=gha,scope=${{ matrix.nginx-image }} |
| 97 | + cache-to: type=gha,scope=${{ matrix.nginx-image }},mode=max |
| 98 | + pull: true |
| 99 | + build-args: | |
| 100 | + NJS_DIR=internal/mode/static/nginx/modules/src |
| 101 | + NGINX_CONF_DIR=internal/mode/static/nginx/conf |
| 102 | + BUILD_AGENT=gha |
| 103 | +
|
| 104 | + - name: Deploy Kubernetes |
| 105 | + id: k8s |
| 106 | + run: | |
| 107 | + k8s_version=${{ matrix.k8s-version }} |
| 108 | + make create-kind-cluster KIND_KUBE_CONFIG=${{ github.workspace }}/kube-${{ github.run_id }} ${{ ! contains(matrix.k8s-version, 'latest') && 'KIND_IMAGE=kindest/node:v${k8s_version}' || '' }} |
| 109 | + echo "KUBECONFIG=${{ github.workspace }}/kube-${{ github.run_id }}" >> "$GITHUB_ENV" |
| 110 | +
|
| 111 | + - name: Setup functional tests |
| 112 | + id: setup |
| 113 | + run: | |
| 114 | + ngf_prefix=ghcr.io/nginxinc/nginx-gateway-fabric |
| 115 | + ngf_tag=${{ steps.ngf-meta.outputs.version }} |
| 116 | + make load-images${{ matrix.nginx-image == 'nginx-plus' && '-with-plus' || ''}} PREFIX=${ngf_prefix} TAG=${ngf_tag} |
| 117 | + working-directory: ./tests |
| 118 | + |
| 119 | + - name: Run functional tests |
| 120 | + run: | |
| 121 | + ngf_prefix=ghcr.io/nginxinc/nginx-gateway-fabric |
| 122 | + ngf_tag=${{ steps.ngf-meta.outputs.version }} |
| 123 | + make test${{ matrix.nginx-image == 'nginx-plus' && '-with-plus' || ''}} PREFIX=${ngf_prefix} TAG=${ngf_tag} |
| 124 | + working-directory: ./tests |
0 commit comments