From 587bb63c99067c166cc7981062028d6869e2fae2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 28 Feb 2024 18:38:52 +0000 Subject: [PATCH 01/17] [pre-commit.ci] pre-commit autoupdate (#1595) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/golangci/golangci-lint: v1.56.1 → v1.56.2](https://github.com/golangci/golangci-lint/compare/v1.56.1...v1.56.2) - [github.com/adrienverge/yamllint.git: v1.34.0 → v1.35.1](https://github.com/adrienverge/yamllint.git/compare/v1.34.0...v1.35.1) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .github/workflows/functional.yml | 157 +++++++++++++++++++++++++++++++ tests/Makefile | 14 ++- tests/suite/sample_test.go | 18 +++- 3 files changed, 185 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/functional.yml diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml new file mode 100644 index 0000000000..45613948f3 --- /dev/null +++ b/.github/workflows/functional.yml @@ -0,0 +1,157 @@ +name: Functional Testing + +on: + push: + branches: + - main + - release-* + tags: + - "v[0-9]+.[0-9]+.[0-9]+*" + +defaults: + run: + shell: bash + +permissions: + contents: read + +jobs: + vars: + name: Setting up environment + runs-on: ubuntu-22.04 + strategy: + matrix: + k8s-version: ["1.23.17", "latest"] + nginx-image: [nginx, nginx-plus] + steps: + - name: Checkout Repository + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Setup Golang Environment + uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 + with: + go-version: stable + + - name: Set GOPATH + run: echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV + + - name: Docker Buildx + uses: docker/setup-buildx-action@0d103c3126aa41d772a8362f6aa67afac040f80c # v3.1.0 + + - name: NGF Docker meta + id: ngf-meta + uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 + with: + images: | + name=ghcr.io/nginxinc/nginx-gateway-fabric + tags: | + type=semver,pattern={{version}} + type=edge + type=ref,event=pr + type=ref,event=branch,suffix=-rc,enable=${{ startsWith(github.ref, 'refs/heads/release') }} + + - name: NGINX Docker meta + id: nginx-meta + uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 + with: + images: | + name=ghcr.io/nginxinc/nginx-gateway-fabric/${{ matrix.nginx-image }} + tags: | + type=semver,pattern={{version}} + type=edge + type=ref,event=pr + type=ref,event=branch,suffix=-rc,enable=${{ startsWith(github.ref, 'refs/heads/release') }} + + - name: Build binary + uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0 + with: + version: latest + args: build --snapshot --clean + + - name: Build NGF Docker Image + uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0 + with: + file: build/Dockerfile + tags: ${{ steps.ngf-meta.outputs.tags }} + context: "." + target: goreleaser + load: true + cache-from: type=gha,scope=ngf + cache-to: type=gha,scope=ngf,mode=max + pull: true + + - name: Build NGINX Docker Image + uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0 + with: + file: build/Dockerfile${{ matrix.nginx-image == 'nginx' && '.nginx' || '' }}${{ matrix.nginx-image == 'nginx-plus' && '.nginxplus' || ''}} + tags: ${{ steps.nginx-meta.outputs.tags }} + context: "." + load: true + cache-from: type=gha,scope=${{ matrix.nginx-image }} + cache-to: type=gha,scope=${{ matrix.nginx-image }},mode=max + pull: true + build-args: | + NJS_DIR=internal/mode/static/nginx/modules/src + NGINX_CONF_DIR=internal/mode/static/nginx/conf + BUILD_AGENT=gha + + - name: Deploy Kubernetes + id: k8s + run: | + k8s_version=${{ matrix.k8s-version }} + 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}' || '' }} + echo "KUBECONFIG=${{ github.workspace }}/kube-${{ github.run_id }}" >> "$GITHUB_ENV" + working-directory: ./tests + + - name: Wait for release to exist + if: startsWith(github.ref, 'refs/tags/') + run: | + REF=${{ github.ref_name }} + until docker pull ghcr.io/nginxinc/nginx-gateway-fabric:${REF#v}; do sleep 5; done + until docker pull ghcr.io/nginxinc/nginx-gateway-fabric/nginx:${REF#v}; do sleep 5; done + + - name: Setup functionals tests + run: | + ngf_prefix=ghcr.io/nginxinc/nginx-gateway-fabric + ngf_tag=${{ steps.ngf-meta.outputs.version }} + if [ ${{ github.event_name }} == "schedule" ]; then export GW_API_VERSION=main; fi + if [ ${{ startsWith(matrix.k8s-version, '1.23') || startsWith(matrix.k8s-version, '1.24') }} == "true" ]; then export INSTALL_WEBHOOK=true; fi + make install-ngf-local-no-build${{ matrix.nginx-image == 'nginx-plus' && '-with-plus' || ''}} PREFIX=${ngf_prefix} TAG=${ngf_tag} + working-directory: ./tests + + + nginx-functional-tests: + name: Gateway Functional Tests with NGINX + runs-on: ubuntu-22.04 + needs: vars + permissions: + contents: write # needed for uploading release artifacts + steps: + - name: Run NGINX functional tests + run: | + make nginx-functional-test + working-directory: ./tests + + - name: Upload profile to release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: gh release upload ${{ github.ref_name }} results/functional/edge/edge.md + working-directory: ./tests + + nginx-plus-functional-tests: + name: Gateway Functional Tests with NGINX Plus + runs-on: ubuntu-22.04 + needs: vars + permissions: + contents: write # needed for uploading release artifacts + steps: + - name: Run NGINX Plus functional tests + run: | + make nginx-plus-functional-test + working-directory: ./tests + + - name: Upload profile to release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: gh release upload ${{ github.ref_name }} results/functional/edge/edge.md + working-directory: ./tests diff --git a/tests/Makefile b/tests/Makefile index 031e51f99f..0d57631f8d 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -9,7 +9,7 @@ GW_API_VERSION ?= 1.0.0 ## Supported Gateway API version for NGF under test K8S_VERSION ?= latest ## Expected format: 1.24 (major.minor) or latest GW_SERVICE_TYPE=NodePort GW_SVC_GKE_INTERNAL=false -GINKGO_LABEL= +GINKGO_LABEL=functional GINKGO_FLAGS= ifneq ($(GINKGO_LABEL),) @@ -47,11 +47,23 @@ load-images-with-plus: ## Load NGF and NGINX Plus images on configured kind clus cd .. && make PREFIX=$(PREFIX) TAG=$(TAG) load-images-with-plus test: ## Run the system tests against your default k8s cluster + go test -v ./suite -args --gateway-api-version=$(GW_API_VERSION) \ + --gateway-api-prev-version=$(GW_API_PREV_VERSION) --image-tag=$(TAG) --plus-enabled=$(PLUS_ENABLED) \ + --ngf-image-repo=$(PREFIX) --nginx-image-repo=$(NGINX_PREFIX) --pull-policy=$(PULL_POLICY) \ + --k8s-version=$(K8S_VERSION) --service-type=$(GW_SERVICE_TYPE) --is-gke-internal-lb=$(GW_SVC_GKE_INTERNAL) + +nginx-functional-test: ## Run the functional tests against your default k8s cluster go test -v ./suite $(GINKGO_FLAGS) -args --gateway-api-version=$(GW_API_VERSION) \ --gateway-api-prev-version=$(GW_API_PREV_VERSION) --image-tag=$(TAG) --plus-enabled=$(PLUS_ENABLED) \ --ngf-image-repo=$(PREFIX) --nginx-image-repo=$(NGINX_PREFIX) --pull-policy=$(PULL_POLICY) \ --k8s-version=$(K8S_VERSION) --service-type=$(GW_SERVICE_TYPE) --is-gke-internal-lb=$(GW_SVC_GKE_INTERNAL) +nginx-plus-functional-test: ## Run the functional tests against your default k8s cluster + go test -v ./suite $(GINKGO_FLAGS) -args --gateway-api-version=$(GW_API_VERSION) \ + --gateway-api-prev-version=$(GW_API_PREV_VERSION) --image-tag=$(TAG) --plus-enabled=true \ + --ngf-image-repo=$(PREFIX) --nginx-image-repo=$(NGINX_PLUS_PREFIX) --pull-policy=$(PULL_POLICY) \ + --k8s-version=$(K8S_VERSION) --service-type=$(GW_SERVICE_TYPE) --is-gke-internal-lb=$(GW_SVC_GKE_INTERNAL) + .PHONY: delete-kind-cluster delete-kind-cluster: ## Delete kind cluster kind delete cluster diff --git a/tests/suite/sample_test.go b/tests/suite/sample_test.go index 0e6ce59f16..ce1586f558 100644 --- a/tests/suite/sample_test.go +++ b/tests/suite/sample_test.go @@ -3,6 +3,8 @@ package suite import ( "fmt" "net/http" + "os" + "path/filepath" "strconv" . "github.com/onsi/ginkgo/v2" @@ -14,7 +16,8 @@ import ( "github.com/nginxinc/nginx-gateway-fabric/tests/framework" ) -var _ = Describe("Basic test example", func() { +var _ = Describe("Basic test example", Ordered, Label("functional"), func() { + var outFile *os.File files := []string{ "hello/hello.yaml", "hello/gateway.yaml", @@ -26,15 +29,24 @@ var _ = Describe("Basic test example", func() { }, } - BeforeEach(func() { + BeforeAll(func() { Expect(resourceManager.Apply([]client.Object{ns})).To(Succeed()) Expect(resourceManager.ApplyFromFiles(files, ns.Name)).To(Succeed()) Expect(resourceManager.WaitForAppsToBeReady(ns.Name)).To(Succeed()) + + resultsDir, err := framework.CreateResultsDir("functional", version) + Expect(err).ToNot(HaveOccurred()) + + filename := filepath.Join(resultsDir, fmt.Sprintf("%s.md", version)) + outFile, err = framework.CreateResultsFile(filename) + Expect(err).ToNot(HaveOccurred()) + Expect(framework.WriteSystemInfoToFile(outFile, clusterInfo, *plusEnabled)).To(Succeed()) }) - AfterEach(func() { + AfterAll(func() { Expect(resourceManager.DeleteFromFiles(files, ns.Name)).To(Succeed()) Expect(resourceManager.Delete([]client.Object{ns})).To(Succeed()) + outFile.Close() }) It("sends traffic", func() { From cb2f77da0eadd91ce537b5ec301ce3ca839bf2c6 Mon Sep 17 00:00:00 2001 From: salonichf5 <146118978+salonichf5@users.noreply.github.com> Date: Thu, 29 Feb 2024 10:07:42 -0700 Subject: [PATCH 02/17] update functional.yaml --- .github/workflows/functional.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index 45613948f3..95023734ca 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -7,6 +7,7 @@ on: - release-* tags: - "v[0-9]+.[0-9]+.[0-9]+*" + pull_request: defaults: run: From f8d0684275a718c5c7b6660d162a1ed44502bab9 Mon Sep 17 00:00:00 2001 From: salonichf5 <146118978+salonichf5@users.noreply.github.com> Date: Thu, 29 Feb 2024 11:27:41 -0700 Subject: [PATCH 03/17] update functional test setup --- .github/workflows/functional.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index 95023734ca..b554fc4ea9 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -118,7 +118,7 @@ jobs: if [ ${{ github.event_name }} == "schedule" ]; then export GW_API_VERSION=main; fi if [ ${{ startsWith(matrix.k8s-version, '1.23') || startsWith(matrix.k8s-version, '1.24') }} == "true" ]; then export INSTALL_WEBHOOK=true; fi make install-ngf-local-no-build${{ matrix.nginx-image == 'nginx-plus' && '-with-plus' || ''}} PREFIX=${ngf_prefix} TAG=${ngf_tag} - working-directory: ./tests + working-directory: ./ nginx-functional-tests: From 71dbf37a0f77e706d2dd33d21a981abd5c4129a6 Mon Sep 17 00:00:00 2001 From: salonichf5 <146118978+salonichf5@users.noreply.github.com> Date: Thu, 29 Feb 2024 11:42:38 -0700 Subject: [PATCH 04/17] fix job --- .github/workflows/functional.yml | 45 ++++++++------------------------ tests/Makefile | 12 +++++++-- 2 files changed, 21 insertions(+), 36 deletions(-) diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index b554fc4ea9..2dbeb3c1c6 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -117,42 +117,19 @@ jobs: ngf_tag=${{ steps.ngf-meta.outputs.version }} if [ ${{ github.event_name }} == "schedule" ]; then export GW_API_VERSION=main; fi if [ ${{ startsWith(matrix.k8s-version, '1.23') || startsWith(matrix.k8s-version, '1.24') }} == "true" ]; then export INSTALL_WEBHOOK=true; fi - make install-ngf-local-no-build${{ matrix.nginx-image == 'nginx-plus' && '-with-plus' || ''}} PREFIX=${ngf_prefix} TAG=${ngf_tag} - working-directory: ./ - - - nginx-functional-tests: - name: Gateway Functional Tests with NGINX - runs-on: ubuntu-22.04 - needs: vars - permissions: - contents: write # needed for uploading release artifacts - steps: - - name: Run NGINX functional tests - run: | - make nginx-functional-test - working-directory: ./tests - - - name: Upload profile to release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh release upload ${{ github.ref_name }} results/functional/edge/edge.md + make install-ngf-local${{ matrix.nginx-image == 'nginx-plus' && '-with-plus' || ''}} PREFIX=${ngf_prefix} TAG=${ngf_tag} working-directory: ./tests - nginx-plus-functional-tests: - name: Gateway Functional Tests with NGINX Plus - runs-on: ubuntu-22.04 - needs: vars - permissions: - contents: write # needed for uploading release artifacts - steps: - - name: Run NGINX Plus functional tests + - name: Run NGINX functional tests run: | - make nginx-plus-functional-test + ngf_tag=${{ steps.ngf-meta.outputs.version }} + if [ ${{ github.event_name }} == "schedule" ]; then export GW_API_VERSION=main; fi + make functional-test${{ matrix.nginx-image == 'nginx-plus' && '-nginx-plus' || ''}} PREFIX=${ngf_prefix} TAG=${ngf_tag} working-directory: ./tests - - name: Upload profile to release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh release upload ${{ github.ref_name }} results/functional/edge/edge.md - working-directory: ./tests + - name: Upload Coverage Report + uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + with: + name: cover-${{ github.run_id }}.html + path: ${{ github.workspace }}/cover.html + if: always() diff --git a/tests/Makefile b/tests/Makefile index 0d57631f8d..7cbd24a99f 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -46,19 +46,27 @@ load-images: ## Load NGF and NGINX images on configured kind cluster load-images-with-plus: ## Load NGF and NGINX Plus images on configured kind cluster cd .. && make PREFIX=$(PREFIX) TAG=$(TAG) load-images-with-plus +.PHONY: install-ngf-local +install-ngf-local: ## Install NGF from local build on configured kind cluster. + cd .. && make PREFIX=$(PREFIX) TAG=$(TAG) install-ngf-local-build + +.PHONY: install-ngf-local-with-plus +install-ngf-local-with-plus: ## Install NGF with NGINX Plus from local build on configured kind cluster. + cd .. && make PREFIX=$(PREFIX) TAG=$(TAG) install-ngf-local-build-with-plus + test: ## Run the system tests against your default k8s cluster go test -v ./suite -args --gateway-api-version=$(GW_API_VERSION) \ --gateway-api-prev-version=$(GW_API_PREV_VERSION) --image-tag=$(TAG) --plus-enabled=$(PLUS_ENABLED) \ --ngf-image-repo=$(PREFIX) --nginx-image-repo=$(NGINX_PREFIX) --pull-policy=$(PULL_POLICY) \ --k8s-version=$(K8S_VERSION) --service-type=$(GW_SERVICE_TYPE) --is-gke-internal-lb=$(GW_SVC_GKE_INTERNAL) -nginx-functional-test: ## Run the functional tests against your default k8s cluster +functional-test: ## Run the functional tests against your default k8s cluster go test -v ./suite $(GINKGO_FLAGS) -args --gateway-api-version=$(GW_API_VERSION) \ --gateway-api-prev-version=$(GW_API_PREV_VERSION) --image-tag=$(TAG) --plus-enabled=$(PLUS_ENABLED) \ --ngf-image-repo=$(PREFIX) --nginx-image-repo=$(NGINX_PREFIX) --pull-policy=$(PULL_POLICY) \ --k8s-version=$(K8S_VERSION) --service-type=$(GW_SERVICE_TYPE) --is-gke-internal-lb=$(GW_SVC_GKE_INTERNAL) -nginx-plus-functional-test: ## Run the functional tests against your default k8s cluster +functional-test-nginx-plus: ## Run the functional tests against your default k8s cluster go test -v ./suite $(GINKGO_FLAGS) -args --gateway-api-version=$(GW_API_VERSION) \ --gateway-api-prev-version=$(GW_API_PREV_VERSION) --image-tag=$(TAG) --plus-enabled=true \ --ngf-image-repo=$(PREFIX) --nginx-image-repo=$(NGINX_PLUS_PREFIX) --pull-policy=$(PULL_POLICY) \ From bf928ed481e36e1122a16fe484447b7aa162ff43 Mon Sep 17 00:00:00 2001 From: salonichf5 <146118978+salonichf5@users.noreply.github.com> Date: Thu, 29 Feb 2024 12:10:27 -0700 Subject: [PATCH 05/17] update coverage --- .github/workflows/functional.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index 2dbeb3c1c6..89b12cf81f 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -127,9 +127,9 @@ jobs: make functional-test${{ matrix.nginx-image == 'nginx-plus' && '-nginx-plus' || ''}} PREFIX=${ngf_prefix} TAG=${ngf_tag} working-directory: ./tests - - name: Upload Coverage Report - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - name: cover-${{ github.run_id }}.html - path: ${{ github.workspace }}/cover.html - if: always() + - name: Upload profile to release + if: ${{ matrix.k8s-version == 'latest' && startsWith(github.ref, 'refs/tags/') }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: gh release upload ${{ github.ref_name }} results/functional/edge/* + working-directory: ./tests From dd7359ad41ea9afe5274275f1c085826bb48a637 Mon Sep 17 00:00:00 2001 From: salonichf5 <146118978+salonichf5@users.noreply.github.com> Date: Thu, 29 Feb 2024 12:19:45 -0700 Subject: [PATCH 06/17] simplify make file --- .github/workflows/functional.yml | 9 --------- tests/Makefile | 28 ++++++++------------------- tests/results/functional/edge/edge.md | 26 +++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 29 deletions(-) create mode 100755 tests/results/functional/edge/edge.md diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index 89b12cf81f..00a5d5a1a0 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -111,15 +111,6 @@ jobs: until docker pull ghcr.io/nginxinc/nginx-gateway-fabric:${REF#v}; do sleep 5; done until docker pull ghcr.io/nginxinc/nginx-gateway-fabric/nginx:${REF#v}; do sleep 5; done - - name: Setup functionals tests - run: | - ngf_prefix=ghcr.io/nginxinc/nginx-gateway-fabric - ngf_tag=${{ steps.ngf-meta.outputs.version }} - if [ ${{ github.event_name }} == "schedule" ]; then export GW_API_VERSION=main; fi - if [ ${{ startsWith(matrix.k8s-version, '1.23') || startsWith(matrix.k8s-version, '1.24') }} == "true" ]; then export INSTALL_WEBHOOK=true; fi - make install-ngf-local${{ matrix.nginx-image == 'nginx-plus' && '-with-plus' || ''}} PREFIX=${ngf_prefix} TAG=${ngf_tag} - working-directory: ./tests - - name: Run NGINX functional tests run: | ngf_tag=${{ steps.ngf-meta.outputs.version }} diff --git a/tests/Makefile b/tests/Makefile index 7cbd24a99f..5963daa3fc 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -9,7 +9,7 @@ GW_API_VERSION ?= 1.0.0 ## Supported Gateway API version for NGF under test K8S_VERSION ?= latest ## Expected format: 1.24 (major.minor) or latest GW_SERVICE_TYPE=NodePort GW_SVC_GKE_INTERNAL=false -GINKGO_LABEL=functional +GINKGO_LABEL= GINKGO_FLAGS= ifneq ($(GINKGO_LABEL),) @@ -46,31 +46,19 @@ load-images: ## Load NGF and NGINX images on configured kind cluster load-images-with-plus: ## Load NGF and NGINX Plus images on configured kind cluster cd .. && make PREFIX=$(PREFIX) TAG=$(TAG) load-images-with-plus -.PHONY: install-ngf-local -install-ngf-local: ## Install NGF from local build on configured kind cluster. - cd .. && make PREFIX=$(PREFIX) TAG=$(TAG) install-ngf-local-build - -.PHONY: install-ngf-local-with-plus -install-ngf-local-with-plus: ## Install NGF with NGINX Plus from local build on configured kind cluster. - cd .. && make PREFIX=$(PREFIX) TAG=$(TAG) install-ngf-local-build-with-plus - test: ## Run the system tests against your default k8s cluster - go test -v ./suite -args --gateway-api-version=$(GW_API_VERSION) \ - --gateway-api-prev-version=$(GW_API_PREV_VERSION) --image-tag=$(TAG) --plus-enabled=$(PLUS_ENABLED) \ - --ngf-image-repo=$(PREFIX) --nginx-image-repo=$(NGINX_PREFIX) --pull-policy=$(PULL_POLICY) \ - --k8s-version=$(K8S_VERSION) --service-type=$(GW_SERVICE_TYPE) --is-gke-internal-lb=$(GW_SVC_GKE_INTERNAL) - -functional-test: ## Run the functional tests against your default k8s cluster go test -v ./suite $(GINKGO_FLAGS) -args --gateway-api-version=$(GW_API_VERSION) \ --gateway-api-prev-version=$(GW_API_PREV_VERSION) --image-tag=$(TAG) --plus-enabled=$(PLUS_ENABLED) \ --ngf-image-repo=$(PREFIX) --nginx-image-repo=$(NGINX_PREFIX) --pull-policy=$(PULL_POLICY) \ --k8s-version=$(K8S_VERSION) --service-type=$(GW_SERVICE_TYPE) --is-gke-internal-lb=$(GW_SVC_GKE_INTERNAL) -functional-test-nginx-plus: ## Run the functional tests against your default k8s cluster - go test -v ./suite $(GINKGO_FLAGS) -args --gateway-api-version=$(GW_API_VERSION) \ - --gateway-api-prev-version=$(GW_API_PREV_VERSION) --image-tag=$(TAG) --plus-enabled=true \ - --ngf-image-repo=$(PREFIX) --nginx-image-repo=$(NGINX_PLUS_PREFIX) --pull-policy=$(PULL_POLICY) \ - --k8s-version=$(K8S_VERSION) --service-type=$(GW_SERVICE_TYPE) --is-gke-internal-lb=$(GW_SVC_GKE_INTERNAL) +.PHONY: functional-test +functional-test: ## Run the functional tests with NGINX against your default k8s cluster + make test GINKGO_LABEL=functional + +.PHONY: functional-test-nginx-plus +functional-test-nginx-plus: ## Run the functional tests with NGINX Plus against your default k8s cluster + make test GINKGO_LABEL=functional PLUS_ENABLED=true .PHONY: delete-kind-cluster delete-kind-cluster: ## Delete kind cluster diff --git a/tests/results/functional/edge/edge.md b/tests/results/functional/edge/edge.md new file mode 100755 index 0000000000..5221d41c50 --- /dev/null +++ b/tests/results/functional/edge/edge.md @@ -0,0 +1,26 @@ +# Results + +## Test environment + +NGINX Plus: false + +Local Cluster: + +- Node count: 1 +- k8s version: v1.29.2 +- vCPUs per node: 12 +- RAM per node: 8034504Ki +- Max pods per node: 110 +# Results + +## Test environment + +NGINX Plus: true + +Local Cluster: + +- Node count: 1 +- k8s version: v1.29.2 +- vCPUs per node: 12 +- RAM per node: 8034504Ki +- Max pods per node: 110 From 43bc963b52f767ef5476b0a86185dfea0b5a650f Mon Sep 17 00:00:00 2001 From: salonichf5 <146118978+salonichf5@users.noreply.github.com> Date: Thu, 29 Feb 2024 12:35:05 -0700 Subject: [PATCH 07/17] update test readme --- .github/workflows/functional.yml | 7 ------- tests/README.md | 20 ++++++++++++++++++-- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index 00a5d5a1a0..d5a772d94c 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -104,13 +104,6 @@ jobs: echo "KUBECONFIG=${{ github.workspace }}/kube-${{ github.run_id }}" >> "$GITHUB_ENV" working-directory: ./tests - - name: Wait for release to exist - if: startsWith(github.ref, 'refs/tags/') - run: | - REF=${{ github.ref_name }} - until docker pull ghcr.io/nginxinc/nginx-gateway-fabric:${REF#v}; do sleep 5; done - until docker pull ghcr.io/nginxinc/nginx-gateway-fabric/nginx:${REF#v}; do sleep 5; done - - name: Run NGINX functional tests run: | ngf_tag=${{ steps.ngf-meta.outputs.version }} diff --git a/tests/README.md b/tests/README.md index b5d01b10c2..606b41d33d 100644 --- a/tests/README.md +++ b/tests/README.md @@ -37,6 +37,7 @@ make ``` ```text +build-images-with-plus Build NGF and NGINX Plus images build-images Build NGF and NGINX images cleanup-gcp Cleanup all GCP resources cleanup-router Delete the GKE router @@ -45,7 +46,10 @@ create-and-setup-vm Create and setup a GCP VM for tests create-gke-router Create a GKE router to allow egress traffic from private nodes (allows for external image pulls) create-kind-cluster Create a kind cluster delete-kind-cluster Delete kind cluster +functional-test-nginx-plus Run the functional tests with NGINX Plus against your default k8s cluster +functional-test Run the functional tests with NGINX against your default k8s cluster help Display this help +load-images-with-plus Load NGF and NGINX Plus images on configured kind cluster load-images Load NGF and NGINX images on configured kind cluster run-tests-on-vm Run the tests on a GCP VM setup-gcp-and-run-tests Create and setup a GKE router and GCP VM for tests and run the tests @@ -101,7 +105,7 @@ make build-images-with-plus load-images-with-plus TAG=$(whoami) ## Step 3 - Run the tests -### 3a - Run the tests locally +### 3a - Run all the tests locally ```makefile make test TAG=$(whoami) @@ -113,7 +117,19 @@ Or, to run the tests with NGINX Plus enabled: make test TAG=$(whoami) PLUS_ENABLED=true ``` -### 3b - Run the tests on a GKE cluster from a GCP VM +### 3b - Run the functional tests locally + +```makefile +make functional-test TAG=$(whoami) +``` + +Or, to run the tests with NGINX Plus enabled: + +```makefile +make functional-test-nginx-plus TAG=$(whoami) +``` + +### 3c - Run the tests on a GKE cluster from a GCP VM This step only applies if you would like to run the tests from a GCP based VM. From 033e1312f5c3ce56d2b1fc6e1a91a22025103514 Mon Sep 17 00:00:00 2001 From: salonichf5 <146118978+salonichf5@users.noreply.github.com> Date: Thu, 29 Feb 2024 12:44:47 -0700 Subject: [PATCH 08/17] fix workflow --- .github/workflows/functional.yml | 2 +- tests/results/functional/edge/edge.md | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index d5a772d94c..15fe00efb3 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -108,7 +108,7 @@ jobs: run: | ngf_tag=${{ steps.ngf-meta.outputs.version }} if [ ${{ github.event_name }} == "schedule" ]; then export GW_API_VERSION=main; fi - make functional-test${{ matrix.nginx-image == 'nginx-plus' && '-nginx-plus' || ''}} PREFIX=${ngf_prefix} TAG=${ngf_tag} + make functional-test${{ matrix.nginx-image == 'nginx-plus' && '-nginx-plus' || ''}} TAG=${ngf_tag} working-directory: ./tests - name: Upload profile to release diff --git a/tests/results/functional/edge/edge.md b/tests/results/functional/edge/edge.md index 5221d41c50..f2db0a3631 100755 --- a/tests/results/functional/edge/edge.md +++ b/tests/results/functional/edge/edge.md @@ -24,3 +24,16 @@ Local Cluster: - vCPUs per node: 12 - RAM per node: 8034504Ki - Max pods per node: 110 +# Results + +## Test environment + +NGINX Plus: false + +Local Cluster: + +- Node count: 1 +- k8s version: v1.29.2 +- vCPUs per node: 12 +- RAM per node: 8034504Ki +- Max pods per node: 110 From bf08c8e28be94095c36b5a34b6aa95d6d3d2413f Mon Sep 17 00:00:00 2001 From: salonichf5 <146118978+salonichf5@users.noreply.github.com> Date: Thu, 29 Feb 2024 12:58:20 -0700 Subject: [PATCH 09/17] add step in workflow --- .github/workflows/functional.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index 15fe00efb3..ecd40c91fb 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -104,11 +104,21 @@ jobs: echo "KUBECONFIG=${{ github.workspace }}/kube-${{ github.run_id }}" >> "$GITHUB_ENV" working-directory: ./tests + - name: Setup functional tests + run: | + ngf_prefix=ghcr.io/nginxinc/nginx-gateway-fabric + ngf_tag=${{ steps.ngf-meta.outputs.version }} + if [ ${{ github.event_name }} == "schedule" ]; then export GW_API_VERSION=main; fi + if [ ${{ startsWith(matrix.k8s-version, '1.23') || startsWith(matrix.k8s-version, '1.24') }} == "true" ]; then export INSTALL_WEBHOOK=true; fi + make build-images-${{ matrix.nginx-image == 'nginx-plus' && '-with-plus' || ''}} load-images-${{ matrix.nginx-image == 'nginx-plus' && '-with-plus' || ''}} PREFIX=${ngf_prefix} TAG=${ngf_tag} + working-directory: ./tests + - name: Run NGINX functional tests run: | + ngf_prefix=ghcr.io/nginxinc/nginx-gateway-fabric ngf_tag=${{ steps.ngf-meta.outputs.version }} if [ ${{ github.event_name }} == "schedule" ]; then export GW_API_VERSION=main; fi - make functional-test${{ matrix.nginx-image == 'nginx-plus' && '-nginx-plus' || ''}} TAG=${ngf_tag} + make functional-test${{ matrix.nginx-image == 'nginx-plus' && '-nginx-plus' || ''}} TAG=${ngf_tag} PREFIX=${ngf_prefix} working-directory: ./tests - name: Upload profile to release From ce17e650a9e3fe9e669d3a59474e478bd932223e Mon Sep 17 00:00:00 2001 From: salonichf5 <146118978+salonichf5@users.noreply.github.com> Date: Thu, 29 Feb 2024 13:18:19 -0700 Subject: [PATCH 10/17] fix kubernetes deployment --- .github/workflows/functional.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index ecd40c91fb..f672d1c727 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -99,10 +99,9 @@ jobs: - name: Deploy Kubernetes id: k8s run: | - k8s_version=${{ matrix.k8s-version }} - 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}' || '' }} - echo "KUBECONFIG=${{ github.workspace }}/kube-${{ github.run_id }}" >> "$GITHUB_ENV" - working-directory: ./tests + kube_config=${{ github.workspace }}/deploy/helm-chart/kube-${{ github.run_id }}-helm + make create-kind-cluster KIND_KUBE_CONFIG=${kube_config} + echo "KUBECONFIG=${kube_config}" >> "$GITHUB_ENV" - name: Setup functional tests run: | From 64e3def86c366d82f38e901fc1dccd9be7ecfc53 Mon Sep 17 00:00:00 2001 From: salonichf5 <146118978+salonichf5@users.noreply.github.com> Date: Thu, 29 Feb 2024 13:24:38 -0700 Subject: [PATCH 11/17] fix typo --- .github/workflows/functional.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index f672d1c727..3d97cfbd0c 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -109,7 +109,7 @@ jobs: ngf_tag=${{ steps.ngf-meta.outputs.version }} if [ ${{ github.event_name }} == "schedule" ]; then export GW_API_VERSION=main; fi if [ ${{ startsWith(matrix.k8s-version, '1.23') || startsWith(matrix.k8s-version, '1.24') }} == "true" ]; then export INSTALL_WEBHOOK=true; fi - make build-images-${{ matrix.nginx-image == 'nginx-plus' && '-with-plus' || ''}} load-images-${{ matrix.nginx-image == 'nginx-plus' && '-with-plus' || ''}} PREFIX=${ngf_prefix} TAG=${ngf_tag} + make build-images${{ matrix.nginx-image == 'nginx-plus' && '-with-plus' || ''}} load-images${{ matrix.nginx-image == 'nginx-plus' && '-with-plus' || ''}} PREFIX=${ngf_prefix} TAG=${ngf_tag} working-directory: ./tests - name: Run NGINX functional tests From b304df3cffed0001f35762d2aadd4f86d00237cc Mon Sep 17 00:00:00 2001 From: salonichf5 <146118978+salonichf5@users.noreply.github.com> Date: Thu, 29 Feb 2024 13:31:50 -0700 Subject: [PATCH 12/17] update job --- .github/workflows/functional.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index 3d97cfbd0c..1015b6e60e 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -105,19 +105,17 @@ jobs: - name: Setup functional tests run: | - ngf_prefix=ghcr.io/nginxinc/nginx-gateway-fabric ngf_tag=${{ steps.ngf-meta.outputs.version }} if [ ${{ github.event_name }} == "schedule" ]; then export GW_API_VERSION=main; fi if [ ${{ startsWith(matrix.k8s-version, '1.23') || startsWith(matrix.k8s-version, '1.24') }} == "true" ]; then export INSTALL_WEBHOOK=true; fi - make build-images${{ matrix.nginx-image == 'nginx-plus' && '-with-plus' || ''}} load-images${{ matrix.nginx-image == 'nginx-plus' && '-with-plus' || ''}} PREFIX=${ngf_prefix} TAG=${ngf_tag} + make build-images${{ matrix.nginx-image == 'nginx-plus' && '-with-plus' || ''}} load-images${{ matrix.nginx-image == 'nginx-plus' && '-with-plus' || ''}} TAG=${ngf_tag} working-directory: ./tests - name: Run NGINX functional tests run: | - ngf_prefix=ghcr.io/nginxinc/nginx-gateway-fabric ngf_tag=${{ steps.ngf-meta.outputs.version }} if [ ${{ github.event_name }} == "schedule" ]; then export GW_API_VERSION=main; fi - make functional-test${{ matrix.nginx-image == 'nginx-plus' && '-nginx-plus' || ''}} TAG=${ngf_tag} PREFIX=${ngf_prefix} + make functional-test${{ matrix.nginx-image == 'nginx-plus' && '-nginx-plus' || ''}} TAG=${ngf_tag} working-directory: ./tests - name: Upload profile to release From 9227ece21311f0a13898143cdfe3182712fcf176 Mon Sep 17 00:00:00 2001 From: salonichf5 <146118978+salonichf5@users.noreply.github.com> Date: Thu, 29 Feb 2024 13:56:47 -0700 Subject: [PATCH 13/17] get secret nginx plus --- .github/workflows/functional.yml | 39 +++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index 1015b6e60e..a026668fa0 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -39,6 +39,36 @@ jobs: - name: Docker Buildx uses: docker/setup-buildx-action@0d103c3126aa41d772a8362f6aa67afac040f80c # v3.1.0 + - name: Setup QEMU + uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 + with: + platforms: arm64 + + - name: Login to GitHub Container Registry + uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 + if: ${{ github.event_name != 'pull_request' && ! contains(inputs.image, 'plus') }} + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Get Id Token + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + id: idtoken + with: + script: | + let id_token = await core.getIDToken() + core.setOutput('id_token', id_token) + if: ${{ github.event_name != 'pull_request' && contains(inputs.image, 'plus')}} + + - name: Login to NGINX Registry + uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 + with: + registry: docker-mgmt.nginx.com + username: ${{ steps.idtoken.outputs.id_token }} + password: ${{ github.actor }} + if: ${{ github.event_name != 'pull_request' && contains(inputs.image, 'plus') }} + - name: NGF Docker meta id: ngf-meta uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 @@ -63,12 +93,6 @@ jobs: type=ref,event=pr type=ref,event=branch,suffix=-rc,enable=${{ startsWith(github.ref, 'refs/heads/release') }} - - name: Build binary - uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0 - with: - version: latest - args: build --snapshot --clean - - name: Build NGF Docker Image uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0 with: @@ -95,6 +119,9 @@ jobs: NJS_DIR=internal/mode/static/nginx/modules/src NGINX_CONF_DIR=internal/mode/static/nginx/conf BUILD_AGENT=gha + secrets: | + ${{ contains(inputs.image, 'plus') && format('"nginx-repo.crt={0}"', secrets.NGINX_CRT) || '' }} + ${{ contains(inputs.image, 'plus') && format('"nginx-repo.key={0}"', secrets.NGINX_KEY) || '' }} - name: Deploy Kubernetes id: k8s From 6e691f782165fac852fa32419447a6a63b526c56 Mon Sep 17 00:00:00 2001 From: salonichf5 <146118978+salonichf5@users.noreply.github.com> Date: Thu, 29 Feb 2024 14:25:10 -0700 Subject: [PATCH 14/17] remove nginx-plus --- .github/workflows/functional.yml | 47 ++++++++------------------------ tests/suite/sample_test.go | 6 ++-- 2 files changed, 15 insertions(+), 38 deletions(-) diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index a026668fa0..c1e9e9e9e7 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -17,13 +17,23 @@ permissions: contents: read jobs: - vars: + build: name: Setting up environment runs-on: ubuntu-22.04 + permissions: + contents: read # for docker/build-push-action to read repo content + security-events: write # for github/codeql-action/upload-sarif to upload SARIF results + packages: write # for docker/build-push-action to push to GHCR + id-token: write # for docker/login to login to NGINX registry + services: + registry: + image: registry:2 + ports: + - 5000:5000 strategy: matrix: k8s-version: ["1.23.17", "latest"] - nginx-image: [nginx, nginx-plus] + nginx-image: [nginx] steps: - name: Checkout Repository uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 @@ -39,36 +49,6 @@ jobs: - name: Docker Buildx uses: docker/setup-buildx-action@0d103c3126aa41d772a8362f6aa67afac040f80c # v3.1.0 - - name: Setup QEMU - uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 - with: - platforms: arm64 - - - name: Login to GitHub Container Registry - uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 - if: ${{ github.event_name != 'pull_request' && ! contains(inputs.image, 'plus') }} - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Get Id Token - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 - id: idtoken - with: - script: | - let id_token = await core.getIDToken() - core.setOutput('id_token', id_token) - if: ${{ github.event_name != 'pull_request' && contains(inputs.image, 'plus')}} - - - name: Login to NGINX Registry - uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 - with: - registry: docker-mgmt.nginx.com - username: ${{ steps.idtoken.outputs.id_token }} - password: ${{ github.actor }} - if: ${{ github.event_name != 'pull_request' && contains(inputs.image, 'plus') }} - - name: NGF Docker meta id: ngf-meta uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 @@ -119,9 +99,6 @@ jobs: NJS_DIR=internal/mode/static/nginx/modules/src NGINX_CONF_DIR=internal/mode/static/nginx/conf BUILD_AGENT=gha - secrets: | - ${{ contains(inputs.image, 'plus') && format('"nginx-repo.crt={0}"', secrets.NGINX_CRT) || '' }} - ${{ contains(inputs.image, 'plus') && format('"nginx-repo.key={0}"', secrets.NGINX_KEY) || '' }} - name: Deploy Kubernetes id: k8s diff --git a/tests/suite/sample_test.go b/tests/suite/sample_test.go index ce1586f558..f383659619 100644 --- a/tests/suite/sample_test.go +++ b/tests/suite/sample_test.go @@ -16,7 +16,7 @@ import ( "github.com/nginxinc/nginx-gateway-fabric/tests/framework" ) -var _ = Describe("Basic test example", Ordered, Label("functional"), func() { +var _ = Describe("Basic test example", Label("functional"), func() { var outFile *os.File files := []string{ "hello/hello.yaml", @@ -29,7 +29,7 @@ var _ = Describe("Basic test example", Ordered, Label("functional"), func() { }, } - BeforeAll(func() { + BeforeEach(func() { Expect(resourceManager.Apply([]client.Object{ns})).To(Succeed()) Expect(resourceManager.ApplyFromFiles(files, ns.Name)).To(Succeed()) Expect(resourceManager.WaitForAppsToBeReady(ns.Name)).To(Succeed()) @@ -43,7 +43,7 @@ var _ = Describe("Basic test example", Ordered, Label("functional"), func() { Expect(framework.WriteSystemInfoToFile(outFile, clusterInfo, *plusEnabled)).To(Succeed()) }) - AfterAll(func() { + AfterEach(func() { Expect(resourceManager.DeleteFromFiles(files, ns.Name)).To(Succeed()) Expect(resourceManager.Delete([]client.Object{ns})).To(Succeed()) outFile.Close() From cf1bbd27481e1d400fd0c6da916c894ac3b7dd83 Mon Sep 17 00:00:00 2001 From: salonichf5 <146118978+salonichf5@users.noreply.github.com> Date: Thu, 29 Feb 2024 14:40:04 -0700 Subject: [PATCH 15/17] update workflow for plus --- .github/workflows/functional.yml | 60 +++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 8 deletions(-) diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index c1e9e9e9e7..404d127165 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -8,7 +8,17 @@ on: tags: - "v[0-9]+.[0-9]+.[0-9]+*" pull_request: - + workflow_call: + inputs: + platforms: + required: true + type: string + image: + required: true + type: string + tag: + required: false + type: string defaults: run: shell: bash @@ -18,22 +28,21 @@ permissions: jobs: build: - name: Setting up environment - runs-on: ubuntu-22.04 permissions: contents: read # for docker/build-push-action to read repo content security-events: write # for github/codeql-action/upload-sarif to upload SARIF results packages: write # for docker/build-push-action to push to GHCR id-token: write # for docker/login to login to NGINX registry + runs-on: ${{ github.event_name != 'pull_request' && contains(inputs.image, 'plus') && 'kic-plus' || 'ubuntu-22.04' }} services: - registry: - image: registry:2 - ports: - - 5000:5000 + registry: + image: registry:2 + ports: + - 5000:5000 strategy: matrix: k8s-version: ["1.23.17", "latest"] - nginx-image: [nginx] + nginx-image: [nginx,nginx-plus] steps: - name: Checkout Repository uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 @@ -48,6 +57,38 @@ jobs: - name: Docker Buildx uses: docker/setup-buildx-action@0d103c3126aa41d772a8362f6aa67afac040f80c # v3.1.0 + with: + driver-opts: network=host + + - name: Setup QEMU + uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 + with: + platforms: arm64 + + - name: Login to GitHub Container Registry + uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 + if: ${{ github.event_name != 'pull_request' && ! contains(inputs.image, 'plus') }} + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Get Id Token + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + id: idtoken + with: + script: | + let id_token = await core.getIDToken() + core.setOutput('id_token', id_token) + if: ${{ github.event_name != 'pull_request' && contains(inputs.image, 'plus')}} + + - name: Login to NGINX Registry + uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 + with: + registry: docker-mgmt.nginx.com + username: ${{ steps.idtoken.outputs.id_token }} + password: ${{ github.actor }} + if: ${{ github.event_name != 'pull_request' && contains(inputs.image, 'plus') }} - name: NGF Docker meta id: ngf-meta @@ -99,6 +140,9 @@ jobs: NJS_DIR=internal/mode/static/nginx/modules/src NGINX_CONF_DIR=internal/mode/static/nginx/conf BUILD_AGENT=gha + secrets: | + ${{ contains(inputs.image, 'plus') && format('"nginx-repo.crt={0}"', secrets.NGINX_CRT) || '' }} + ${{ contains(inputs.image, 'plus') && format('"nginx-repo.key={0}"', secrets.NGINX_KEY) || '' }} - name: Deploy Kubernetes id: k8s From 5e785d8ac449efcd4da56ab985259ae06a23862d Mon Sep 17 00:00:00 2001 From: salonichf5 <146118978+salonichf5@users.noreply.github.com> Date: Thu, 29 Feb 2024 16:53:39 -0700 Subject: [PATCH 16/17] build ngf binary --- .github/workflows/functional.yml | 42 +++++++++++++++----------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index 404d127165..a8c1b7e0b6 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -33,7 +33,7 @@ jobs: security-events: write # for github/codeql-action/upload-sarif to upload SARIF results packages: write # for docker/build-push-action to push to GHCR id-token: write # for docker/login to login to NGINX registry - runs-on: ${{ github.event_name != 'pull_request' && contains(inputs.image, 'plus') && 'kic-plus' || 'ubuntu-22.04' }} + runs-on: ubuntu-22.04 services: registry: image: registry:2 @@ -65,30 +65,28 @@ jobs: with: platforms: arm64 - - name: Login to GitHub Container Registry - uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 - if: ${{ github.event_name != 'pull_request' && ! contains(inputs.image, 'plus') }} - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} + - name: Output Variables + id: vars + run: echo "go_path=$(go env GOPATH)" >> $GITHUB_OUTPUT - - name: Get Id Token - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 - id: idtoken + - name: Build binary + uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0 with: - script: | - let id_token = await core.getIDToken() - core.setOutput('id_token', id_token) - if: ${{ github.event_name != 'pull_request' && contains(inputs.image, 'plus')}} - - - name: Login to NGINX Registry - uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 + version: latest + args: ${{ github.ref_type == 'tag' && 'release' || 'build --snapshot' }} --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GOPATH: ${{ steps.vars.outputs.go_path }} + AZURE_STORAGE_ACCOUNT: ${{ secrets.AZURE_STORAGE_ACCOUNT }} + AZURE_STORAGE_KEY: ${{ secrets.AZURE_STORAGE_KEY }} + AZURE_BUCKET_NAME: ${{ secrets.AZURE_BUCKET_NAME }} + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_COMMUNITY }} + + - name: Fetch Cached Artifacts + uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 with: - registry: docker-mgmt.nginx.com - username: ${{ steps.idtoken.outputs.id_token }} - password: ${{ github.actor }} - if: ${{ github.event_name != 'pull_request' && contains(inputs.image, 'plus') }} + path: ${{ github.workspace }}/dist + key: nginx-gateway-fabric-${{ github.run_id }}-${{ github.run_number }} - name: NGF Docker meta id: ngf-meta From b790d6a09cdb0badea7e49364de6415defdfea45 Mon Sep 17 00:00:00 2001 From: salonichf5 <146118978+salonichf5@users.noreply.github.com> Date: Fri, 1 Mar 2024 10:08:45 -0700 Subject: [PATCH 17/17] update go modules --- .github/workflows/functional.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index a8c1b7e0b6..e2e66eb7d7 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -100,6 +100,11 @@ jobs: type=ref,event=pr type=ref,event=branch,suffix=-rc,enable=${{ startsWith(github.ref, 'refs/heads/release') }} + - name: Update Go Modules + if: ${{ github.event_name == 'schedule' }} + run: make update-go-modules + working-directory: ./conformance + - name: NGINX Docker meta id: nginx-meta uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1