From e58e606f6f411f8d8f61e4a4ea20b77311e94d1a Mon Sep 17 00:00:00 2001 From: yonipeleg33 <51454184+yonipeleg33@users.noreply.github.com> Date: Thu, 20 Jun 2024 17:23:15 +0300 Subject: [PATCH] CI: verify no untracked files in the clients folder (#7905) * add verify_clients_untracked_files.sh * fix job * review fixes * add make target --- .github/workflows/test.yaml | 4 ++- Makefile | 3 ++ scripts/verify_clients_untracked_files.sh | 34 +++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100755 scripts/verify_clients_untracked_files.sh diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index d0337b68273..178cdc83d38 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -26,7 +26,9 @@ jobs: - name: Generate code env: NODE_OPTIONS: "--max-old-space-size=4096" - run: make gen + run: | + make gen + make validate-clients-untracked-files - name: Checks validator env: GOLANGCI_LINT_FLAGS: --out-format github-actions diff --git a/Makefile b/Makefile index 144e2a860a6..057d1ca8223 100644 --- a/Makefile +++ b/Makefile @@ -357,3 +357,6 @@ help: ## Show Help menu # helpers gen: gen-ui gen-api gen-code clients gen-docs + +validate-clients-untracked-files: + scripts/verify_clients_untracked_files.sh diff --git a/scripts/verify_clients_untracked_files.sh b/scripts/verify_clients_untracked_files.sh new file mode 100755 index 00000000000..1900513599e --- /dev/null +++ b/scripts/verify_clients_untracked_files.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +set -euo pipefail + +echo "Checking for untracked files in 'clients/'..." + +if git status --porcelain clients/ | grep -E '^\?\?'; then + cat << EOF +Error: Untracked files found in the 'clients/' directory. + +The 'clients/' directory contains auto-generated code that must be tracked in Git. Untracked files suggest new files were created and need to be added. + +To resolve this: + +1. Remove the 'clients/' directory: + rm -fr clients/ + +2. Restore 'clients/' to the last commit: + git restore -- clients/ + +3. Regenerate files in 'clients/': + make gen + +4. Stage the regenerated files: + git add clients/ + +5. Commit the changes: + git commit -m 'Regenerate clients/ files' +EOF + exit 1 +else + echo "No untracked files found." + exit 0 +fi