From 62e3a650f3bfbf371803f3005961a0781581711c Mon Sep 17 00:00:00 2001 From: Dave Shoup Date: Fri, 21 Feb 2025 14:24:06 -0500 Subject: [PATCH 01/24] add pipeline to check sidecar version against OpenAPI spec and client code versions --- .semaphore/scripts/check-sidecar-version.sh | 41 +++++++++++++++++++++ .semaphore/semaphore.yml | 4 ++ .semaphore/validate-sidecar-version.yml | 25 +++++++++++++ Makefile | 4 ++ 4 files changed, 74 insertions(+) create mode 100755 .semaphore/scripts/check-sidecar-version.sh create mode 100644 .semaphore/validate-sidecar-version.yml diff --git a/.semaphore/scripts/check-sidecar-version.sh b/.semaphore/scripts/check-sidecar-version.sh new file mode 100755 index 000000000..864b3da34 --- /dev/null +++ b/.semaphore/scripts/check-sidecar-version.sh @@ -0,0 +1,41 @@ +#!/bin/bash +set -e + +# Extract version from ide-sidecar.txt (removing 'v' prefix and whitespace) +SIDECAR_VERSION_PATH=.versions/ide-sidecar.txt +SIDECAR_VERSION=$(cat "${SIDECAR_VERSION_PATH}" | sed 's/^v//' | tr -d '[:space:]') + +# Extract version from OpenAPI spec +OPENAPI_SPEC_PATH=src/clients/sidecar-openapi-specs/sidecar.openapi.yaml +OPENAPI_SPEC_VERSION=$(yq '.info.version' "${OPENAPI_SPEC_PATH}") + +# Extract version from client code +CLIENT_CODE_PATH=src/clients/sidecar/runtime.ts +CLIENT_VERSION=$(grep -o "version of the OpenAPI document: [0-9.]*" "${CLIENT_CODE_PATH}" | cut -d' ' -f6) + +# ANSI color codes +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +GRAY='\033[0;90m' +NC='\033[0m' + +# Enable color output +export TERM=xterm-color + +# Compare versions: sidecar vs OpenAPI spec vs client code +if [ "$SIDECAR_VERSION" != "$OPENAPI_SPEC_VERSION" ]; then + printf "❌ ${RED}OpenAPI spec version mismatch!${NC}\n\nMake sure to copy ${GRAY}https://github.com/confluentinc/ide-sidecar/blob/v${SIDECAR_VERSION}/src/generated/resources/openapi.yaml${NC} to ${BLUE}%s${NC}.\n\n" "$OPENAPI_SPEC_PATH" + printf "${GRAY}%s${NC} -> ${GREEN}%s${NC}\n" "$SIDECAR_VERSION_PATH" "$SIDECAR_VERSION" + printf "${GRAY}%s${NC} -> ${RED}%s${NC}\n" "$OPENAPI_SPEC_PATH" "$OPENAPI_SPEC_VERSION" + exit 1 +elif [ "$OPENAPI_SPEC_VERSION" != "$CLIENT_VERSION" ]; then + printf "❌ ${RED}Client code version mismatch!${NC}\n\nMake sure to run '${BLUE}gulp apigen${NC}' to regenerate sidecar client code.\n\n" + printf "${GRAY}%s${NC} -> ${GREEN}%s${NC}\n" "$SIDECAR_VERSION_PATH" "$SIDECAR_VERSION" + printf "${GRAY}%s${NC} -> ${GREEN}%s${NC}\n" "$OPENAPI_SPEC_PATH" "$OPENAPI_SPEC_VERSION" + printf "${GRAY}%s${NC} -> ${RED}%s${NC}\n" "$CLIENT_CODE_PATH" "$CLIENT_VERSION" + exit 1 +fi + +printf "✅ ${GREEN}All versions match: ${YELLOW}%s${NC}\n" "$SIDECAR_VERSION" diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index e75f27a40..9c7bd8c3b 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -142,3 +142,7 @@ promotions: pipeline_file: third-party-notices.yml auto_promote: when: "branch =~ '.*' and change_in(['/package.json', '/NOTICE.txt', '/scripts/notices/NOTICE-vsix_PREAMBLE.txt'], {default_branch: 'main', branch_range: '$SEMAPHORE_GIT_COMMIT_RANGE', pipeline_file: 'ignore'})" + - name: Validate Sidecar Version + pipeline_file: validate-sidecar-version.yml + auto_promote: + when: "result = 'passed' and change_in(['.versions/ide-sidecar.txt', 'src/clients/sidecar-openapi-specs/sidecar.openapi.yaml'])" diff --git a/.semaphore/validate-sidecar-version.yml b/.semaphore/validate-sidecar-version.yml new file mode 100644 index 000000000..8f0f47d62 --- /dev/null +++ b/.semaphore/validate-sidecar-version.yml @@ -0,0 +1,25 @@ +version: v1.0 +name: validate-sidecar-version +agent: + machine: + type: s1-prod-ubuntu24-04-amd64-1 + +auto_cancel: + running: + when: "branch != 'main'" + +execution_time_limit: + hours: 1 + +queue: + - when: "branch != 'main'" + processing: parallel + +blocks: + - name: "Validate Versions" + task: + jobs: + - name: "Compare ide-sidecar.txt version against OpenAPI spec version" + commands: + - checkout + - make check-sidecar-versions diff --git a/Makefile b/Makefile index 3daa6c417..a0ac17aa4 100644 --- a/Makefile +++ b/Makefile @@ -112,3 +112,7 @@ update-third-party-notices-pr: .PHONY: collect-notices-vsix collect-notices-vsix: @./scripts/notices/collect-notices-vsix.sh + +.PHONY: check-sidecar-versions +check-sidecar-versions: + @./scripts/check-sidecar-versions.sh From bccaf41f15995a2039949220d990ac1b831d0947 Mon Sep 17 00:00:00 2001 From: Dave Shoup Date: Fri, 21 Feb 2025 15:10:23 -0500 Subject: [PATCH 02/24] move check script --- {.semaphore/scripts => scripts}/check-sidecar-version.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {.semaphore/scripts => scripts}/check-sidecar-version.sh (100%) diff --git a/.semaphore/scripts/check-sidecar-version.sh b/scripts/check-sidecar-version.sh similarity index 100% rename from .semaphore/scripts/check-sidecar-version.sh rename to scripts/check-sidecar-version.sh From cad0687e5b19f51130b3e2fdb6b633aaac0644d9 Mon Sep 17 00:00:00 2001 From: Dave Shoup Date: Fri, 21 Feb 2025 15:13:38 -0500 Subject: [PATCH 03/24] rename --- scripts/{check-sidecar-version.sh => check-sidecar-versions.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/{check-sidecar-version.sh => check-sidecar-versions.sh} (100%) diff --git a/scripts/check-sidecar-version.sh b/scripts/check-sidecar-versions.sh similarity index 100% rename from scripts/check-sidecar-version.sh rename to scripts/check-sidecar-versions.sh From 8edd64fa831c318fa9b03ad5dd0da87d7427277b Mon Sep 17 00:00:00 2001 From: Dave Shoup Date: Fri, 21 Feb 2025 15:29:24 -0500 Subject: [PATCH 04/24] post a PR comment on failures --- Makefile | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index a0ac17aa4..508386913 100644 --- a/Makefile +++ b/Makefile @@ -39,10 +39,10 @@ validate-bump: .PHONY: bump-microversion bump-microversion: export VERSION_OVERRIDE=$(shell cat ./.versions/next.txt) ;\ - export VERSION_POST=$(MICROVERSION_POST) ;\ - export BUMP=none ;\ - export SKIP_TAG_RELEASE=true ;\ - $(MAKE) release-ci + export VERSION_POST=$(MICROVERSION_POST) ;\ + export BUMP=none ;\ + export SKIP_TAG_RELEASE=true ;\ + $(MAKE) release-ci .PHONY: release-current-version release-current-version: @@ -115,4 +115,17 @@ collect-notices-vsix: .PHONY: check-sidecar-versions check-sidecar-versions: - @./scripts/check-sidecar-versions.sh + @TEMP_OUTPUT=$$(mktemp) && \ + ./scripts/check-sidecar-versions.sh > $$TEMP_OUTPUT 2>&1; \ + EXIT_CODE=$$?; \ + if [ $$EXIT_CODE -ne 0 ] && [ "$$CI" = "true" ] && [ -n "$$SEMAPHORE_GIT_PR_NUMBER" ]; then \ + echo "Version check failed. Posting comment to PR #$$SEMAPHORE_GIT_PR_NUMBER"; \ + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + /repos/confluentinc/vscode/issues/$$SEMAPHORE_GIT_PR_NUMBER/comments \ + -f body="❌ **Sidecar Version Check Failed** ([commit](https://github.com/confluentinc/vscode/commit/$$SEMAPHORE_GIT_SHA))\n\n\`\`\`\n$$(cat $$TEMP_OUTPUT)\n\`\`\`\n\nPlease ensure the sidecar version in \`.versions/ide-sidecar.txt\` matches both the OpenAPI spec and generated client code versions."; \ + fi; \ + cat $$TEMP_OUTPUT; \ + rm -f $$TEMP_OUTPUT; \ + exit $$EXIT_CODE From dea408f66627c4fd2efcbd8619b203f40b6f7f74 Mon Sep 17 00:00:00 2001 From: Dave Shoup Date: Fri, 21 Feb 2025 15:35:19 -0500 Subject: [PATCH 05/24] strip ANSI escape codes before PR comment --- Makefile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 508386913..36622d3d7 100644 --- a/Makefile +++ b/Makefile @@ -116,16 +116,20 @@ collect-notices-vsix: .PHONY: check-sidecar-versions check-sidecar-versions: @TEMP_OUTPUT=$$(mktemp) && \ - ./scripts/check-sidecar-versions.sh > $$TEMP_OUTPUT 2>&1; \ + COLORED_OUTPUT=$$(mktemp) && \ + ./scripts/check-sidecar-versions.sh > $$COLORED_OUTPUT 2>&1; \ EXIT_CODE=$$?; \ + # Strip ANSI color codes for GitHub comment + sed 's/\x1b\[[0-9;]*m//g' $$COLORED_OUTPUT > $$TEMP_OUTPUT; \ if [ $$EXIT_CODE -ne 0 ] && [ "$$CI" = "true" ] && [ -n "$$SEMAPHORE_GIT_PR_NUMBER" ]; then \ echo "Version check failed. Posting comment to PR #$$SEMAPHORE_GIT_PR_NUMBER"; \ gh api \ --method POST \ -H "Accept: application/vnd.github+json" \ /repos/confluentinc/vscode/issues/$$SEMAPHORE_GIT_PR_NUMBER/comments \ - -f body="❌ **Sidecar Version Check Failed** ([commit](https://github.com/confluentinc/vscode/commit/$$SEMAPHORE_GIT_SHA))\n\n\`\`\`\n$$(cat $$TEMP_OUTPUT)\n\`\`\`\n\nPlease ensure the sidecar version in \`.versions/ide-sidecar.txt\` matches both the OpenAPI spec and generated client code versions."; \ + -f body="❌ **Sidecar Version Check Failed** ([$$SEMAPHORE_GIT_SHA](https://github.com/confluentinc/vscode/commit/$$SEMAPHORE_GIT_SHA))\n\n\`\`\`\n$$(cat $$TEMP_OUTPUT)\n\`\`\`\n\nEither:\n1. Update [.versions/ide-sidecar.txt](https://github.com/confluentinc/vscode/blob/main/.versions/ide-sidecar.txt) to match the OpenAPI spec version, or\n2. Run \`gulp apigen\` to regenerate the client code"; \ fi; \ - cat $$TEMP_OUTPUT; \ - rm -f $$TEMP_OUTPUT; \ + # Show colored output in terminal + cat $$COLORED_OUTPUT; \ + rm -f $$TEMP_OUTPUT $$COLORED_OUTPUT; \ exit $$EXIT_CODE From ef3a3af3d3680652b36409b65f0291f1c18adb54 Mon Sep 17 00:00:00 2001 From: Dave Shoup Date: Fri, 21 Feb 2025 15:39:17 -0500 Subject: [PATCH 06/24] try to fix `sed` --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 36622d3d7..4bbd7cbe8 100644 --- a/Makefile +++ b/Makefile @@ -120,7 +120,7 @@ check-sidecar-versions: ./scripts/check-sidecar-versions.sh > $$COLORED_OUTPUT 2>&1; \ EXIT_CODE=$$?; \ # Strip ANSI color codes for GitHub comment - sed 's/\x1b\[[0-9;]*m//g' $$COLORED_OUTPUT > $$TEMP_OUTPUT; \ + cat "$$COLORED_OUTPUT" | sed -E "s/\x1B\[([0-9]{1,3}(;[0-9]{1,3})*)?[mGK]//g" > "$$TEMP_OUTPUT"; \ if [ $$EXIT_CODE -ne 0 ] && [ "$$CI" = "true" ] && [ -n "$$SEMAPHORE_GIT_PR_NUMBER" ]; then \ echo "Version check failed. Posting comment to PR #$$SEMAPHORE_GIT_PR_NUMBER"; \ gh api \ From 2936a37722562113c863cb7362e47d4453f0a7ae Mon Sep 17 00:00:00 2001 From: Dave Shoup Date: Fri, 21 Feb 2025 15:45:26 -0500 Subject: [PATCH 07/24] next attempt --- Makefile | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 4bbd7cbe8..3551303ab 100644 --- a/Makefile +++ b/Makefile @@ -115,21 +115,20 @@ collect-notices-vsix: .PHONY: check-sidecar-versions check-sidecar-versions: - @TEMP_OUTPUT=$$(mktemp) && \ - COLORED_OUTPUT=$$(mktemp) && \ - ./scripts/check-sidecar-versions.sh > $$COLORED_OUTPUT 2>&1; \ - EXIT_CODE=$$?; \ - # Strip ANSI color codes for GitHub comment - cat "$$COLORED_OUTPUT" | sed -E "s/\x1B\[([0-9]{1,3}(;[0-9]{1,3})*)?[mGK]//g" > "$$TEMP_OUTPUT"; \ - if [ $$EXIT_CODE -ne 0 ] && [ "$$CI" = "true" ] && [ -n "$$SEMAPHORE_GIT_PR_NUMBER" ]; then \ - echo "Version check failed. Posting comment to PR #$$SEMAPHORE_GIT_PR_NUMBER"; \ - gh api \ - --method POST \ - -H "Accept: application/vnd.github+json" \ - /repos/confluentinc/vscode/issues/$$SEMAPHORE_GIT_PR_NUMBER/comments \ - -f body="❌ **Sidecar Version Check Failed** ([$$SEMAPHORE_GIT_SHA](https://github.com/confluentinc/vscode/commit/$$SEMAPHORE_GIT_SHA))\n\n\`\`\`\n$$(cat $$TEMP_OUTPUT)\n\`\`\`\n\nEither:\n1. Update [.versions/ide-sidecar.txt](https://github.com/confluentinc/vscode/blob/main/.versions/ide-sidecar.txt) to match the OpenAPI spec version, or\n2. Run \`gulp apigen\` to regenerate the client code"; \ - fi; \ - # Show colored output in terminal - cat $$COLORED_OUTPUT; \ - rm -f $$TEMP_OUTPUT $$COLORED_OUTPUT; \ - exit $$EXIT_CODE + @set -e; \ + TEMP_OUTPUT=$$(mktemp); \ + COLORED_OUTPUT=$$(mktemp); \ + ./scripts/check-sidecar-versions.sh > "$$COLORED_OUTPUT" 2>&1; \ + EXIT_CODE=$$?; \ + cat "$$COLORED_OUTPUT" | sed -E "s/\x1B\[([0-9]{1,3}(;[0-9]{1,3})*)?[mGK]//g" > "$$TEMP_OUTPUT"; \ + if [ "$$EXIT_CODE" -ne 0 ] && [ "$$CI" = "true" ] && [ -n "$$SEMAPHORE_GIT_PR_NUMBER" ]; then \ + echo "Version check failed. Posting comment to PR #$$SEMAPHORE_GIT_PR_NUMBER"; \ + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + "/repos/confluentinc/vscode/issues/$$SEMAPHORE_GIT_PR_NUMBER/comments" \ + -f body="❌ **Sidecar Version Check Failed** ([failing commit $$SEMAPHORE_GIT_SHA](https://github.com/confluentinc/vscode/commit/$$SEMAPHORE_GIT_SHA))\n\n\`\`\`\n$$(cat "$$TEMP_OUTPUT")\n\`\`\`\n\nEither:\n1. Update [.versions/ide-sidecar.txt](https://github.com/confluentinc/vscode/blob/main/.versions/ide-sidecar.txt) to match the OpenAPI spec version, or\n2. Run \`gulp apigen\` to regenerate the client code"; \ + fi; \ + cat "$$COLORED_OUTPUT"; \ + rm -f "$$TEMP_OUTPUT" "$$COLORED_OUTPUT"; \ + exit "$$EXIT_CODE" From ba1839686610289a64ca3cf7238e2aa94bd27acd Mon Sep 17 00:00:00 2001 From: Dave Shoup Date: Fri, 21 Feb 2025 15:50:18 -0500 Subject: [PATCH 08/24] another attempt --- Makefile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 3551303ab..eab500492 100644 --- a/Makefile +++ b/Makefile @@ -113,21 +113,22 @@ update-third-party-notices-pr: collect-notices-vsix: @./scripts/notices/collect-notices-vsix.sh +# Captures the output of the version check, strips away any ANSI escape codes, and posts a comment +# to the PR if the version check fails. .PHONY: check-sidecar-versions check-sidecar-versions: - @set -e; \ - TEMP_OUTPUT=$$(mktemp); \ + @TEMP_OUTPUT=$$(mktemp); \ COLORED_OUTPUT=$$(mktemp); \ - ./scripts/check-sidecar-versions.sh > "$$COLORED_OUTPUT" 2>&1; \ + ./scripts/check-sidecar-versions.sh > "$$COLORED_OUTPUT" 2>&1 || true; \ EXIT_CODE=$$?; \ cat "$$COLORED_OUTPUT" | sed -E "s/\x1B\[([0-9]{1,3}(;[0-9]{1,3})*)?[mGK]//g" > "$$TEMP_OUTPUT"; \ if [ "$$EXIT_CODE" -ne 0 ] && [ "$$CI" = "true" ] && [ -n "$$SEMAPHORE_GIT_PR_NUMBER" ]; then \ - echo "Version check failed. Posting comment to PR #$$SEMAPHORE_GIT_PR_NUMBER"; \ + echo "Version check failed. Posting comment to PR $$SEMAPHORE_GIT_PR_NUMBER"; \ gh api \ --method POST \ -H "Accept: application/vnd.github+json" \ "/repos/confluentinc/vscode/issues/$$SEMAPHORE_GIT_PR_NUMBER/comments" \ - -f body="❌ **Sidecar Version Check Failed** ([failing commit $$SEMAPHORE_GIT_SHA](https://github.com/confluentinc/vscode/commit/$$SEMAPHORE_GIT_SHA))\n\n\`\`\`\n$$(cat "$$TEMP_OUTPUT")\n\`\`\`\n\nEither:\n1. Update [.versions/ide-sidecar.txt](https://github.com/confluentinc/vscode/blob/main/.versions/ide-sidecar.txt) to match the OpenAPI spec version, or\n2. Run \`gulp apigen\` to regenerate the client code"; \ + -f body="❌ **Sidecar Version Check Failed** ([$$SEMAPHORE_GIT_SHA](https://github.com/confluentinc/vscode/commit/$$SEMAPHORE_GIT_SHA))\n\n\`\`\`\n$$(cat "$$TEMP_OUTPUT")\n\`\`\`\n\nEither:\n1. Update [.versions/ide-sidecar.txt](https://github.com/confluentinc/vscode/blob/main/.versions/ide-sidecar.txt) to match the OpenAPI spec version, or\n2. Run \`gulp apigen\` to regenerate the client code"; \ fi; \ cat "$$COLORED_OUTPUT"; \ rm -f "$$TEMP_OUTPUT" "$$COLORED_OUTPUT"; \ From a00373ea12713bdd503ead5f8663a330465c3d3d Mon Sep 17 00:00:00 2001 From: Dave Shoup Date: Fri, 21 Feb 2025 15:54:22 -0500 Subject: [PATCH 09/24] don't suppress the exit code --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index eab500492..88dacf4b2 100644 --- a/Makefile +++ b/Makefile @@ -119,7 +119,7 @@ collect-notices-vsix: check-sidecar-versions: @TEMP_OUTPUT=$$(mktemp); \ COLORED_OUTPUT=$$(mktemp); \ - ./scripts/check-sidecar-versions.sh > "$$COLORED_OUTPUT" 2>&1 || true; \ + ./scripts/check-sidecar-versions.sh > "$$COLORED_OUTPUT" 2>&1; \ EXIT_CODE=$$?; \ cat "$$COLORED_OUTPUT" | sed -E "s/\x1B\[([0-9]{1,3}(;[0-9]{1,3})*)?[mGK]//g" > "$$TEMP_OUTPUT"; \ if [ "$$EXIT_CODE" -ne 0 ] && [ "$$CI" = "true" ] && [ -n "$$SEMAPHORE_GIT_PR_NUMBER" ]; then \ From c77c51c25a317e8ad45549455c7da291a646f228 Mon Sep 17 00:00:00 2001 From: Dave Shoup Date: Fri, 21 Feb 2025 15:58:47 -0500 Subject: [PATCH 10/24] fix formatting for PR comment --- Makefile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 88dacf4b2..00aa64a1e 100644 --- a/Makefile +++ b/Makefile @@ -128,7 +128,16 @@ check-sidecar-versions: --method POST \ -H "Accept: application/vnd.github+json" \ "/repos/confluentinc/vscode/issues/$$SEMAPHORE_GIT_PR_NUMBER/comments" \ - -f body="❌ **Sidecar Version Check Failed** ([$$SEMAPHORE_GIT_SHA](https://github.com/confluentinc/vscode/commit/$$SEMAPHORE_GIT_SHA))\n\n\`\`\`\n$$(cat "$$TEMP_OUTPUT")\n\`\`\`\n\nEither:\n1. Update [.versions/ide-sidecar.txt](https://github.com/confluentinc/vscode/blob/main/.versions/ide-sidecar.txt) to match the OpenAPI spec version, or\n2. Run \`gulp apigen\` to regenerate the client code"; \ + -f body=$$(printf '%s\n%s\n%s\n%s\n%s\n%s' \ + "❌ **Sidecar Version Check Failed** ([$$SEMAPHORE_GIT_SHA](https://github.com/confluentinc/vscode/commit/$$SEMAPHORE_GIT_SHA))" \ + "" \ + "\`\`\`" \ + "$$(cat $$TEMP_OUTPUT)" \ + "\`\`\`" \ + "" \ + "Either:" \ + "1. Update [.versions/ide-sidecar.txt](https://github.com/confluentinc/vscode/blob/main/.versions/ide-sidecar.txt) to match the OpenAPI spec version, or" \ + "2. Run \`gulp apigen\` to regenerate the client code"); \ fi; \ cat "$$COLORED_OUTPUT"; \ rm -f "$$TEMP_OUTPUT" "$$COLORED_OUTPUT"; \ From 20eaad016b35788df7e8692e6b232a4924eeedd8 Mon Sep 17 00:00:00 2001 From: Dave Shoup Date: Fri, 21 Feb 2025 16:06:05 -0500 Subject: [PATCH 11/24] remove arrows --- scripts/check-sidecar-versions.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/check-sidecar-versions.sh b/scripts/check-sidecar-versions.sh index 864b3da34..8a6480ccf 100755 --- a/scripts/check-sidecar-versions.sh +++ b/scripts/check-sidecar-versions.sh @@ -27,14 +27,14 @@ export TERM=xterm-color # Compare versions: sidecar vs OpenAPI spec vs client code if [ "$SIDECAR_VERSION" != "$OPENAPI_SPEC_VERSION" ]; then printf "❌ ${RED}OpenAPI spec version mismatch!${NC}\n\nMake sure to copy ${GRAY}https://github.com/confluentinc/ide-sidecar/blob/v${SIDECAR_VERSION}/src/generated/resources/openapi.yaml${NC} to ${BLUE}%s${NC}.\n\n" "$OPENAPI_SPEC_PATH" - printf "${GRAY}%s${NC} -> ${GREEN}%s${NC}\n" "$SIDECAR_VERSION_PATH" "$SIDECAR_VERSION" - printf "${GRAY}%s${NC} -> ${RED}%s${NC}\n" "$OPENAPI_SPEC_PATH" "$OPENAPI_SPEC_VERSION" + printf "${GRAY}%s${NC}: ${GREEN}%s${NC}\n" "$SIDECAR_VERSION_PATH" "$SIDECAR_VERSION" + printf "${GRAY}%s${NC}: ${RED}%s${NC}\n" "$OPENAPI_SPEC_PATH" "$OPENAPI_SPEC_VERSION" exit 1 elif [ "$OPENAPI_SPEC_VERSION" != "$CLIENT_VERSION" ]; then printf "❌ ${RED}Client code version mismatch!${NC}\n\nMake sure to run '${BLUE}gulp apigen${NC}' to regenerate sidecar client code.\n\n" - printf "${GRAY}%s${NC} -> ${GREEN}%s${NC}\n" "$SIDECAR_VERSION_PATH" "$SIDECAR_VERSION" - printf "${GRAY}%s${NC} -> ${GREEN}%s${NC}\n" "$OPENAPI_SPEC_PATH" "$OPENAPI_SPEC_VERSION" - printf "${GRAY}%s${NC} -> ${RED}%s${NC}\n" "$CLIENT_CODE_PATH" "$CLIENT_VERSION" + printf "${GRAY}%s${NC}: ${GREEN}%s${NC}\n" "$SIDECAR_VERSION_PATH" "$SIDECAR_VERSION" + printf "${GRAY}%s${NC}: ${GREEN}%s${NC}\n" "$OPENAPI_SPEC_PATH" "$OPENAPI_SPEC_VERSION" + printf "${GRAY}%s${NC}: ${RED}%s${NC}\n" "$CLIENT_CODE_PATH" "$CLIENT_VERSION" exit 1 fi From cc2564194d8187b4ac81202943459507bea61d48 Mon Sep 17 00:00:00 2001 From: Dave Shoup Date: Fri, 21 Feb 2025 16:12:47 -0500 Subject: [PATCH 12/24] fix formatting again --- Makefile | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 00aa64a1e..cfced51eb 100644 --- a/Makefile +++ b/Makefile @@ -128,16 +128,15 @@ check-sidecar-versions: --method POST \ -H "Accept: application/vnd.github+json" \ "/repos/confluentinc/vscode/issues/$$SEMAPHORE_GIT_PR_NUMBER/comments" \ - -f body=$$(printf '%s\n%s\n%s\n%s\n%s\n%s' \ - "❌ **Sidecar Version Check Failed** ([$$SEMAPHORE_GIT_SHA](https://github.com/confluentinc/vscode/commit/$$SEMAPHORE_GIT_SHA))" \ - "" \ - "\`\`\`" \ - "$$(cat $$TEMP_OUTPUT)" \ - "\`\`\`" \ - "" \ - "Either:" \ - "1. Update [.versions/ide-sidecar.txt](https://github.com/confluentinc/vscode/blob/main/.versions/ide-sidecar.txt) to match the OpenAPI spec version, or" \ - "2. Run \`gulp apigen\` to regenerate the client code"); \ + -f body="❌ **Sidecar Version Check Failed** ([$$SEMAPHORE_GIT_SHA](https://github.com/confluentinc/vscode/commit/$$SEMAPHORE_GIT_SHA)) + +\`\`\` +$$(cat "$$TEMP_OUTPUT") +\`\`\` + +Either: +1. Update [.versions/ide-sidecar.txt](https://github.com/confluentinc/vscode/blob/main/.versions/ide-sidecar.txt) to match the OpenAPI spec version, or +2. Run \`gulp apigen\` to regenerate the client code"; \ fi; \ cat "$$COLORED_OUTPUT"; \ rm -f "$$TEMP_OUTPUT" "$$COLORED_OUTPUT"; \ From 0c40218bec8a8753755d5b4b010cce9bca301e22 Mon Sep 17 00:00:00 2001 From: Dave Shoup Date: Fri, 21 Feb 2025 16:22:47 -0500 Subject: [PATCH 13/24] move PR comment logic into main script --- Makefile | 25 +------------ scripts/check-sidecar-versions.sh | 61 +++++++++++++++++++++++++------ 2 files changed, 51 insertions(+), 35 deletions(-) diff --git a/Makefile b/Makefile index cfced51eb..92db1a597 100644 --- a/Makefile +++ b/Makefile @@ -117,27 +117,4 @@ collect-notices-vsix: # to the PR if the version check fails. .PHONY: check-sidecar-versions check-sidecar-versions: - @TEMP_OUTPUT=$$(mktemp); \ - COLORED_OUTPUT=$$(mktemp); \ - ./scripts/check-sidecar-versions.sh > "$$COLORED_OUTPUT" 2>&1; \ - EXIT_CODE=$$?; \ - cat "$$COLORED_OUTPUT" | sed -E "s/\x1B\[([0-9]{1,3}(;[0-9]{1,3})*)?[mGK]//g" > "$$TEMP_OUTPUT"; \ - if [ "$$EXIT_CODE" -ne 0 ] && [ "$$CI" = "true" ] && [ -n "$$SEMAPHORE_GIT_PR_NUMBER" ]; then \ - echo "Version check failed. Posting comment to PR $$SEMAPHORE_GIT_PR_NUMBER"; \ - gh api \ - --method POST \ - -H "Accept: application/vnd.github+json" \ - "/repos/confluentinc/vscode/issues/$$SEMAPHORE_GIT_PR_NUMBER/comments" \ - -f body="❌ **Sidecar Version Check Failed** ([$$SEMAPHORE_GIT_SHA](https://github.com/confluentinc/vscode/commit/$$SEMAPHORE_GIT_SHA)) - -\`\`\` -$$(cat "$$TEMP_OUTPUT") -\`\`\` - -Either: -1. Update [.versions/ide-sidecar.txt](https://github.com/confluentinc/vscode/blob/main/.versions/ide-sidecar.txt) to match the OpenAPI spec version, or -2. Run \`gulp apigen\` to regenerate the client code"; \ - fi; \ - cat "$$COLORED_OUTPUT"; \ - rm -f "$$TEMP_OUTPUT" "$$COLORED_OUTPUT"; \ - exit "$$EXIT_CODE" + @./scripts/check-sidecar-versions.sh diff --git a/scripts/check-sidecar-versions.sh b/scripts/check-sidecar-versions.sh index 8a6480ccf..abd300bba 100755 --- a/scripts/check-sidecar-versions.sh +++ b/scripts/check-sidecar-versions.sh @@ -16,7 +16,6 @@ CLIENT_VERSION=$(grep -o "version of the OpenAPI document: [0-9.]*" "${CLIENT_CO # ANSI color codes RED='\033[0;31m' GREEN='\033[0;32m' -YELLOW='\033[1;33m' BLUE='\033[0;34m' GRAY='\033[0;90m' NC='\033[0m' @@ -24,18 +23,58 @@ NC='\033[0m' # Enable color output export TERM=xterm-color +# Function to capture and post output +handle_version_mismatch() { + local TEMP_OUTPUT=$(mktemp) + local MESSAGE="$1" + + # Capture colored output first + { + printf "❌ ${RED}%s${NC}\n\n%s\n\n" "$MESSAGE" "$2" + printf "${GRAY}%s${NC}: ${GREEN}%s${NC}\n" "$SIDECAR_VERSION_PATH" "$SIDECAR_VERSION" + printf "${GRAY}%s${NC}: %s${NC}\n" "$3" "$4" + if [ -n "$5" ] && [ -n "$6" ]; then + printf "${GRAY}%s${NC}: %s${NC}\n" "$5" "$6" + fi + } | tee >(sed -E "s/\x1B\[([0-9]{1,3}(;[0-9]{1,3})*)?[mGK]//g" > "$TEMP_OUTPUT") + + # Post GitHub comment if in CI + if [ "$CI" = "true" ] && [ -n "$SEMAPHORE_GIT_PR_NUMBER" ]; then + echo "Version check failed. Posting comment to PR #$SEMAPHORE_GIT_PR_NUMBER" + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + "/repos/confluentinc/vscode/issues/$SEMAPHORE_GIT_PR_NUMBER/comments" \ + -f body="❌ **Sidecar Version Check Failed** ([failing commit $SEMAPHORE_GIT_SHA](https://github.com/confluentinc/vscode/commit/$SEMAPHORE_GIT_SHA)) + +\`\`\` +$(cat "$TEMP_OUTPUT") +\`\`\` + +Either: +1. Update [.versions/ide-sidecar.txt](https://github.com/confluentinc/vscode/blob/main/.versions/ide-sidecar.txt) to match the OpenAPI spec version, or +2. Run \`gulp apigen\` to regenerate the client code" + fi + + rm -f "$TEMP_OUTPUT" + exit 1 +} + # Compare versions: sidecar vs OpenAPI spec vs client code if [ "$SIDECAR_VERSION" != "$OPENAPI_SPEC_VERSION" ]; then - printf "❌ ${RED}OpenAPI spec version mismatch!${NC}\n\nMake sure to copy ${GRAY}https://github.com/confluentinc/ide-sidecar/blob/v${SIDECAR_VERSION}/src/generated/resources/openapi.yaml${NC} to ${BLUE}%s${NC}.\n\n" "$OPENAPI_SPEC_PATH" - printf "${GRAY}%s${NC}: ${GREEN}%s${NC}\n" "$SIDECAR_VERSION_PATH" "$SIDECAR_VERSION" - printf "${GRAY}%s${NC}: ${RED}%s${NC}\n" "$OPENAPI_SPEC_PATH" "$OPENAPI_SPEC_VERSION" - exit 1 + handle_version_mismatch \ + "OpenAPI spec version mismatch!" \ + "Make sure to copy ${GRAY}https://github.com/confluentinc/ide-sidecar/blob/v${SIDECAR_VERSION}/src/generated/resources/openapi.yaml${NC} to ${BLUE}${OPENAPI_SPEC_PATH}${NC}." \ + "$OPENAPI_SPEC_PATH" \ + "${RED}$OPENAPI_SPEC_VERSION" elif [ "$OPENAPI_SPEC_VERSION" != "$CLIENT_VERSION" ]; then - printf "❌ ${RED}Client code version mismatch!${NC}\n\nMake sure to run '${BLUE}gulp apigen${NC}' to regenerate sidecar client code.\n\n" - printf "${GRAY}%s${NC}: ${GREEN}%s${NC}\n" "$SIDECAR_VERSION_PATH" "$SIDECAR_VERSION" - printf "${GRAY}%s${NC}: ${GREEN}%s${NC}\n" "$OPENAPI_SPEC_PATH" "$OPENAPI_SPEC_VERSION" - printf "${GRAY}%s${NC}: ${RED}%s${NC}\n" "$CLIENT_CODE_PATH" "$CLIENT_VERSION" - exit 1 + handle_version_mismatch \ + "Client code version mismatch!" \ + "Make sure to run '${BLUE}gulp apigen${NC}' to regenerate sidecar client code." \ + "$OPENAPI_SPEC_PATH" \ + "${GREEN}$OPENAPI_SPEC_VERSION" \ + "$CLIENT_CODE_PATH" \ + "${RED}$CLIENT_VERSION" fi -printf "✅ ${GREEN}All versions match: ${YELLOW}%s${NC}\n" "$SIDECAR_VERSION" +printf "✅ All versions match: ${GREEN}%s${NC}\n" "$SIDECAR_VERSION" From a3a16de15cf9831ba39f07fe0f341e2b2495ee7e Mon Sep 17 00:00:00 2001 From: Dave Shoup Date: Fri, 21 Feb 2025 16:26:42 -0500 Subject: [PATCH 14/24] cleanup --- scripts/check-sidecar-versions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check-sidecar-versions.sh b/scripts/check-sidecar-versions.sh index abd300bba..af0ab788f 100755 --- a/scripts/check-sidecar-versions.sh +++ b/scripts/check-sidecar-versions.sh @@ -45,7 +45,7 @@ handle_version_mismatch() { --method POST \ -H "Accept: application/vnd.github+json" \ "/repos/confluentinc/vscode/issues/$SEMAPHORE_GIT_PR_NUMBER/comments" \ - -f body="❌ **Sidecar Version Check Failed** ([failing commit $SEMAPHORE_GIT_SHA](https://github.com/confluentinc/vscode/commit/$SEMAPHORE_GIT_SHA)) + -f body="**Sidecar Version Check Failed** (https://github.com/confluentinc/vscode/commit/$SEMAPHORE_GIT_SHA) \`\`\` $(cat "$TEMP_OUTPUT") From b6ec77a2fedd282fef8a3ea01f6174205e56bd73 Mon Sep 17 00:00:00 2001 From: Dave Shoup Date: Fri, 21 Feb 2025 16:28:54 -0500 Subject: [PATCH 15/24] fix code block formatting in PR comment --- scripts/check-sidecar-versions.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/check-sidecar-versions.sh b/scripts/check-sidecar-versions.sh index af0ab788f..39faf59c8 100755 --- a/scripts/check-sidecar-versions.sh +++ b/scripts/check-sidecar-versions.sh @@ -28,7 +28,18 @@ handle_version_mismatch() { local TEMP_OUTPUT=$(mktemp) local MESSAGE="$1" - # Capture colored output first + # Generate clean output first (no colors) + { + printf "❌ %s\n\n" "$MESSAGE" + printf "%s\n\n" "$2" | sed -E "s/\x1B\[([0-9]{1,3}(;[0-9]{1,3})*)?[mGK]//g" + printf "%s: %s\n" "$SIDECAR_VERSION_PATH" "$SIDECAR_VERSION" + printf "%s: %s\n" "$3" "$(echo "$4" | sed -E "s/\x1B\[([0-9]{1,3}(;[0-9]{1,3})*)?[mGK]//g")" + if [ -n "$5" ] && [ -n "$6" ]; then + printf "%s: %s\n" "$5" "$(echo "$6" | sed -E "s/\x1B\[([0-9]{1,3}(;[0-9]{1,3})*)?[mGK]//g")" + fi + } > "$TEMP_OUTPUT" + + # Show colored output in terminal { printf "❌ ${RED}%s${NC}\n\n%s\n\n" "$MESSAGE" "$2" printf "${GRAY}%s${NC}: ${GREEN}%s${NC}\n" "$SIDECAR_VERSION_PATH" "$SIDECAR_VERSION" @@ -36,7 +47,7 @@ handle_version_mismatch() { if [ -n "$5" ] && [ -n "$6" ]; then printf "${GRAY}%s${NC}: %s${NC}\n" "$5" "$6" fi - } | tee >(sed -E "s/\x1B\[([0-9]{1,3}(;[0-9]{1,3})*)?[mGK]//g" > "$TEMP_OUTPUT") + } # Post GitHub comment if in CI if [ "$CI" = "true" ] && [ -n "$SEMAPHORE_GIT_PR_NUMBER" ]; then From 0817173293bd7f153ca36b1638f4bedfe0a4e926 Mon Sep 17 00:00:00 2001 From: Dave Shoup Date: Fri, 21 Feb 2025 16:33:20 -0500 Subject: [PATCH 16/24] another formatting attempt --- scripts/check-sidecar-versions.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/check-sidecar-versions.sh b/scripts/check-sidecar-versions.sh index 39faf59c8..1b41a206f 100755 --- a/scripts/check-sidecar-versions.sh +++ b/scripts/check-sidecar-versions.sh @@ -27,15 +27,17 @@ export TERM=xterm-color handle_version_mismatch() { local TEMP_OUTPUT=$(mktemp) local MESSAGE="$1" + # Strip color codes from the second argument + local CLEAN_MESSAGE="$(echo "$2" | sed -E "s/\x1B\[([0-9]{1,3}(;[0-9]{1,3})*)?[mGK]//g")" # Generate clean output first (no colors) { printf "❌ %s\n\n" "$MESSAGE" - printf "%s\n\n" "$2" | sed -E "s/\x1B\[([0-9]{1,3}(;[0-9]{1,3})*)?[mGK]//g" + printf "%s\n\n" "$CLEAN_MESSAGE" printf "%s: %s\n" "$SIDECAR_VERSION_PATH" "$SIDECAR_VERSION" - printf "%s: %s\n" "$3" "$(echo "$4" | sed -E "s/\x1B\[([0-9]{1,3}(;[0-9]{1,3})*)?[mGK]//g")" + printf "%s: %s\n" "$3" "${4//\033[*([0-9;])m/}" if [ -n "$5" ] && [ -n "$6" ]; then - printf "%s: %s\n" "$5" "$(echo "$6" | sed -E "s/\x1B\[([0-9]{1,3}(;[0-9]{1,3})*)?[mGK]//g")" + printf "%s: %s\n" "$5" "${6//\033[*([0-9;])m/}" fi } > "$TEMP_OUTPUT" From c213ff27261d36e280cde778a3e346d6a6766f99 Mon Sep 17 00:00:00 2001 From: Dave Shoup Date: Fri, 21 Feb 2025 16:46:35 -0500 Subject: [PATCH 17/24] split colored formatting from PR comment formatting --- scripts/check-sidecar-versions.sh | 38 +++++++++++++++++++------------ 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/scripts/check-sidecar-versions.sh b/scripts/check-sidecar-versions.sh index 1b41a206f..ed358274d 100755 --- a/scripts/check-sidecar-versions.sh +++ b/scripts/check-sidecar-versions.sh @@ -27,27 +27,33 @@ export TERM=xterm-color handle_version_mismatch() { local TEMP_OUTPUT=$(mktemp) local MESSAGE="$1" - # Strip color codes from the second argument - local CLEAN_MESSAGE="$(echo "$2" | sed -E "s/\x1B\[([0-9]{1,3}(;[0-9]{1,3})*)?[mGK]//g")" + local INSTRUCTION="$2" # Generate clean output first (no colors) { printf "❌ %s\n\n" "$MESSAGE" - printf "%s\n\n" "$CLEAN_MESSAGE" + printf "%s\n\n" "$INSTRUCTION" printf "%s: %s\n" "$SIDECAR_VERSION_PATH" "$SIDECAR_VERSION" - printf "%s: %s\n" "$3" "${4//\033[*([0-9;])m/}" + printf "%s: %s\n" "$3" "$4" if [ -n "$5" ] && [ -n "$6" ]; then - printf "%s: %s\n" "$5" "${6//\033[*([0-9;])m/}" + printf "%s: %s\n" "$5" "$6" fi } > "$TEMP_OUTPUT" - # Show colored output in terminal + # Show colored output in terminal with added colors { - printf "❌ ${RED}%s${NC}\n\n%s\n\n" "$MESSAGE" "$2" + printf "❌ ${RED}%s${NC}\n\n" "$MESSAGE" + if [[ "$INSTRUCTION" == *"gulp apigen"* ]]; then + printf "Make sure to run '${BLUE}gulp apigen${NC}' to regenerate sidecar client code.\n\n" + else + printf "Make sure to copy ${GRAY}%s${NC} to ${BLUE}%s${NC}.\n\n" \ + "https://github.com/confluentinc/ide-sidecar/blob/v${SIDECAR_VERSION}/src/generated/resources/openapi.yaml" \ + "$OPENAPI_SPEC_PATH" + fi printf "${GRAY}%s${NC}: ${GREEN}%s${NC}\n" "$SIDECAR_VERSION_PATH" "$SIDECAR_VERSION" - printf "${GRAY}%s${NC}: %s${NC}\n" "$3" "$4" + printf "${GRAY}%s${NC}: ${RED}%s${NC}\n" "$3" "$4" if [ -n "$5" ] && [ -n "$6" ]; then - printf "${GRAY}%s${NC}: %s${NC}\n" "$5" "$6" + printf "${GRAY}%s${NC}: ${RED}%s${NC}\n" "$5" "$6" fi } @@ -75,19 +81,23 @@ Either: # Compare versions: sidecar vs OpenAPI spec vs client code if [ "$SIDECAR_VERSION" != "$OPENAPI_SPEC_VERSION" ]; then + MESSAGE="Make sure to copy https://github.com/confluentinc/ide-sidecar/blob/v${SIDECAR_VERSION}/src/generated/resources/openapi.yaml to ${OPENAPI_SPEC_PATH}." + handle_version_mismatch \ "OpenAPI spec version mismatch!" \ - "Make sure to copy ${GRAY}https://github.com/confluentinc/ide-sidecar/blob/v${SIDECAR_VERSION}/src/generated/resources/openapi.yaml${NC} to ${BLUE}${OPENAPI_SPEC_PATH}${NC}." \ + "$MESSAGE" \ "$OPENAPI_SPEC_PATH" \ - "${RED}$OPENAPI_SPEC_VERSION" + "$OPENAPI_SPEC_VERSION" elif [ "$OPENAPI_SPEC_VERSION" != "$CLIENT_VERSION" ]; then + MESSAGE="Make sure to run 'gulp apigen' to regenerate sidecar client code." + handle_version_mismatch \ "Client code version mismatch!" \ - "Make sure to run '${BLUE}gulp apigen${NC}' to regenerate sidecar client code." \ + "$MESSAGE" \ "$OPENAPI_SPEC_PATH" \ - "${GREEN}$OPENAPI_SPEC_VERSION" \ + "$OPENAPI_SPEC_VERSION" \ "$CLIENT_CODE_PATH" \ - "${RED}$CLIENT_VERSION" + "$CLIENT_VERSION" fi printf "✅ All versions match: ${GREEN}%s${NC}\n" "$SIDECAR_VERSION" From 4bdf90f14f801550432af4e33ae6b69f338ffd7f Mon Sep 17 00:00:00 2001 From: Dave Shoup Date: Fri, 21 Feb 2025 17:04:28 -0500 Subject: [PATCH 18/24] refactor to remove function and go off of error conditions --- scripts/check-sidecar-versions.sh | 100 ++++++++++++------------------ 1 file changed, 41 insertions(+), 59 deletions(-) diff --git a/scripts/check-sidecar-versions.sh b/scripts/check-sidecar-versions.sh index ed358274d..7ecd363d8 100755 --- a/scripts/check-sidecar-versions.sh +++ b/scripts/check-sidecar-versions.sh @@ -23,39 +23,20 @@ NC='\033[0m' # Enable color output export TERM=xterm-color -# Function to capture and post output -handle_version_mismatch() { - local TEMP_OUTPUT=$(mktemp) - local MESSAGE="$1" - local INSTRUCTION="$2" +# Message templates +PR_COMMENT_HEADER="#### Sidecar Version Check Failed (https://github.com/confluentinc/vscode/commit/${SEMAPHORE_GIT_SHA})" +OPENAPI_MISMATCH_MSG="Make sure to copy https://github.com/confluentinc/ide-sidecar/blob/v${SIDECAR_VERSION}/src/generated/resources/openapi.yaml to ${OPENAPI_SPEC_PATH}" +CLIENT_MISMATCH_MSG="Make sure to run \`gulp apigen\` to regenerate sidecar client code" - # Generate clean output first (no colors) - { - printf "❌ %s\n\n" "$MESSAGE" - printf "%s\n\n" "$INSTRUCTION" - printf "%s: %s\n" "$SIDECAR_VERSION_PATH" "$SIDECAR_VERSION" - printf "%s: %s\n" "$3" "$4" - if [ -n "$5" ] && [ -n "$6" ]; then - printf "%s: %s\n" "$5" "$6" - fi - } > "$TEMP_OUTPUT" - - # Show colored output in terminal with added colors - { - printf "❌ ${RED}%s${NC}\n\n" "$MESSAGE" - if [[ "$INSTRUCTION" == *"gulp apigen"* ]]; then - printf "Make sure to run '${BLUE}gulp apigen${NC}' to regenerate sidecar client code.\n\n" - else - printf "Make sure to copy ${GRAY}%s${NC} to ${BLUE}%s${NC}.\n\n" \ - "https://github.com/confluentinc/ide-sidecar/blob/v${SIDECAR_VERSION}/src/generated/resources/openapi.yaml" \ - "$OPENAPI_SPEC_PATH" - fi - printf "${GRAY}%s${NC}: ${GREEN}%s${NC}\n" "$SIDECAR_VERSION_PATH" "$SIDECAR_VERSION" - printf "${GRAY}%s${NC}: ${RED}%s${NC}\n" "$3" "$4" - if [ -n "$5" ] && [ -n "$6" ]; then - printf "${GRAY}%s${NC}: ${RED}%s${NC}\n" "$5" "$6" - fi - } +# Compare versions: sidecar vs OpenAPI spec vs client code +if [ "$SIDECAR_VERSION" != "$OPENAPI_SPEC_VERSION" ]; then + # Show colored output in terminal + printf "❌ ${RED}OpenAPI spec version mismatch!${NC}\n\n" + printf "Make sure to copy ${GRAY}%s${NC} to ${BLUE}%s${NC}.\n\n" \ + "https://github.com/confluentinc/ide-sidecar/blob/v${SIDECAR_VERSION}/src/generated/resources/openapi.yaml" \ + "$OPENAPI_SPEC_PATH" + printf "${GRAY}%s${NC}: ${GREEN}%s${NC}\n" "$SIDECAR_VERSION_PATH" "$SIDECAR_VERSION" + printf "${GRAY}%s${NC}: ${RED}%s${NC}\n" "$OPENAPI_SPEC_PATH" "$OPENAPI_SPEC_VERSION" # Post GitHub comment if in CI if [ "$CI" = "true" ] && [ -n "$SEMAPHORE_GIT_PR_NUMBER" ]; then @@ -64,40 +45,41 @@ handle_version_mismatch() { --method POST \ -H "Accept: application/vnd.github+json" \ "/repos/confluentinc/vscode/issues/$SEMAPHORE_GIT_PR_NUMBER/comments" \ - -f body="**Sidecar Version Check Failed** (https://github.com/confluentinc/vscode/commit/$SEMAPHORE_GIT_SHA) + -f body="${PR_COMMENT_HEADER} -\`\`\` -$(cat "$TEMP_OUTPUT") -\`\`\` +OpenAPI spec version mismatch: +- ${SIDECAR_VERSION_PATH}: ${SIDECAR_VERSION} :white_check_mark: +- ${OPENAPI_SPEC_PATH}: ${OPENAPI_SPEC_VERSION} :x: -Either: -1. Update [.versions/ide-sidecar.txt](https://github.com/confluentinc/vscode/blob/main/.versions/ide-sidecar.txt) to match the OpenAPI spec version, or -2. Run \`gulp apigen\` to regenerate the client code" +${OPENAPI_MISMATCH_MSG}" fi - - rm -f "$TEMP_OUTPUT" exit 1 -} -# Compare versions: sidecar vs OpenAPI spec vs client code -if [ "$SIDECAR_VERSION" != "$OPENAPI_SPEC_VERSION" ]; then - MESSAGE="Make sure to copy https://github.com/confluentinc/ide-sidecar/blob/v${SIDECAR_VERSION}/src/generated/resources/openapi.yaml to ${OPENAPI_SPEC_PATH}." - - handle_version_mismatch \ - "OpenAPI spec version mismatch!" \ - "$MESSAGE" \ - "$OPENAPI_SPEC_PATH" \ - "$OPENAPI_SPEC_VERSION" elif [ "$OPENAPI_SPEC_VERSION" != "$CLIENT_VERSION" ]; then - MESSAGE="Make sure to run 'gulp apigen' to regenerate sidecar client code." + # Show colored output in terminal + printf "❌ ${RED}Client code version mismatch!${NC}\n\n" + printf "Make sure to run '${BLUE}gulp apigen${NC}' to regenerate sidecar client code.\n\n" + printf "${GRAY}%s${NC}: ${GREEN}%s${NC}\n" "$SIDECAR_VERSION_PATH" "$SIDECAR_VERSION" + printf "${GRAY}%s${NC}: ${GREEN}%s${NC}\n" "$OPENAPI_SPEC_PATH" "$OPENAPI_SPEC_VERSION" + printf "${GRAY}%s${NC}: ${RED}%s${NC}\n" "$CLIENT_CODE_PATH" "$CLIENT_VERSION" - handle_version_mismatch \ - "Client code version mismatch!" \ - "$MESSAGE" \ - "$OPENAPI_SPEC_PATH" \ - "$OPENAPI_SPEC_VERSION" \ - "$CLIENT_CODE_PATH" \ - "$CLIENT_VERSION" + # Post GitHub comment if in CI + if [ "$CI" = "true" ] && [ -n "$SEMAPHORE_GIT_PR_NUMBER" ]; then + echo "Version check failed. Posting comment to PR #$SEMAPHORE_GIT_PR_NUMBER" + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + "/repos/confluentinc/vscode/issues/$SEMAPHORE_GIT_PR_NUMBER/comments" \ + -f body="${PR_COMMENT_HEADER} + +Client code version mismatch: +- ${SIDECAR_VERSION_PATH}: ${SIDECAR_VERSION} :white_check_mark: +- ${OPENAPI_SPEC_PATH}: ${OPENAPI_SPEC_VERSION} :white_check_mark: +- ${CLIENT_CODE_PATH}: ${CLIENT_VERSION} :x: + +${CLIENT_MISMATCH_MSG}" + fi + exit 1 fi printf "✅ All versions match: ${GREEN}%s${NC}\n" "$SIDECAR_VERSION" From 653018bef67cbfc1fbaf324e9a8489b1dc0b1c15 Mon Sep 17 00:00:00 2001 From: Dave Shoup Date: Fri, 21 Feb 2025 17:10:38 -0500 Subject: [PATCH 19/24] set GH paths --- scripts/check-sidecar-versions.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/scripts/check-sidecar-versions.sh b/scripts/check-sidecar-versions.sh index 7ecd363d8..65a0f6639 100755 --- a/scripts/check-sidecar-versions.sh +++ b/scripts/check-sidecar-versions.sh @@ -24,17 +24,19 @@ NC='\033[0m' export TERM=xterm-color # Message templates -PR_COMMENT_HEADER="#### Sidecar Version Check Failed (https://github.com/confluentinc/vscode/commit/${SEMAPHORE_GIT_SHA})" +PR_COMMENT_HEADER="### Sidecar Version Check Failed (https://github.com/confluentinc/vscode/commit/${SEMAPHORE_GIT_SHA})" OPENAPI_MISMATCH_MSG="Make sure to copy https://github.com/confluentinc/ide-sidecar/blob/v${SIDECAR_VERSION}/src/generated/resources/openapi.yaml to ${OPENAPI_SPEC_PATH}" CLIENT_MISMATCH_MSG="Make sure to run \`gulp apigen\` to regenerate sidecar client code" +GH_PR_PATH_PREFIX=https://github.com/confluentinc/vscode/blob/${SEMAPHORE_GIT_SHA} + # Compare versions: sidecar vs OpenAPI spec vs client code if [ "$SIDECAR_VERSION" != "$OPENAPI_SPEC_VERSION" ]; then # Show colored output in terminal printf "❌ ${RED}OpenAPI spec version mismatch!${NC}\n\n" printf "Make sure to copy ${GRAY}%s${NC} to ${BLUE}%s${NC}.\n\n" \ "https://github.com/confluentinc/ide-sidecar/blob/v${SIDECAR_VERSION}/src/generated/resources/openapi.yaml" \ - "$OPENAPI_SPEC_PATH" + "${GH_PR_PATH_PREFIX}/${OPENAPI_SPEC_PATH}" printf "${GRAY}%s${NC}: ${GREEN}%s${NC}\n" "$SIDECAR_VERSION_PATH" "$SIDECAR_VERSION" printf "${GRAY}%s${NC}: ${RED}%s${NC}\n" "$OPENAPI_SPEC_PATH" "$OPENAPI_SPEC_VERSION" @@ -48,8 +50,8 @@ if [ "$SIDECAR_VERSION" != "$OPENAPI_SPEC_VERSION" ]; then -f body="${PR_COMMENT_HEADER} OpenAPI spec version mismatch: -- ${SIDECAR_VERSION_PATH}: ${SIDECAR_VERSION} :white_check_mark: -- ${OPENAPI_SPEC_PATH}: ${OPENAPI_SPEC_VERSION} :x: +- ${GH_PR_PATH_PREFIX}/${SIDECAR_VERSION_PATH}: \`${SIDECAR_VERSION}\` :white_check_mark: +- ${GH_PR_PATH_PREFIX}/${OPENAPI_SPEC_PATH}: \`${OPENAPI_SPEC_VERSION}\` :x: ${OPENAPI_MISMATCH_MSG}" fi @@ -73,9 +75,9 @@ elif [ "$OPENAPI_SPEC_VERSION" != "$CLIENT_VERSION" ]; then -f body="${PR_COMMENT_HEADER} Client code version mismatch: -- ${SIDECAR_VERSION_PATH}: ${SIDECAR_VERSION} :white_check_mark: -- ${OPENAPI_SPEC_PATH}: ${OPENAPI_SPEC_VERSION} :white_check_mark: -- ${CLIENT_CODE_PATH}: ${CLIENT_VERSION} :x: +- ${GH_PR_PATH_PREFIX}/${SIDECAR_VERSION_PATH}: \`${SIDECAR_VERSION}\` :white_check_mark: +- ${GH_PR_PATH_PREFIX}/${OPENAPI_SPEC_PATH}: \`${OPENAPI_SPEC_VERSION}\` :white_check_mark: +- ${GH_PR_PATH_PREFIX}/${CLIENT_CODE_PATH}: \`${CLIENT_VERSION}\` :x: ${CLIENT_MISMATCH_MSG}" fi From a35627d9912550aadf0857a8dc0dd653afbdcb85 Mon Sep 17 00:00:00 2001 From: Dave Shoup Date: Fri, 21 Feb 2025 17:18:52 -0500 Subject: [PATCH 20/24] formatting cleanup --- scripts/check-sidecar-versions.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/check-sidecar-versions.sh b/scripts/check-sidecar-versions.sh index 65a0f6639..9261ea7da 100755 --- a/scripts/check-sidecar-versions.sh +++ b/scripts/check-sidecar-versions.sh @@ -28,7 +28,11 @@ PR_COMMENT_HEADER="### Sidecar Version Check Failed (https://github.com/confluen OPENAPI_MISMATCH_MSG="Make sure to copy https://github.com/confluentinc/ide-sidecar/blob/v${SIDECAR_VERSION}/src/generated/resources/openapi.yaml to ${OPENAPI_SPEC_PATH}" CLIENT_MISMATCH_MSG="Make sure to run \`gulp apigen\` to regenerate sidecar client code" +# GitHub PR links GH_PR_PATH_PREFIX=https://github.com/confluentinc/vscode/blob/${SEMAPHORE_GIT_SHA} +IDE_SIDECAR_LINK="[ide-sidecar.txt](${GH_PR_PATH_PREFIX}/${SIDECAR_VERSION_PATH})" +OPENAPI_SPEC_LINK="[sidecar.openapi.yaml](${GH_PR_PATH_PREFIX}/${OPENAPI_SPEC_PATH})" +CLIENT_CODE_LINK="[runtime.ts](${GH_PR_PATH_PREFIX}/${CLIENT_CODE_PATH})" # Compare versions: sidecar vs OpenAPI spec vs client code if [ "$SIDECAR_VERSION" != "$OPENAPI_SPEC_VERSION" ]; then @@ -36,7 +40,7 @@ if [ "$SIDECAR_VERSION" != "$OPENAPI_SPEC_VERSION" ]; then printf "❌ ${RED}OpenAPI spec version mismatch!${NC}\n\n" printf "Make sure to copy ${GRAY}%s${NC} to ${BLUE}%s${NC}.\n\n" \ "https://github.com/confluentinc/ide-sidecar/blob/v${SIDECAR_VERSION}/src/generated/resources/openapi.yaml" \ - "${GH_PR_PATH_PREFIX}/${OPENAPI_SPEC_PATH}" + "$IDE_SIDECAR_LINK" printf "${GRAY}%s${NC}: ${GREEN}%s${NC}\n" "$SIDECAR_VERSION_PATH" "$SIDECAR_VERSION" printf "${GRAY}%s${NC}: ${RED}%s${NC}\n" "$OPENAPI_SPEC_PATH" "$OPENAPI_SPEC_VERSION" @@ -50,8 +54,8 @@ if [ "$SIDECAR_VERSION" != "$OPENAPI_SPEC_VERSION" ]; then -f body="${PR_COMMENT_HEADER} OpenAPI spec version mismatch: -- ${GH_PR_PATH_PREFIX}/${SIDECAR_VERSION_PATH}: \`${SIDECAR_VERSION}\` :white_check_mark: -- ${GH_PR_PATH_PREFIX}/${OPENAPI_SPEC_PATH}: \`${OPENAPI_SPEC_VERSION}\` :x: +- ${IDE_SIDECAR_LINK}: \`${SIDECAR_VERSION}\` :white_check_mark: +- ${OPENAPI_SPEC_LINK}: \`${OPENAPI_SPEC_VERSION}\` :x: ${OPENAPI_MISMATCH_MSG}" fi @@ -75,9 +79,9 @@ elif [ "$OPENAPI_SPEC_VERSION" != "$CLIENT_VERSION" ]; then -f body="${PR_COMMENT_HEADER} Client code version mismatch: -- ${GH_PR_PATH_PREFIX}/${SIDECAR_VERSION_PATH}: \`${SIDECAR_VERSION}\` :white_check_mark: -- ${GH_PR_PATH_PREFIX}/${OPENAPI_SPEC_PATH}: \`${OPENAPI_SPEC_VERSION}\` :white_check_mark: -- ${GH_PR_PATH_PREFIX}/${CLIENT_CODE_PATH}: \`${CLIENT_VERSION}\` :x: +- ${IDE_SIDECAR_LINK}: \`${SIDECAR_VERSION}\` :white_check_mark: +- ${OPENAPI_SPEC_LINK}: \`${OPENAPI_SPEC_VERSION}\` :white_check_mark: +- ${CLIENT_CODE_LINK}: \`${CLIENT_VERSION}\` :x: ${CLIENT_MISMATCH_MSG}" fi From 36f4f210795e6fcf636f3a70b678a4e269e97d2d Mon Sep 17 00:00:00 2001 From: Dave Shoup Date: Fri, 21 Feb 2025 17:27:41 -0500 Subject: [PATCH 21/24] fix linking and use SEMAPHORE_GIT_PR_SHA --- scripts/check-sidecar-versions.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/check-sidecar-versions.sh b/scripts/check-sidecar-versions.sh index 9261ea7da..542f3869c 100755 --- a/scripts/check-sidecar-versions.sh +++ b/scripts/check-sidecar-versions.sh @@ -23,24 +23,24 @@ NC='\033[0m' # Enable color output export TERM=xterm-color -# Message templates -PR_COMMENT_HEADER="### Sidecar Version Check Failed (https://github.com/confluentinc/vscode/commit/${SEMAPHORE_GIT_SHA})" -OPENAPI_MISMATCH_MSG="Make sure to copy https://github.com/confluentinc/ide-sidecar/blob/v${SIDECAR_VERSION}/src/generated/resources/openapi.yaml to ${OPENAPI_SPEC_PATH}" -CLIENT_MISMATCH_MSG="Make sure to run \`gulp apigen\` to regenerate sidecar client code" - -# GitHub PR links -GH_PR_PATH_PREFIX=https://github.com/confluentinc/vscode/blob/${SEMAPHORE_GIT_SHA} +# Markdown links for GH PR comment +GH_PR_PATH_PREFIX=https://github.com/confluentinc/vscode/blob/${SEMAPHORE_GIT_PR_SHA} IDE_SIDECAR_LINK="[ide-sidecar.txt](${GH_PR_PATH_PREFIX}/${SIDECAR_VERSION_PATH})" OPENAPI_SPEC_LINK="[sidecar.openapi.yaml](${GH_PR_PATH_PREFIX}/${OPENAPI_SPEC_PATH})" CLIENT_CODE_LINK="[runtime.ts](${GH_PR_PATH_PREFIX}/${CLIENT_CODE_PATH})" +# Message templates +PR_COMMENT_HEADER="### Sidecar Version Check Failed (https://github.com/confluentinc/vscode/commit/${SEMAPHORE_GIT_PR_SHA})" +OPENAPI_MISMATCH_MSG="Make sure to copy https://github.com/confluentinc/ide-sidecar/blob/v${SIDECAR_VERSION}/src/generated/resources/openapi.yaml to ${IDE_SIDECAR_LINK}" +CLIENT_MISMATCH_MSG="Make sure to run \`gulp apigen\` to regenerate sidecar client code" + # Compare versions: sidecar vs OpenAPI spec vs client code if [ "$SIDECAR_VERSION" != "$OPENAPI_SPEC_VERSION" ]; then # Show colored output in terminal printf "❌ ${RED}OpenAPI spec version mismatch!${NC}\n\n" printf "Make sure to copy ${GRAY}%s${NC} to ${BLUE}%s${NC}.\n\n" \ "https://github.com/confluentinc/ide-sidecar/blob/v${SIDECAR_VERSION}/src/generated/resources/openapi.yaml" \ - "$IDE_SIDECAR_LINK" + "$OPENAPI_SPEC_PATH" printf "${GRAY}%s${NC}: ${GREEN}%s${NC}\n" "$SIDECAR_VERSION_PATH" "$SIDECAR_VERSION" printf "${GRAY}%s${NC}: ${RED}%s${NC}\n" "$OPENAPI_SPEC_PATH" "$OPENAPI_SPEC_VERSION" From ca54eea628de680a7f28130bc657c4c4c4fd1632 Mon Sep 17 00:00:00 2001 From: Dave Shoup Date: Fri, 21 Feb 2025 17:30:58 -0500 Subject: [PATCH 22/24] use the right link --- scripts/check-sidecar-versions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check-sidecar-versions.sh b/scripts/check-sidecar-versions.sh index 542f3869c..c94981edf 100755 --- a/scripts/check-sidecar-versions.sh +++ b/scripts/check-sidecar-versions.sh @@ -31,7 +31,7 @@ CLIENT_CODE_LINK="[runtime.ts](${GH_PR_PATH_PREFIX}/${CLIENT_CODE_PATH})" # Message templates PR_COMMENT_HEADER="### Sidecar Version Check Failed (https://github.com/confluentinc/vscode/commit/${SEMAPHORE_GIT_PR_SHA})" -OPENAPI_MISMATCH_MSG="Make sure to copy https://github.com/confluentinc/ide-sidecar/blob/v${SIDECAR_VERSION}/src/generated/resources/openapi.yaml to ${IDE_SIDECAR_LINK}" +OPENAPI_MISMATCH_MSG="Make sure to copy https://github.com/confluentinc/ide-sidecar/blob/v${SIDECAR_VERSION}/src/generated/resources/openapi.yaml to ${OPENAPI_SPEC_LINK}" CLIENT_MISMATCH_MSG="Make sure to run \`gulp apigen\` to regenerate sidecar client code" # Compare versions: sidecar vs OpenAPI spec vs client code From 8fd6f48018d1ec8c2d59c2ab890173eceaae42b1 Mon Sep 17 00:00:00 2001 From: Dave Shoup Date: Fri, 21 Feb 2025 17:36:54 -0500 Subject: [PATCH 23/24] REVERT THIS --- src/clients/sidecar-openapi-specs/sidecar.openapi.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clients/sidecar-openapi-specs/sidecar.openapi.yaml b/src/clients/sidecar-openapi-specs/sidecar.openapi.yaml index b9259c13f..c5e5a9ee7 100644 --- a/src/clients/sidecar-openapi-specs/sidecar.openapi.yaml +++ b/src/clients/sidecar-openapi-specs/sidecar.openapi.yaml @@ -8,7 +8,7 @@ info: name: Confluent for VS Code Support url: https://confluent.io/contact email: vscode@confluent.io - version: 1.0.1 + version: 0.161.0 servers: - url: http://127.0.0.1:26636 description: Auto generated value From 1efc007a6005b90f542c645fd02fd0bf7d2a28cf Mon Sep 17 00:00:00 2001 From: Dave Shoup Date: Fri, 21 Feb 2025 17:39:26 -0500 Subject: [PATCH 24/24] Revert "REVERT THIS" This reverts commit 8fd6f48018d1ec8c2d59c2ab890173eceaae42b1. --- src/clients/sidecar-openapi-specs/sidecar.openapi.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clients/sidecar-openapi-specs/sidecar.openapi.yaml b/src/clients/sidecar-openapi-specs/sidecar.openapi.yaml index c5e5a9ee7..b9259c13f 100644 --- a/src/clients/sidecar-openapi-specs/sidecar.openapi.yaml +++ b/src/clients/sidecar-openapi-specs/sidecar.openapi.yaml @@ -8,7 +8,7 @@ info: name: Confluent for VS Code Support url: https://confluent.io/contact email: vscode@confluent.io - version: 0.161.0 + version: 1.0.1 servers: - url: http://127.0.0.1:26636 description: Auto generated value