-
Notifications
You must be signed in to change notification settings - Fork 0
Docfx/context7 chat #21
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| [ ] | ||
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,133 @@ | ||||||||||||
| #!/usr/bin/env python3 | ||||||||||||
| """ | ||||||||||||
| Simplified package bumping for Codebelt service updates (Option B). | ||||||||||||
|
|
||||||||||||
| Only updates packages published by the triggering source repo. | ||||||||||||
| Does NOT update Microsoft.Extensions.*, BenchmarkDotNet, or other third-party packages. | ||||||||||||
| Does NOT parse TFM conditions - only bumps Codebelt/Cuemon/Savvyio packages to the triggering version. | ||||||||||||
|
|
||||||||||||
| Usage: | ||||||||||||
| TRIGGER_SOURCE=cuemon TRIGGER_VERSION=10.3.0 python3 bump-nuget.py | ||||||||||||
|
|
||||||||||||
| Behavior: | ||||||||||||
| - If TRIGGER_SOURCE is "cuemon" and TRIGGER_VERSION is "10.3.0": | ||||||||||||
| - Cuemon.Core: 10.2.1 → 10.3.0 | ||||||||||||
| - Cuemon.Extensions.IO: 10.2.1 → 10.3.0 | ||||||||||||
| - Microsoft.Extensions.Hosting: 9.0.13 → UNCHANGED (not a Codebelt package) | ||||||||||||
| - BenchmarkDotNet: 0.15.8 → UNCHANGED (not a Codebelt package) | ||||||||||||
| """ | ||||||||||||
|
|
||||||||||||
| import re | ||||||||||||
| import os | ||||||||||||
| import sys | ||||||||||||
| from typing import Dict, List | ||||||||||||
|
|
||||||||||||
| TRIGGER_SOURCE = os.environ.get("TRIGGER_SOURCE", "") | ||||||||||||
| TRIGGER_VERSION = os.environ.get("TRIGGER_VERSION", "") | ||||||||||||
|
|
||||||||||||
| # Map of source repos to their package ID prefixes | ||||||||||||
| SOURCE_PACKAGE_MAP: Dict[str, List[str]] = { | ||||||||||||
| "cuemon": ["Cuemon."], | ||||||||||||
| "xunit": ["Codebelt.Extensions.Xunit"], | ||||||||||||
| "benchmarkdotnet": ["Codebelt.Extensions.BenchmarkDotNet"], | ||||||||||||
| "bootstrapper": ["Codebelt.Bootstrapper"], | ||||||||||||
| "newtonsoft-json": [ | ||||||||||||
| "Codebelt.Extensions.Newtonsoft.Json", | ||||||||||||
| "Codebelt.Extensions.AspNetCore.Mvc.Formatters.Newtonsoft", | ||||||||||||
| ], | ||||||||||||
| "aws-signature-v4": ["Codebelt.Extensions.AspNetCore.Authentication.AwsSignature"], | ||||||||||||
| "unitify": ["Codebelt.Unitify"], | ||||||||||||
| "yamldotnet": [ | ||||||||||||
| "Codebelt.Extensions.YamlDotNet", | ||||||||||||
| "Codebelt.Extensions.AspNetCore.Mvc.Formatters.Text.Yaml", | ||||||||||||
| ], | ||||||||||||
| "globalization": ["Codebelt.Extensions.Globalization"], | ||||||||||||
| "asp-versioning": ["Codebelt.Extensions.Asp.Versioning"], | ||||||||||||
| "swashbuckle-aspnetcore": ["Codebelt.Extensions.Swashbuckle"], | ||||||||||||
| "savvyio": ["Savvyio."], | ||||||||||||
| "shared-kernel": [], | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
|
Comment on lines
+48
to
+51
|
||||||||||||
| "shared-kernel": [], | |
| } | |
| } |
Copilot
AI
Feb 20, 2026
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 is_triggered_package function has a type annotation indicating it returns bool, but when TRIGGER_SOURCE is not set, the function returns False without logging or warning about this condition. This is a silent failure mode that could make debugging difficult when the script unexpectedly skips all packages. Consider adding a debug print statement or logging when TRIGGER_SOURCE is empty to help diagnose configuration issues.
| if not TRIGGER_SOURCE: | |
| if not TRIGGER_SOURCE: | |
| print( | |
| "Debug: TRIGGER_SOURCE is not set; is_triggered_package will always return False." | |
| ) |
Copilot
AI
Feb 20, 2026
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 script does not validate whether the target version is greater than the current version before performing updates. This could lead to downgrading packages or setting them to the same version, which may not be the intended behavior for a service update. Consider adding a version comparison check to ensure the target version is actually newer than the current version before making changes.
Copilot
AI
Feb 20, 2026
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 return statement is redundant as it returns 0 in both branches of the ternary expression. This appears to be dead code or incomplete logic. Either remove the ternary operator and simply return 0, or implement proper exit code logic where the script returns a non-zero code when no changes are made if that's the desired behavior for downstream workflow logic.
| return 0 if changes else 0 # Return 0 even if no changes (not an error) | |
| return 0 # Return 0 even if no changes (not an error) |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,139 @@ | ||||||||||||||||||||||||||||||||||
| name: Service Update | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||||
| repository_dispatch: | ||||||||||||||||||||||||||||||||||
| types: [codebelt-service-update] | ||||||||||||||||||||||||||||||||||
| workflow_dispatch: | ||||||||||||||||||||||||||||||||||
| inputs: | ||||||||||||||||||||||||||||||||||
| source_repo: | ||||||||||||||||||||||||||||||||||
| description: 'Triggering source repo name (e.g. cuemon)' | ||||||||||||||||||||||||||||||||||
| required: false | ||||||||||||||||||||||||||||||||||
| default: '' | ||||||||||||||||||||||||||||||||||
| source_version: | ||||||||||||||||||||||||||||||||||
| description: 'Version released by source (e.g. 10.3.0)' | ||||||||||||||||||||||||||||||||||
| required: false | ||||||||||||||||||||||||||||||||||
| default: '' | ||||||||||||||||||||||||||||||||||
| dry_run: | ||||||||||||||||||||||||||||||||||
| type: boolean | ||||||||||||||||||||||||||||||||||
| description: 'Dry run — show changes but do not commit or open PR' | ||||||||||||||||||||||||||||||||||
| default: false | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||||
| contents: write | ||||||||||||||||||||||||||||||||||
| pull-requests: write | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||||
| service-update: | ||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-24.04 | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||
| - name: Checkout | ||||||||||||||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||
| fetch-depth: 0 | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - name: Resolve trigger inputs | ||||||||||||||||||||||||||||||||||
| id: trigger | ||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||
| SOURCE="${{ github.event.client_payload.source_repo || github.event.inputs.source_repo }}" | ||||||||||||||||||||||||||||||||||
| VERSION="${{ github.event.client_payload.source_version || github.event.inputs.source_version }}" | ||||||||||||||||||||||||||||||||||
| echo "source=$SOURCE" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||||||||
| echo "version=$VERSION" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
| - name: Validate trigger inputs | |
| run: | | |
| SOURCE="${{ steps.trigger.outputs.source }}" | |
| VERSION="${{ steps.trigger.outputs.version }}" | |
| if [ -z "$SOURCE" ] || [ -z "$VERSION" ]; then | |
| echo "Error: TRIGGER_SOURCE and TRIGGER_VERSION must be set. Got SOURCE='$SOURCE', VERSION='$VERSION'." | |
| echo "Ensure repository_dispatch or workflow_dispatch provides non-empty 'source_repo' and 'source_version'." | |
| exit 1 | |
| fi |
Copilot
AI
Feb 20, 2026
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 version determination logic using grep and awk assumes the CHANGELOG.md format is consistent and that the first match is always a valid semantic version. If the CHANGELOG.md is empty, malformed, or doesn't contain a version in the expected format, this step will fail or produce incorrect results. Consider adding validation to ensure CURRENT contains a valid version before attempting the awk transformation, and handle the case where no version is found.
| NEW=$(echo "$CURRENT" | awk -F. '{printf "%s.%s.%d", $1, $2, $3+1}') | |
| if ! echo "$CURRENT" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'; then | |
| echo "ERROR: Unable to determine current semantic version from CHANGELOG.md (got: '$CURRENT')." >&2 | |
| echo "Ensure CHANGELOG.md contains a heading like '## [1.2.3]'." >&2 | |
| exit 1 | |
| fi | |
| NEW=$(awk -F. '{printf "%s.%s.%d", $1, $2, $3+1}' <<< "$CURRENT") |
Copilot
AI
Feb 20, 2026
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 awk command for version bumping only increments the patch version (third component). This means the workflow always creates patch releases (e.g., 0.5.2 → 0.5.3) and cannot handle minor or major version bumps. For service updates this might be intentional, but it's inflexible and will cause issues if a major or minor version bump is needed for breaking changes or significant updates. Consider adding workflow inputs or logic to support different version bump strategies (major, minor, patch).
Copilot
AI
Feb 20, 2026
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 TFM (Target Framework Moniker) extraction using grep relies on the "Availability:" line being present and correctly formatted in the existing PackageReleaseNotes.txt file. If this line is missing or malformed, the sed command will fail silently and TFM will be set to the fallback value, potentially using incorrect framework information for new releases. Consider adding validation or error handling to ensure the extracted TFM value is reasonable before using it.
| TFM=$(grep -m1 "^Availability:" "$f" | sed 's/Availability: //' || echo ".NET 10, .NET 9 and .NET Standard 2.0") | |
| RAW_AVAIL_LINE=$(grep -m1 "^Availability:" "$f" || true) | |
| if [ -n "$RAW_AVAIL_LINE" ]; then | |
| TFM=${RAW_AVAIL_LINE#Availability:} | |
| TFM=$(echo "$TFM" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') | |
| else | |
| TFM="" | |
| fi | |
| if [ -z "$TFM" ]; then | |
| echo "Warning: Using fallback TFM for $f because Availability line is missing or malformed." | |
| TFM=".NET 10, .NET 9 and .NET Standard 2.0" | |
| fi |
Copilot
AI
Feb 20, 2026
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 PackageReleaseNotes.txt update step uses a shell loop with 'continue' to skip missing files, but the logic doesn't validate whether any files were actually found and updated. If the .nuget/*/PackageReleaseNotes.txt pattern matches no files (or all files fail the conditional check), the step will succeed silently without updating any release notes. Consider adding validation after the loop to ensure at least one file was processed, or logging a message when no files are found.
| for f in .nuget/*/PackageReleaseNotes.txt; do | |
| [ -f "$f" ] || continue | |
| TFM=$(grep -m1 "^Availability:" "$f" | sed 's/Availability: //' || echo ".NET 10, .NET 9 and .NET Standard 2.0") | |
| ENTRY="Version: ${NEW}\nAvailability: ${TFM}\n \n# ALM\n- CHANGED Dependencies have been upgraded to the latest compatible versions for all supported target frameworks (TFMs)\n \n" | |
| { printf "$ENTRY"; cat "$f"; } > "$f.tmp" && mv "$f.tmp" "$f" | |
| done | |
| PROCESSED=0 | |
| for f in .nuget/*/PackageReleaseNotes.txt; do | |
| [ -f "$f" ] || continue | |
| TFM=$(grep -m1 "^Availability:" "$f" | sed 's/Availability: //' || echo ".NET 10, .NET 9 and .NET Standard 2.0") | |
| ENTRY="Version: ${NEW}\nAvailability: ${TFM}\n \n# ALM\n- CHANGED Dependencies have been upgraded to the latest compatible versions for all supported target frameworks (TFMs)\n \n" | |
| { printf "$ENTRY"; cat "$f"; } > "$f.tmp" && mv "$f.tmp" "$f" && PROCESSED=1 | |
| done | |
| if [ "$PROCESSED" -eq 0 ]; then | |
| echo "No PackageReleaseNotes.txt files found to update under .nuget/*/PackageReleaseNotes.txt" | |
| fi |
Copilot
AI
Feb 20, 2026
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 workflow creates a branch and attempts to create a PR but does not check if a PR or branch with the same name already exists. If the workflow runs multiple times (e.g., due to multiple releases or manual triggers), it will fail with 'git push' or 'gh pr create' errors when trying to create duplicate branches or PRs. Consider adding logic to check for existing branches/PRs and either skip creation, update the existing branch, or use unique identifiers in the branch name.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,78 @@ | ||||||||||||||||||||||||||||||||||||||||||||
| name: Trigger Downstream Service Updates | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||||||||||||||
| release: | ||||||||||||||||||||||||||||||||||||||||||||
| types: [published] | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||||||||||||||
| dispatch: | ||||||||||||||||||||||||||||||||||||||||||||
| if: github.event.release.prerelease == false | ||||||||||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-24.04 | ||||||||||||||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||||||||||||||
| contents: read | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||||||||
| - name: Checkout (to read dispatch-targets.json) | ||||||||||||||||||||||||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| - name: Check for dispatch targets | ||||||||||||||||||||||||||||||||||||||||||||
| id: check | ||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||
| if [ ! -f .github/dispatch-targets.json ]; then | ||||||||||||||||||||||||||||||||||||||||||||
| echo "No dispatch-targets.json found, skipping." | ||||||||||||||||||||||||||||||||||||||||||||
| echo "has_targets=false" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||
| COUNT=$(python3 -c "import json; print(len(json.load(open('.github/dispatch-targets.json'))))") | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
| COUNT=$(python3 -c "import json; print(len(json.load(open('.github/dispatch-targets.json'))))") | |
| COUNT=$(python3 - << 'EOF' | |
| import json | |
| import sys | |
| path = '.github/dispatch-targets.json' | |
| try: | |
| with open(path, 'r', encoding='utf-8') as f: | |
| data = json.load(f) | |
| except json.JSONDecodeError as exc: | |
| print(f"Error: Failed to parse {path}: {exc}", file=sys.stderr) | |
| sys.exit(1) | |
| # Expect a JSON array; adjust here if a different structure is intended. | |
| if not isinstance(data, list): | |
| print(f"Error: Expected a JSON array in {path}, got {type(data).__name__}", file=sys.stderr) | |
| sys.exit(1) | |
| print(len(data)) | |
| EOF | |
| ) |
Copilot
AI
Feb 20, 2026
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 inline Python script uses json.load with open() but doesn't use a context manager (with statement) to ensure the file is properly closed. While this works in a short-lived script context, it's not following Python best practices. Consider using 'with open('.github/dispatch-targets.json') as f: targets = json.load(f)' for proper resource management and to follow idiomatic Python patterns.
Copilot
AI
Feb 20, 2026
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 hardcoded organization name 'codebeltnet' in the URL construction limits reusability and makes the workflow less flexible. If this workflow needs to be used across different organizations or if the organization name changes, the script will require modification. Consider using a GitHub Actions variable or environment variable (e.g., github.repository_owner) to make this configurable.
Copilot
AI
Feb 20, 2026
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 urllib.request.urlopen call does not handle potential HTTP errors. If the API request fails with a 4xx or 5xx status code, it will raise an HTTPError exception, causing the workflow to fail without attempting to dispatch to remaining repositories. Consider adding error handling to catch HTTPError exceptions, log the failure, and continue with the next repository in the list.
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.
A third-party JavaScript widget from context7.com is being loaded without any documentation, security review notes, or explanation of its purpose in the PR description. Loading external scripts can introduce security and privacy risks, including potential XSS vulnerabilities, data leakage, or dependency on external service availability. Consider documenting the purpose of this widget, conducting a security review, implementing a Content Security Policy (CSP), and adding a Subresource Integrity (SRI) hash to ensure the script hasn't been tampered with.