Automate functional test in the pipeline #54
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Functional Testing | |
on: | |
push: | |
branches: | |
- main | |
- release-* | |
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: true | |
type: string | |
defaults: | |
run: | |
shell: bash | |
permissions: | |
contents: read | |
jobs: | |
functional-tests: | |
name: Gateway Functional Tests | |
permissions: | |
contents: write # for docker/build-push-action to read repo content | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
k8s-version: ["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 | |
with: | |
driver-opts: network=host | |
- name: Output Variables | |
id: vars | |
run: echo "go_path=$(go env GOPATH)" >> $GITHUB_OUTPUT | |
- name: Fetch Cached Artifacts | |
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 | |
with: | |
path: ${{ github.workspace }}/dist | |
key: nginx-gateway-fabric-${{ github.run_id }}-${{ github.run_number }} | |
- name: Update Go Modules | |
run: make update-go-modules | |
working-directory: ./tests | |
- 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: Prepare NGF files | |
run: | | |
ngf_prefix=ghcr.io/nginxinc/nginx-gateway-fabric | |
ngf_tag=${{ steps.ngf-meta.outputs.version }} | |
make update-ngf-manifest${{ matrix.nginx-image == 'nginx-plus' && '-with-plus' || ''}} PREFIX=${ngf_prefix} TAG=${ngf_tag} | |
working-directory: ./tests | |
- 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: "." | |
load: true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
pull: true | |
target: goreleaser | |
- 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 | |
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 | |
run: | | |
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 | |
id: setup | |
run: | | |
ngf_prefix=ghcr.io/nginxinc/nginx-gateway-fabric | |
ngf_tag=${{ steps.ngf-meta.outputs.version }} | |
if [ ${{ startsWith(matrix.k8s-version, '1.23') || startsWith(matrix.k8s-version, '1.24') }} == "true" ]; then export INSTALL_WEBHOOK=true; fi | |
make load-images${{ matrix.nginx-image == 'nginx-plus' && '-with-plus' || ''}} PREFIX=${ngf_prefix} TAG=${ngf_tag} | |
working-directory: ./tests | |
- name: Run functional tests | |
run: | | |
ngf_prefix=ghcr.io/nginxinc/nginx-gateway-fabric | |
ngf_tag=${{ steps.ngf-meta.outputs.version }} | |
if [ ${{ startsWith(matrix.k8s-version, '1.23') || startsWith(matrix.k8s-version, '1.24') }} == "true" ]; then export INSTALL_WEBHOOK=true; fi | |
make functional-test${{ matrix.nginx-image == 'nginx-plus' && '-nginx-plus' || ''}} PREFIX=${ngf_prefix} TAG=${ngf_tag} | |
working-directory: ./tests |