-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(CI): add pipeline to check sidecar version against OpenAPI spec and client code versions #1062
Merged
Merged
chore(CI): add pipeline to check sidecar version against OpenAPI spec and client code versions #1062
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
62e3a65
add pipeline to check sidecar version against OpenAPI spec and client…
shouples bccaf41
move check script
shouples cad0687
rename
shouples 8edd64f
post a PR comment on failures
shouples dea408f
strip ANSI escape codes before PR comment
shouples ef3a3af
try to fix `sed`
shouples 2936a37
next attempt
shouples ba18396
another attempt
shouples a00373e
don't suppress the exit code
shouples c77c51c
fix formatting for PR comment
shouples 20eaad0
remove arrows
shouples cc25641
fix formatting again
shouples 0c40218
move PR comment logic into main script
shouples a3a16de
cleanup
shouples b6ec77a
fix code block formatting in PR comment
shouples 0817173
another formatting attempt
shouples c213ff2
split colored formatting from PR comment formatting
shouples 4bdf90f
refactor to remove function and go off of error conditions
shouples 653018b
set GH paths
shouples a35627d
formatting cleanup
shouples 36f4f21
fix linking and use SEMAPHORE_GIT_PR_SHA
shouples ca54eea
use the right link
shouples 8fd6f48
REVERT THIS
shouples 1efc007
Revert "REVERT THIS"
shouples File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#!/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' | ||
BLUE='\033[0;34m' | ||
GRAY='\033[0;90m' | ||
NC='\033[0m' | ||
|
||
# Enable color output | ||
export TERM=xterm-color | ||
|
||
# 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 ${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 | ||
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 | ||
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} | ||
|
||
OpenAPI spec version mismatch: | ||
- ${IDE_SIDECAR_LINK}: \`${SIDECAR_VERSION}\` :white_check_mark: | ||
- ${OPENAPI_SPEC_LINK}: \`${OPENAPI_SPEC_VERSION}\` :x: | ||
|
||
${OPENAPI_MISMATCH_MSG}" | ||
fi | ||
exit 1 | ||
|
||
elif [ "$OPENAPI_SPEC_VERSION" != "$CLIENT_VERSION" ]; then | ||
# 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" | ||
|
||
# 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: | ||
- ${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 | ||
exit 1 | ||
fi | ||
|
||
printf "✅ All versions match: ${GREEN}%s${NC}\n" "$SIDECAR_VERSION" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The auto_promote condition references 'src/clients/sidecar-openapi-specs/sidecar.openapi.yaml' for the OpenAPI spec version check, but the PR description mentions validating the client code version in 'src/clients/sidecar/runtime.ts'. Please verify that the correct file is monitored for changes.
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We care more about changes to
sidecar.openapi.yaml
, which should be followed up bygulp apigen
(which then changesclients/**/runtime.ts
files). No need to explicitly check for any changes toruntime.ts
here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good bot, try again next time.