From 7a485d702f33e4f7b43ae69f01e61220ffaa9736 Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Mon, 10 Jun 2024 17:09:17 -0700 Subject: [PATCH 1/2] Add generate-all make target Problem: We have a lot of generated files now and we might forget to run some targets. Soluton: Add generate-all target that calls all the other generate targets. Use this new target in the CI check and in the release PR to make sure everything is up to date. --- .github/workflows/ci.yml | 34 ++++++++++++++++---------------- .github/workflows/release-pr.yml | 4 ++-- Makefile | 11 +++++++---- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8ca02bf965..a4b9bfb04c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,20 +66,8 @@ jobs: run: go mod tidy && git diff --exit-code -- go.mod go.sum working-directory: tests - - name: Check if generated go files are up to date - run: make generate && git diff --exit-code - - - name: Check if generated CRDs and types are up to date - run: make generate-crds && git diff --exit-code - - - name: Check if generated manifests are up to date - run: make generate-manifests && git diff --exit-code - - - name: Check if helm docs are up to date - run: make helm-docs && git diff --exit-code - - - name: Check if API docs are up to date - run: make generate-api-docs && git diff --exit-code + - name: Check if all the generated files are up to date + run: make generate-all && git diff --exit-code unit-tests: name: Unit Tests @@ -230,7 +218,11 @@ jobs: fail-fast: false matrix: image: [nginx, plus] - k8s-version: ["${{ needs.vars.outputs.min_k8s_version }}", "${{ needs.vars.outputs.k8s_latest }}"] + k8s-version: + [ + "${{ needs.vars.outputs.min_k8s_version }}", + "${{ needs.vars.outputs.k8s_latest }}", + ] uses: ./.github/workflows/functional.yml with: image: ${{ matrix.image }} @@ -245,7 +237,11 @@ jobs: fail-fast: false matrix: image: [nginx, plus] - k8s-version: ["${{ needs.vars.outputs.min_k8s_version }}", "${{ needs.vars.outputs.k8s_latest }}"] + k8s-version: + [ + "${{ needs.vars.outputs.min_k8s_version }}", + "${{ needs.vars.outputs.k8s_latest }}", + ] enable-experimental: [true, false] uses: ./.github/workflows/conformance.yml with: @@ -262,7 +258,11 @@ jobs: fail-fast: false matrix: image: [nginx, plus] - k8s-version: ["${{ needs.vars.outputs.min_k8s_version }}", "${{ needs.vars.outputs.k8s_latest }}"] + k8s-version: + [ + "${{ needs.vars.outputs.min_k8s_version }}", + "${{ needs.vars.outputs.k8s_latest }}", + ] uses: ./.github/workflows/helm.yml with: image: ${{ matrix.image }} diff --git a/.github/workflows/release-pr.yml b/.github/workflows/release-pr.yml index 331d9bd6af..f9a251effc 100644 --- a/.github/workflows/release-pr.yml +++ b/.github/workflows/release-pr.yml @@ -78,7 +78,7 @@ jobs: include: "charts/nginx-gateway-fabric/*.yaml" regex: false - - name: Generate manifests and changelog + - name: Generate files and changelog run: | sed -i -e "s/v${{ steps.vars.outputs.current_version }}/v${{ inputs.version }}/g" README.md sed -i -e "s/\[${{ steps.vars.outputs.current_version }}\]/\[${{ inputs.version }}\]/g" README.md @@ -86,7 +86,7 @@ jobs: sed -i "6r .github/CHANGELOG_TEMPLATE.md" CHANGELOG.md sed -i -e "s/%%VERSION%%/${{ inputs.version }}/g" CHANGELOG.md sed -i "8a ${{ join(fromJson(steps.notes.outputs.release-sections).release-notes, '\n') }}\n" CHANGELOG.md - make generate-manifests + make generate-all - name: Create Pull Request uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v6.0.5 diff --git a/Makefile b/Makefile index 6f0978d32d..9311a5b1d6 100644 --- a/Makefile +++ b/Makefile @@ -138,6 +138,13 @@ generate-manifests: ## Generate manifests using Helm. generate-api-docs: ## Generate API docs go run github.com/ahmetb/gen-crd-api-reference-docs -config site/config/api/config.json -template-dir site/config/api -out-file site/content/reference/api.md -api-dir "github.com/nginxinc/nginx-gateway-fabric/apis" +.PHONY: generate-helm-docs +generate-helm-docs: ## Generate the Helm chart documentation + docker run --pull always --rm -v $(CURDIR):/nginx-gateway-fabric -w /nginx-gateway-fabric jnorwood/helm-docs:latest --chart-search-root=charts --template-files _templates.gotmpl --template-files README.md.gotmpl + +.PHONY: generate-all +generate-all: generate generate-crds generate-manifests generate-api-docs generate-helm-docs ## Generate all the necessary files + .PHONY: clean clean: ## Clean the build -rm -r $(OUT_DIR) @@ -202,10 +209,6 @@ njs-unit-test: ## Run unit tests for the njs httpmatches module lint-helm: ## Run the helm chart linter docker run --pull always --rm -v $(CURDIR):/nginx-gateway-fabric -w /nginx-gateway-fabric quay.io/helmpack/chart-testing:latest ct lint --config .ct.yaml -.PHONY: helm-docs -helm-docs: ## Generate the Helm chart documentation - docker run --pull always --rm -v $(CURDIR):/nginx-gateway-fabric -w /nginx-gateway-fabric jnorwood/helm-docs:latest --chart-search-root=charts --template-files _templates.gotmpl --template-files README.md.gotmpl - .PHONY: load-images load-images: ## Load NGF and NGINX images on configured kind cluster. kind load docker-image $(PREFIX):$(TAG) $(NGINX_PREFIX):$(TAG) From 10a70d9b93c63579b6fb7b1a280c0687ceffe02d Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Thu, 20 Jun 2024 10:22:02 +0200 Subject: [PATCH 2/2] update docs --- docs/developer/quickstart.md | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/docs/developer/quickstart.md b/docs/developer/quickstart.md index 83b889371d..0b0a7a8845 100644 --- a/docs/developer/quickstart.md +++ b/docs/developer/quickstart.md @@ -222,20 +222,10 @@ Run the following make command from the project's root directory to lint the Hel make lint-helm ``` -## Run Code Generation +## Update all the generated files -To ensure all the generated code is up to date, run the following make command from the project's root directory: +To update all the generated files, run the following make command from the project's root directory: -```shell -make generate -``` - -That command also will generate the avro scheme (`.avdl`) for product telemetry data points. - -## Update Generated Manifests - -To update the generated manifests, run the following make command from the project's root directory: - -```shell -make generate-manifests +```makefile +make generate-all ```