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