From 36520e240ab77f4ce97ce191534a92c32234a839 Mon Sep 17 00:00:00 2001 From: Alon Yeshurun <98805507+ayeshurun@users.noreply.github.com> Date: Wed, 17 Sep 2025 17:11:18 +0300 Subject: [PATCH 01/21] Change pull_request to pull_request_target --- .github/workflows/semantic-pull-request.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/semantic-pull-request.yml b/.github/workflows/semantic-pull-request.yml index 26b2dec0..7179ead3 100644 --- a/.github/workflows/semantic-pull-request.yml +++ b/.github/workflows/semantic-pull-request.yml @@ -3,7 +3,7 @@ name: 🔍 Semantic PR Validation on: - pull_request: + pull_request_target: branches: - main types: @@ -113,4 +113,4 @@ jobs: repo: context.repo.repo, name: 'invalid', }); - } \ No newline at end of file + } From 1de4d6b78a5834a5daea87621970db7f994a386d Mon Sep 17 00:00:00 2001 From: Alon Yeshurun Date: Thu, 13 Nov 2025 15:08:42 +0000 Subject: [PATCH 02/21] Support host app --- src/fabric_cli/client/fab_api_client.py | 45 ++++++++-- src/fabric_cli/core/fab_constant.py | 10 +++ tests/test_core/test_fab_api_client.py | 111 ++++++++++++++++++++++++ 3 files changed, 160 insertions(+), 6 deletions(-) diff --git a/src/fabric_cli/client/fab_api_client.py b/src/fabric_cli/client/fab_api_client.py index b9121f67..9f3835ca 100644 --- a/src/fabric_cli/client/fab_api_client.py +++ b/src/fabric_cli/client/fab_api_client.py @@ -2,6 +2,7 @@ # Licensed under the MIT License. import json +import os import platform import re import time @@ -23,15 +24,13 @@ from fabric_cli.errors import ErrorMessages from fabric_cli.utils import fab_error_parser as utils_errors from fabric_cli.utils import fab_files as files_utils -from fabric_cli.utils.fab_http_polling_utils import get_polling_interval from fabric_cli.utils import fab_ui as utils_ui +from fabric_cli.utils.fab_http_polling_utils import get_polling_interval GUID_PATTERN = r"([a-f0-9\-]{36})" FABRIC_WORKSPACE_URI_PATTERN = rf"workspaces/{GUID_PATTERN}" - - def do_request( args, json=None, @@ -91,14 +90,17 @@ def do_request( # Get token from fabric_cli.core.fab_auth import FabAuth + token = FabAuth().get_access_token(scope) # Build headers from fabric_cli.core.fab_context import Context as FabContext + ctxt_cmd = FabContext().command + headers = { "Authorization": "Bearer " + str(token), - "User-Agent": f"{fab_constant.API_USER_AGENT}/{fab_constant.FAB_VERSION} ({ctxt_cmd}; {platform.system()}; {platform.machine()}; {platform.release()})", + "User-Agent": _build_user_agent(ctxt_cmd), } if files is None: @@ -279,6 +281,37 @@ def _handle_successful_response(args: Namespace, response: ApiResponse) -> ApiRe return response +def _build_user_agent(ctxt_cmd: str) -> str: + """Build the User-Agent header for API requests, including context command and HostApp if applicable.""" + base_user_agent = f"{fab_constant.API_USER_AGENT}/{fab_constant.FAB_VERSION} ({ctxt_cmd}; {platform.system()}; {platform.machine()}; {platform.release()})" + host_app_suffix = _get_host_app_suffix() + return f"{base_user_agent}{host_app_suffix}" + + +def _get_host_app_suffix() -> str: + """Get the HostApp suffix for the User-Agent header based on environment variable. + + Returns an empty string if the environment variable is not set or has an invalid value. + """ + _host_app_in_env = os.environ.get(fab_constant.FAB_HOST_APP_ENV_VAR) + if not _host_app_in_env: + return "" + + host_app = next( + ( + allowed_app + for allowed_app in fab_constant.ALLOWED_FAB_HOST_APP_VALUES + if _host_app_in_env.lower() == allowed_app.lower() + ), + None, + ) + + if not host_app: + return "" + + return f"; HostApp/{host_app}" + + def _print_response_details(response: ApiResponse) -> None: response_details = dict( { @@ -355,10 +388,10 @@ def _poll_operation( args.method = "get" args.wait = False args.params = {} - + initial_interval = get_polling_interval(original_response.headers) time.sleep(initial_interval) - + while True: response = do_request(args, hostname=hostname) diff --git a/src/fabric_cli/core/fab_constant.py b/src/fabric_cli/core/fab_constant.py index 15d20ff7..85b85438 100644 --- a/src/fabric_cli/core/fab_constant.py +++ b/src/fabric_cli/core/fab_constant.py @@ -64,6 +64,8 @@ IDENTITY_TYPE: ["user", "service_principal", "managed_identity"], } +FAB_HOST_APP_ENV_VAR = "FABRIC_CLI_HOST_APP" + # Other constants FAB_CAPACITY_NAME_NONE = "none" FAB_DEFAULT_OPEN_EXPERIENCE_FABRIC = "fabric-developer" @@ -316,3 +318,11 @@ "workspaceId", "folderId", } + +################################################ +### Only allowed for modification by CLI team ## + +ALLOWED_FAB_HOST_APP_VALUES = [ + # "CLI-ADO-Pipeline" +] +################################################ diff --git a/tests/test_core/test_fab_api_client.py b/tests/test_core/test_fab_api_client.py index b19a592d..75005188 100644 --- a/tests/test_core/test_fab_api_client.py +++ b/tests/test_core/test_fab_api_client.py @@ -8,6 +8,7 @@ import pytest from fabric_cli.client.fab_api_client import ( + _get_host_app_suffix, _transform_workspace_url_for_private_link_if_needed, do_request, ) @@ -309,6 +310,116 @@ def __init__(self): assert "ErrorCode" == excinfo.value.status_code +@pytest.mark.parametrize( + "host_app_env, expected_suffix", + [ + ("VSCode-Extension", "; HostApp/VSCode-Extension"), # Valid, correct case + ("vscode-extension", "; HostApp/VSCode-Extension"), # Valid, lower case + ("VSCodE-ExTenSion", "; HostApp/VSCode-Extension"), # Valid, mixed case + ( + "Azure-DevOps-Pipeline", + "; HostApp/Azure-DevOps-Pipeline", + ), # Valid, correct case + ( + "azure-devops-pipeline", + "; HostApp/Azure-DevOps-Pipeline", + ), # Valid, lower case + ("Invalid-App", ""), # Invalid + ("", ""), # Empty + (None, ""), # Not set + ], +) +def test_get_host_app_suffix(host_app_env, expected_suffix, monkeypatch): + """Test the _get_host_app_suffix helper function.""" + if host_app_env is not None: + monkeypatch.setenv(fab_constant.FAB_HOST_APP_ENV_VAR, host_app_env) + else: + monkeypatch.delenv(fab_constant.FAB_HOST_APP_ENV_VAR, raising=False) + + result = _get_host_app_suffix() + + assert result == expected_suffix + + @pytest.fixture() def setup_default_private_links(mock_fab_set_state_config): mock_fab_set_state_config(fab_constant.FAB_WS_PRIVATE_LINKS_ENABLED, "true") + + +@patch("platform.release", return_value="5.4.0") +@patch("platform.machine", return_value="x86_64") +@patch("platform.system", return_value="Linux") +@patch("requests.Session.request") +@patch("fabric_cli.core.fab_auth.FabAuth") +@patch("fabric_cli.core.fab_context.Context") +@pytest.mark.parametrize( + "host_app_env, expected_suffix", + [ + (None, ""), # No env var set + ("VSCode-Extension", "; HostApp/VSCode-Extension"), # Valid and allowed + ( + "Azure-DevOps-Pipeline", + "; HostApp/Azure-DevOps-Pipeline", + ), # Valid and allowed + ( + "vscode-extension", + "; HostApp/VSCode-Extension", + ), # Valid and allowed (case-insensitive) + ("Invalid-App", ""), # Invalid and not in allowlist + ("", ""), # Empty value + ], +) +def test_do_request_user_agent_header( + mock_context, + mock_auth, + mock_request, + mock_system, + mock_machine, + mock_release, + host_app_env, + expected_suffix, + monkeypatch, +): + """Test User-Agent header construction with and without host app identifier.""" + if host_app_env is not None: + monkeypatch.setenv(fab_constant.FAB_HOST_APP_ENV_VAR, host_app_env) + else: + monkeypatch.delenv(fab_constant.FAB_HOST_APP_ENV_VAR, raising=False) + + # Configure mocks + mock_auth.return_value.get_access_token.return_value = "dummy-token" + mock_context.return_value.command = "test-command" + + class DummyResponse: + status_code = 200 + text = "{}" + content = b"{}" + headers = {} + + mock_request.return_value = DummyResponse() + + dummy_args = Namespace( + uri="items", + method="get", + audience=None, + headers=None, + wait=False, + raw_response=True, + request_params={}, + json_file=None, + ) + + do_request(dummy_args) + + # Verify the User-Agent header from the actual request call + call_kwargs = mock_request.call_args.kwargs + headers = call_kwargs["headers"] + user_agent = headers["User-Agent"] + + base_user_agent = ( + f"{fab_constant.API_USER_AGENT}/{fab_constant.FAB_VERSION} " + f"(test-command; Linux; x86_64; 5.4.0)" + ) + expected_user_agent = base_user_agent + expected_suffix + + assert user_agent == expected_user_agent From 55020f077694e45ca67d9ff6a940c5e44d286173 Mon Sep 17 00:00:00 2001 From: Alon Yeshurun Date: Sun, 14 Dec 2025 14:12:48 +0000 Subject: [PATCH 03/21] Fix new functionality section in release notes --- docs/release-notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/release-notes.md b/docs/release-notes.md index 852b6b7f..1d912e3d 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -10,7 +10,7 @@ hide: ### ✨ New Functionality -* Add support of mv, cp, export and import for SQLDatabase item type +* Add support of `mv`, `cp` and `import` commands for SQLDatabase item type * Add new 'job run-rm' command for remove a scheduled job * Enhance `set` command for items to support any settable property path within the item's definition and metadata structure * Add support in `ls` commmand using `-q` flag for filtering based on JMESPath expressions From beb01490bffaf32ff5321eb53f91264f535a3ea1 Mon Sep 17 00:00:00 2001 From: Alon Yeshurun Date: Sun, 14 Dec 2025 14:12:48 +0000 Subject: [PATCH 04/21] Fix new functionality section in release notes --- docs/release-notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/release-notes.md b/docs/release-notes.md index 98a1aa04..479c7cb5 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -10,7 +10,7 @@ hide: ### ✨ New Functionality -* Add support of mv, cp, export and import for SQLDatabase item type +* Add support of `mv`, `cp` and `import` commands for SQLDatabase item type * Add new 'job run-rm' command for remove a scheduled job * Enhance `set` command for items to support any settable property path within the item's definition and metadata structure * Add support in `ls` commmand using `-q` flag for filtering based on JMESPath expressions From ca313c305ad010157171ee7bfd9af66dc9a5d957 Mon Sep 17 00:00:00 2001 From: Alon Yeshurun Date: Wed, 17 Dec 2025 13:43:53 +0000 Subject: [PATCH 05/21] Introduce release workflow --- .github/workflows/create-release.yml | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/create-release.yml diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml new file mode 100644 index 00000000..819cd8cf --- /dev/null +++ b/.github/workflows/create-release.yml @@ -0,0 +1,37 @@ +name: 🚀 Create GitHub Release + +on: + workflow_dispatch: + inputs: + version: + description: 'The version to release (e.g., v1.2.0)' + required: true + +jobs: + create-release: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up release variables + id: set_vars + run: | + VERSION="${{ github.event.inputs.version }}" + echo "tag_name=$VERSION" >> $GITHUB_OUTPUT + echo "changelog_file_path=.changes/${VERSION}.md" >> $GITHUB_OUTPUT + + - name: Validate release notes file + run: | + if [ ! -f "${{ steps.set_vars.outputs.changelog_file_path }}" ]; then + echo "Error: Release notes file not found at ${{ steps.set_vars.outputs.changelog_file_path }}" + exit 1 + fi + + - name: Create Release with GitHub CLI + run: | + gh release create ${{ steps.set_vars.outputs.tag_name }} \ + --title "${{ steps.set_vars.outputs.tag_name }}" \ + --notes-file "${{ steps.set_vars.outputs.changelog_file_path }}" \ No newline at end of file From 39f2d851274d5d302ba9caeaf0a3768a69e13c2c Mon Sep 17 00:00:00 2001 From: Alon Yeshurun <98805507+ayeshurun@users.noreply.github.com> Date: Wed, 17 Dec 2025 16:21:05 +0200 Subject: [PATCH 06/21] Add GH_TOKEN to create release step --- .github/workflows/create-release.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 819cd8cf..e8dd7f15 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -31,7 +31,9 @@ jobs: fi - name: Create Release with GitHub CLI + env: + GH_TOKEN: ${{ github.token }} run: | gh release create ${{ steps.set_vars.outputs.tag_name }} \ --title "${{ steps.set_vars.outputs.tag_name }}" \ - --notes-file "${{ steps.set_vars.outputs.changelog_file_path }}" \ No newline at end of file + --notes-file "${{ steps.set_vars.outputs.changelog_file_path }}" From 5e3b68e2d33a6373f56631b15e6b17abc05e2b33 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 17 Dec 2025 14:29:08 +0000 Subject: [PATCH 07/21] Initial plan From 7c573b0285782f74cafea72d6db1d7b5c145c5b6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 17 Dec 2025 14:33:51 +0000 Subject: [PATCH 08/21] Enhance create-release workflow with GITHUB_STEP_SUMMARY and optional commit SHA Co-authored-by: ayeshurun <98805507+ayeshurun@users.noreply.github.com> --- .github/workflows/create-release.yml | 124 ++++++++++++++++++++++++++- 1 file changed, 120 insertions(+), 4 deletions(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index e8dd7f15..4494fd73 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -6,6 +6,10 @@ on: version: description: 'The version to release (e.g., v1.2.0)' required: true + commit_sha: + description: 'Optional: Commit SHA to create the tag on. If not provided, the tag will be created on the latest commit of the current branch (HEAD)' + required: false + default: '' jobs: create-release: @@ -15,25 +19,137 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + with: + fetch-depth: 0 # Required to access full commit history for validation + + - name: Display workflow information + run: | + echo "# 🚀 Create Release Workflow" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "## â„šī¸ Workflow Information" >> $GITHUB_STEP_SUMMARY + echo "- **Version:** ${{ github.event.inputs.version }}" >> $GITHUB_STEP_SUMMARY + if [ -n "${{ github.event.inputs.commit_sha }}" ]; then + echo "- **Target Commit:** \`${{ github.event.inputs.commit_sha }}\`" >> $GITHUB_STEP_SUMMARY + else + echo "- **Target Commit:** Latest commit on current branch (HEAD)" >> $GITHUB_STEP_SUMMARY + fi + echo "" >> $GITHUB_STEP_SUMMARY + + - name: Validate commit SHA (if provided) + if: ${{ github.event.inputs.commit_sha != '' }} + run: | + COMMIT_SHA="${{ github.event.inputs.commit_sha }}" + if ! git rev-parse --verify "$COMMIT_SHA^{commit}" >/dev/null 2>&1; then + echo "## ❌ Error: Invalid Commit SHA" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "The provided commit SHA \`$COMMIT_SHA\` is not valid or does not exist in this repository." >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### 📝 Troubleshooting" >> $GITHUB_STEP_SUMMARY + echo "- Verify the commit SHA exists in the repository" >> $GITHUB_STEP_SUMMARY + echo "- Ensure you are using the full commit SHA (or at least 7 characters)" >> $GITHUB_STEP_SUMMARY + echo "- Check that the commit is in the current branch history" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "Error: Invalid commit SHA: $COMMIT_SHA" + exit 1 + fi + echo "✅ Commit SHA validated successfully: $COMMIT_SHA" - name: Set up release variables id: set_vars run: | VERSION="${{ github.event.inputs.version }}" + COMMIT_SHA="${{ github.event.inputs.commit_sha }}" + + # Use provided commit SHA or default to HEAD + if [ -n "$COMMIT_SHA" ]; then + TARGET_COMMIT="$COMMIT_SHA" + else + TARGET_COMMIT="HEAD" + fi + echo "tag_name=$VERSION" >> $GITHUB_OUTPUT echo "changelog_file_path=.changes/${VERSION}.md" >> $GITHUB_OUTPUT + echo "target_commit=$TARGET_COMMIT" >> $GITHUB_OUTPUT + + # Get the actual commit SHA for display + ACTUAL_SHA=$(git rev-parse "$TARGET_COMMIT") + echo "actual_sha=$ACTUAL_SHA" >> $GITHUB_OUTPUT + + echo "✅ Release variables set:" + echo " - Tag name: $VERSION" + echo " - Target commit: $ACTUAL_SHA" + echo " - Changelog file: .changes/${VERSION}.md" - name: Validate release notes file run: | - if [ ! -f "${{ steps.set_vars.outputs.changelog_file_path }}" ]; then - echo "Error: Release notes file not found at ${{ steps.set_vars.outputs.changelog_file_path }}" + CHANGELOG_FILE="${{ steps.set_vars.outputs.changelog_file_path }}" + if [ ! -f "$CHANGELOG_FILE" ]; then + echo "## ❌ Error: Release Notes File Not Found" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "The release notes file was not found at the expected location:" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY + echo "$CHANGELOG_FILE" >> $GITHUB_STEP_SUMMARY + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### 📝 What to do:" >> $GITHUB_STEP_SUMMARY + echo "1. Ensure you have created the changelog file for version \`${{ steps.set_vars.outputs.tag_name }}\`" >> $GITHUB_STEP_SUMMARY + echo "2. The file should be located at: \`.changes/${{ steps.set_vars.outputs.tag_name }}.md\`" >> $GITHUB_STEP_SUMMARY + echo "3. You can use \`changie batch \` to generate the changelog file" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### 📂 Available changelog files:" >> $GITHUB_STEP_SUMMARY + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY + ls -1 .changes/*.md 2>/dev/null || echo "No changelog files found" >> $GITHUB_STEP_SUMMARY + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "Error: Release notes file not found at $CHANGELOG_FILE" exit 1 fi + echo "✅ Release notes file found at: $CHANGELOG_FILE" - name: Create Release with GitHub CLI env: GH_TOKEN: ${{ github.token }} run: | - gh release create ${{ steps.set_vars.outputs.tag_name }} \ + echo "## đŸ—ī¸ Creating Release" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "Creating release with the following details:" >> $GITHUB_STEP_SUMMARY + echo "- **Tag:** \`${{ steps.set_vars.outputs.tag_name }}\`" >> $GITHUB_STEP_SUMMARY + echo "- **Target Commit:** \`${{ steps.set_vars.outputs.actual_sha }}\`" >> $GITHUB_STEP_SUMMARY + echo "- **Notes File:** \`${{ steps.set_vars.outputs.changelog_file_path }}\`" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + + # Create the release with the target commit + if gh release create ${{ steps.set_vars.outputs.tag_name }} \ --title "${{ steps.set_vars.outputs.tag_name }}" \ - --notes-file "${{ steps.set_vars.outputs.changelog_file_path }}" + --notes-file "${{ steps.set_vars.outputs.changelog_file_path }}" \ + --target "${{ steps.set_vars.outputs.target_commit }}"; then + + echo "## ✅ Release Created Successfully!" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "🎉 **Release \`${{ steps.set_vars.outputs.tag_name }}\` has been created!**" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### 📋 Release Details:" >> $GITHUB_STEP_SUMMARY + echo "- **Tag:** \`${{ steps.set_vars.outputs.tag_name }}\`" >> $GITHUB_STEP_SUMMARY + echo "- **Commit:** \`${{ steps.set_vars.outputs.actual_sha }}\`" >> $GITHUB_STEP_SUMMARY + echo "- **Release URL:** [View Release](https://github.com/${{ github.repository }}/releases/tag/${{ steps.set_vars.outputs.tag_name }})" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + else + echo "## ❌ Error: Failed to Create Release" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "The GitHub CLI failed to create the release. This could be due to:" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### 🔍 Common Issues:" >> $GITHUB_STEP_SUMMARY + echo "- A release with tag \`${{ steps.set_vars.outputs.tag_name }}\` already exists" >> $GITHUB_STEP_SUMMARY + echo "- Insufficient permissions to create releases" >> $GITHUB_STEP_SUMMARY + echo "- Network connectivity issues" >> $GITHUB_STEP_SUMMARY + echo "- Invalid release notes format" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### 📝 Next Steps:" >> $GITHUB_STEP_SUMMARY + echo "1. Check if the tag already exists: \`git tag -l '${{ steps.set_vars.outputs.tag_name }}'\`" >> $GITHUB_STEP_SUMMARY + echo "2. Verify you have the necessary permissions to create releases" >> $GITHUB_STEP_SUMMARY + echo "3. Review the workflow run logs for detailed error messages" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "Error: Failed to create release" + exit 1 + fi From f9a4bb2a434fc2f23857477b38cb7d7be416c674 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 18 Dec 2025 08:31:07 +0000 Subject: [PATCH 09/21] Refactor GITHUB_STEP_SUMMARY messages to use heredoc syntax Co-authored-by: ayeshurun <98805507+ayeshurun@users.noreply.github.com> --- .github/workflows/create-release.yml | 144 +++++++++++++++------------ 1 file changed, 79 insertions(+), 65 deletions(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 4494fd73..fbaa15b3 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -24,31 +24,37 @@ jobs: - name: Display workflow information run: | - echo "# 🚀 Create Release Workflow" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "## â„šī¸ Workflow Information" >> $GITHUB_STEP_SUMMARY - echo "- **Version:** ${{ github.event.inputs.version }}" >> $GITHUB_STEP_SUMMARY if [ -n "${{ github.event.inputs.commit_sha }}" ]; then - echo "- **Target Commit:** \`${{ github.event.inputs.commit_sha }}\`" >> $GITHUB_STEP_SUMMARY + TARGET_INFO="- **Target Commit:** \`${{ github.event.inputs.commit_sha }}\`" else - echo "- **Target Commit:** Latest commit on current branch (HEAD)" >> $GITHUB_STEP_SUMMARY + TARGET_INFO="- **Target Commit:** Latest commit on current branch (HEAD)" fi - echo "" >> $GITHUB_STEP_SUMMARY + + cat >> $GITHUB_STEP_SUMMARY << EOF + # 🚀 Create Release Workflow + + ## â„šī¸ Workflow Information + - **Version:** ${{ github.event.inputs.version }} + $TARGET_INFO + + EOF - name: Validate commit SHA (if provided) if: ${{ github.event.inputs.commit_sha != '' }} run: | COMMIT_SHA="${{ github.event.inputs.commit_sha }}" if ! git rev-parse --verify "$COMMIT_SHA^{commit}" >/dev/null 2>&1; then - echo "## ❌ Error: Invalid Commit SHA" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "The provided commit SHA \`$COMMIT_SHA\` is not valid or does not exist in this repository." >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "### 📝 Troubleshooting" >> $GITHUB_STEP_SUMMARY - echo "- Verify the commit SHA exists in the repository" >> $GITHUB_STEP_SUMMARY - echo "- Ensure you are using the full commit SHA (or at least 7 characters)" >> $GITHUB_STEP_SUMMARY - echo "- Check that the commit is in the current branch history" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY + cat >> $GITHUB_STEP_SUMMARY << EOF + ## ❌ Error: Invalid Commit SHA + + The provided commit SHA \`$COMMIT_SHA\` is not valid or does not exist in this repository. + + ### 📝 Troubleshooting + - Verify the commit SHA exists in the repository + - Ensure you are using the full commit SHA (or at least 7 characters) + - Check that the commit is in the current branch history + + EOF echo "Error: Invalid commit SHA: $COMMIT_SHA" exit 1 fi @@ -84,24 +90,26 @@ jobs: run: | CHANGELOG_FILE="${{ steps.set_vars.outputs.changelog_file_path }}" if [ ! -f "$CHANGELOG_FILE" ]; then - echo "## ❌ Error: Release Notes File Not Found" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "The release notes file was not found at the expected location:" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "\`\`\`" >> $GITHUB_STEP_SUMMARY - echo "$CHANGELOG_FILE" >> $GITHUB_STEP_SUMMARY - echo "\`\`\`" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "### 📝 What to do:" >> $GITHUB_STEP_SUMMARY - echo "1. Ensure you have created the changelog file for version \`${{ steps.set_vars.outputs.tag_name }}\`" >> $GITHUB_STEP_SUMMARY - echo "2. The file should be located at: \`.changes/${{ steps.set_vars.outputs.tag_name }}.md\`" >> $GITHUB_STEP_SUMMARY - echo "3. You can use \`changie batch \` to generate the changelog file" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "### 📂 Available changelog files:" >> $GITHUB_STEP_SUMMARY - echo "\`\`\`" >> $GITHUB_STEP_SUMMARY - ls -1 .changes/*.md 2>/dev/null || echo "No changelog files found" >> $GITHUB_STEP_SUMMARY - echo "\`\`\`" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY + cat >> $GITHUB_STEP_SUMMARY << EOF + ## ❌ Error: Release Notes File Not Found + + The release notes file was not found at the expected location: + + \`\`\` + $CHANGELOG_FILE + \`\`\` + + ### 📝 What to do: + 1. Ensure you have created the changelog file for version \`${{ steps.set_vars.outputs.tag_name }}\` + 2. The file should be located at: \`.changes/${{ steps.set_vars.outputs.tag_name }}.md\` + 3. You can use \`changie batch \` to generate the changelog file + + ### 📂 Available changelog files: + \`\`\` + $(ls -1 .changes/*.md 2>/dev/null || echo "No changelog files found") + \`\`\` + + EOF echo "Error: Release notes file not found at $CHANGELOG_FILE" exit 1 fi @@ -111,13 +119,15 @@ jobs: env: GH_TOKEN: ${{ github.token }} run: | - echo "## đŸ—ī¸ Creating Release" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "Creating release with the following details:" >> $GITHUB_STEP_SUMMARY - echo "- **Tag:** \`${{ steps.set_vars.outputs.tag_name }}\`" >> $GITHUB_STEP_SUMMARY - echo "- **Target Commit:** \`${{ steps.set_vars.outputs.actual_sha }}\`" >> $GITHUB_STEP_SUMMARY - echo "- **Notes File:** \`${{ steps.set_vars.outputs.changelog_file_path }}\`" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY + cat >> $GITHUB_STEP_SUMMARY << EOF + ## đŸ—ī¸ Creating Release + + Creating release with the following details: + - **Tag:** \`${{ steps.set_vars.outputs.tag_name }}\` + - **Target Commit:** \`${{ steps.set_vars.outputs.actual_sha }}\` + - **Notes File:** \`${{ steps.set_vars.outputs.changelog_file_path }}\` + + EOF # Create the release with the target commit if gh release create ${{ steps.set_vars.outputs.tag_name }} \ @@ -125,31 +135,35 @@ jobs: --notes-file "${{ steps.set_vars.outputs.changelog_file_path }}" \ --target "${{ steps.set_vars.outputs.target_commit }}"; then - echo "## ✅ Release Created Successfully!" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "🎉 **Release \`${{ steps.set_vars.outputs.tag_name }}\` has been created!**" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "### 📋 Release Details:" >> $GITHUB_STEP_SUMMARY - echo "- **Tag:** \`${{ steps.set_vars.outputs.tag_name }}\`" >> $GITHUB_STEP_SUMMARY - echo "- **Commit:** \`${{ steps.set_vars.outputs.actual_sha }}\`" >> $GITHUB_STEP_SUMMARY - echo "- **Release URL:** [View Release](https://github.com/${{ github.repository }}/releases/tag/${{ steps.set_vars.outputs.tag_name }})" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY + cat >> $GITHUB_STEP_SUMMARY << EOF + ## ✅ Release Created Successfully! + + 🎉 **Release \`${{ steps.set_vars.outputs.tag_name }}\` has been created!** + + ### 📋 Release Details: + - **Tag:** \`${{ steps.set_vars.outputs.tag_name }}\` + - **Commit:** \`${{ steps.set_vars.outputs.actual_sha }}\` + - **Release URL:** [View Release](https://github.com/${{ github.repository }}/releases/tag/${{ steps.set_vars.outputs.tag_name }}) + + EOF else - echo "## ❌ Error: Failed to Create Release" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "The GitHub CLI failed to create the release. This could be due to:" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "### 🔍 Common Issues:" >> $GITHUB_STEP_SUMMARY - echo "- A release with tag \`${{ steps.set_vars.outputs.tag_name }}\` already exists" >> $GITHUB_STEP_SUMMARY - echo "- Insufficient permissions to create releases" >> $GITHUB_STEP_SUMMARY - echo "- Network connectivity issues" >> $GITHUB_STEP_SUMMARY - echo "- Invalid release notes format" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "### 📝 Next Steps:" >> $GITHUB_STEP_SUMMARY - echo "1. Check if the tag already exists: \`git tag -l '${{ steps.set_vars.outputs.tag_name }}'\`" >> $GITHUB_STEP_SUMMARY - echo "2. Verify you have the necessary permissions to create releases" >> $GITHUB_STEP_SUMMARY - echo "3. Review the workflow run logs for detailed error messages" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY + cat >> $GITHUB_STEP_SUMMARY << EOF + ## ❌ Error: Failed to Create Release + + The GitHub CLI failed to create the release. This could be due to: + + ### 🔍 Common Issues: + - A release with tag \`${{ steps.set_vars.outputs.tag_name }}\` already exists + - Insufficient permissions to create releases + - Network connectivity issues + - Invalid release notes format + + ### 📝 Next Steps: + 1. Check if the tag already exists: \`git tag -l '${{ steps.set_vars.outputs.tag_name }}'\` + 2. Verify you have the necessary permissions to create releases + 3. Review the workflow run logs for detailed error messages + + EOF echo "Error: Failed to create release" exit 1 fi From 641c4e768f65e6e348b1897e352bd4f0cbc39bae Mon Sep 17 00:00:00 2001 From: Alon Yeshurun <98805507+ayeshurun@users.noreply.github.com> Date: Mon, 22 Dec 2025 12:48:32 +0200 Subject: [PATCH 10/21] Update release notes for v1.3.1 --- docs/release-notes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/release-notes.md b/docs/release-notes.md index 479c7cb5..dc41a2b2 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -10,7 +10,7 @@ hide: ### ✨ New Functionality -* Add support of `mv`, `cp` and `import` commands for SQLDatabase item type +* Add support of mv, cp, export and import for SQLDatabase item type * Add new 'job run-rm' command for remove a scheduled job * Enhance `set` command for items to support any settable property path within the item's definition and metadata structure * Add support in `ls` commmand using `-q` flag for filtering based on JMESPath expressions @@ -165,4 +165,4 @@ hide: * Initial public release * Released to PyPI -* Onboarded to GitHub Pages \ No newline at end of file +* Onboarded to GitHub Pages From 516dbb8cb5dcbbcb1f76372ec9f1236498a10fcf Mon Sep 17 00:00:00 2001 From: Alon Yeshurun Date: Sun, 14 Dec 2025 14:12:48 +0000 Subject: [PATCH 11/21] Fix new functionality section in release notes --- docs/release-notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/release-notes.md b/docs/release-notes.md index dc41a2b2..056089bc 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -10,7 +10,7 @@ hide: ### ✨ New Functionality -* Add support of mv, cp, export and import for SQLDatabase item type +* Add support of `mv`, `cp` and `import` commands for SQLDatabase item type * Add new 'job run-rm' command for remove a scheduled job * Enhance `set` command for items to support any settable property path within the item's definition and metadata structure * Add support in `ls` commmand using `-q` flag for filtering based on JMESPath expressions From 484993f8291512a108bed94c975fc2bab2647399 Mon Sep 17 00:00:00 2001 From: Alon Yeshurun Date: Wed, 17 Dec 2025 13:43:53 +0000 Subject: [PATCH 12/21] Introduce release workflow --- .github/workflows/create-release.yml | 140 +-------------------------- 1 file changed, 4 insertions(+), 136 deletions(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index fbaa15b3..819cd8cf 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -6,10 +6,6 @@ on: version: description: 'The version to release (e.g., v1.2.0)' required: true - commit_sha: - description: 'Optional: Commit SHA to create the tag on. If not provided, the tag will be created on the latest commit of the current branch (HEAD)' - required: false - default: '' jobs: create-release: @@ -19,151 +15,23 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - with: - fetch-depth: 0 # Required to access full commit history for validation - - - name: Display workflow information - run: | - if [ -n "${{ github.event.inputs.commit_sha }}" ]; then - TARGET_INFO="- **Target Commit:** \`${{ github.event.inputs.commit_sha }}\`" - else - TARGET_INFO="- **Target Commit:** Latest commit on current branch (HEAD)" - fi - - cat >> $GITHUB_STEP_SUMMARY << EOF - # 🚀 Create Release Workflow - - ## â„šī¸ Workflow Information - - **Version:** ${{ github.event.inputs.version }} - $TARGET_INFO - - EOF - - - name: Validate commit SHA (if provided) - if: ${{ github.event.inputs.commit_sha != '' }} - run: | - COMMIT_SHA="${{ github.event.inputs.commit_sha }}" - if ! git rev-parse --verify "$COMMIT_SHA^{commit}" >/dev/null 2>&1; then - cat >> $GITHUB_STEP_SUMMARY << EOF - ## ❌ Error: Invalid Commit SHA - - The provided commit SHA \`$COMMIT_SHA\` is not valid or does not exist in this repository. - - ### 📝 Troubleshooting - - Verify the commit SHA exists in the repository - - Ensure you are using the full commit SHA (or at least 7 characters) - - Check that the commit is in the current branch history - - EOF - echo "Error: Invalid commit SHA: $COMMIT_SHA" - exit 1 - fi - echo "✅ Commit SHA validated successfully: $COMMIT_SHA" - name: Set up release variables id: set_vars run: | VERSION="${{ github.event.inputs.version }}" - COMMIT_SHA="${{ github.event.inputs.commit_sha }}" - - # Use provided commit SHA or default to HEAD - if [ -n "$COMMIT_SHA" ]; then - TARGET_COMMIT="$COMMIT_SHA" - else - TARGET_COMMIT="HEAD" - fi - echo "tag_name=$VERSION" >> $GITHUB_OUTPUT echo "changelog_file_path=.changes/${VERSION}.md" >> $GITHUB_OUTPUT - echo "target_commit=$TARGET_COMMIT" >> $GITHUB_OUTPUT - - # Get the actual commit SHA for display - ACTUAL_SHA=$(git rev-parse "$TARGET_COMMIT") - echo "actual_sha=$ACTUAL_SHA" >> $GITHUB_OUTPUT - - echo "✅ Release variables set:" - echo " - Tag name: $VERSION" - echo " - Target commit: $ACTUAL_SHA" - echo " - Changelog file: .changes/${VERSION}.md" - name: Validate release notes file run: | - CHANGELOG_FILE="${{ steps.set_vars.outputs.changelog_file_path }}" - if [ ! -f "$CHANGELOG_FILE" ]; then - cat >> $GITHUB_STEP_SUMMARY << EOF - ## ❌ Error: Release Notes File Not Found - - The release notes file was not found at the expected location: - - \`\`\` - $CHANGELOG_FILE - \`\`\` - - ### 📝 What to do: - 1. Ensure you have created the changelog file for version \`${{ steps.set_vars.outputs.tag_name }}\` - 2. The file should be located at: \`.changes/${{ steps.set_vars.outputs.tag_name }}.md\` - 3. You can use \`changie batch \` to generate the changelog file - - ### 📂 Available changelog files: - \`\`\` - $(ls -1 .changes/*.md 2>/dev/null || echo "No changelog files found") - \`\`\` - - EOF - echo "Error: Release notes file not found at $CHANGELOG_FILE" + if [ ! -f "${{ steps.set_vars.outputs.changelog_file_path }}" ]; then + echo "Error: Release notes file not found at ${{ steps.set_vars.outputs.changelog_file_path }}" exit 1 fi - echo "✅ Release notes file found at: $CHANGELOG_FILE" - name: Create Release with GitHub CLI - env: - GH_TOKEN: ${{ github.token }} run: | - cat >> $GITHUB_STEP_SUMMARY << EOF - ## đŸ—ī¸ Creating Release - - Creating release with the following details: - - **Tag:** \`${{ steps.set_vars.outputs.tag_name }}\` - - **Target Commit:** \`${{ steps.set_vars.outputs.actual_sha }}\` - - **Notes File:** \`${{ steps.set_vars.outputs.changelog_file_path }}\` - - EOF - - # Create the release with the target commit - if gh release create ${{ steps.set_vars.outputs.tag_name }} \ + gh release create ${{ steps.set_vars.outputs.tag_name }} \ --title "${{ steps.set_vars.outputs.tag_name }}" \ - --notes-file "${{ steps.set_vars.outputs.changelog_file_path }}" \ - --target "${{ steps.set_vars.outputs.target_commit }}"; then - - cat >> $GITHUB_STEP_SUMMARY << EOF - ## ✅ Release Created Successfully! - - 🎉 **Release \`${{ steps.set_vars.outputs.tag_name }}\` has been created!** - - ### 📋 Release Details: - - **Tag:** \`${{ steps.set_vars.outputs.tag_name }}\` - - **Commit:** \`${{ steps.set_vars.outputs.actual_sha }}\` - - **Release URL:** [View Release](https://github.com/${{ github.repository }}/releases/tag/${{ steps.set_vars.outputs.tag_name }}) - - EOF - else - cat >> $GITHUB_STEP_SUMMARY << EOF - ## ❌ Error: Failed to Create Release - - The GitHub CLI failed to create the release. This could be due to: - - ### 🔍 Common Issues: - - A release with tag \`${{ steps.set_vars.outputs.tag_name }}\` already exists - - Insufficient permissions to create releases - - Network connectivity issues - - Invalid release notes format - - ### 📝 Next Steps: - 1. Check if the tag already exists: \`git tag -l '${{ steps.set_vars.outputs.tag_name }}'\` - 2. Verify you have the necessary permissions to create releases - 3. Review the workflow run logs for detailed error messages - - EOF - echo "Error: Failed to create release" - exit 1 - fi + --notes-file "${{ steps.set_vars.outputs.changelog_file_path }}" \ No newline at end of file From 3a42a5cc88c1846bc164ea73a3e43a2a7549f4f1 Mon Sep 17 00:00:00 2001 From: Alon Yeshurun <98805507+ayeshurun@users.noreply.github.com> Date: Wed, 17 Dec 2025 16:21:05 +0200 Subject: [PATCH 13/21] Add GH_TOKEN to create release step --- .github/workflows/create-release.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 819cd8cf..e8dd7f15 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -31,7 +31,9 @@ jobs: fi - name: Create Release with GitHub CLI + env: + GH_TOKEN: ${{ github.token }} run: | gh release create ${{ steps.set_vars.outputs.tag_name }} \ --title "${{ steps.set_vars.outputs.tag_name }}" \ - --notes-file "${{ steps.set_vars.outputs.changelog_file_path }}" \ No newline at end of file + --notes-file "${{ steps.set_vars.outputs.changelog_file_path }}" From 0755733cee4f5bf85a6ef9533c5e44caaeb49a0e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 17 Dec 2025 14:29:08 +0000 Subject: [PATCH 14/21] Initial plan From 5917da7c91f018d0fedbacfe5d889e8651318d53 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 17 Dec 2025 14:33:51 +0000 Subject: [PATCH 15/21] Enhance create-release workflow with GITHUB_STEP_SUMMARY and optional commit SHA Co-authored-by: ayeshurun <98805507+ayeshurun@users.noreply.github.com> --- .github/workflows/create-release.yml | 124 ++++++++++++++++++++++++++- 1 file changed, 120 insertions(+), 4 deletions(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index e8dd7f15..4494fd73 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -6,6 +6,10 @@ on: version: description: 'The version to release (e.g., v1.2.0)' required: true + commit_sha: + description: 'Optional: Commit SHA to create the tag on. If not provided, the tag will be created on the latest commit of the current branch (HEAD)' + required: false + default: '' jobs: create-release: @@ -15,25 +19,137 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + with: + fetch-depth: 0 # Required to access full commit history for validation + + - name: Display workflow information + run: | + echo "# 🚀 Create Release Workflow" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "## â„šī¸ Workflow Information" >> $GITHUB_STEP_SUMMARY + echo "- **Version:** ${{ github.event.inputs.version }}" >> $GITHUB_STEP_SUMMARY + if [ -n "${{ github.event.inputs.commit_sha }}" ]; then + echo "- **Target Commit:** \`${{ github.event.inputs.commit_sha }}\`" >> $GITHUB_STEP_SUMMARY + else + echo "- **Target Commit:** Latest commit on current branch (HEAD)" >> $GITHUB_STEP_SUMMARY + fi + echo "" >> $GITHUB_STEP_SUMMARY + + - name: Validate commit SHA (if provided) + if: ${{ github.event.inputs.commit_sha != '' }} + run: | + COMMIT_SHA="${{ github.event.inputs.commit_sha }}" + if ! git rev-parse --verify "$COMMIT_SHA^{commit}" >/dev/null 2>&1; then + echo "## ❌ Error: Invalid Commit SHA" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "The provided commit SHA \`$COMMIT_SHA\` is not valid or does not exist in this repository." >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### 📝 Troubleshooting" >> $GITHUB_STEP_SUMMARY + echo "- Verify the commit SHA exists in the repository" >> $GITHUB_STEP_SUMMARY + echo "- Ensure you are using the full commit SHA (or at least 7 characters)" >> $GITHUB_STEP_SUMMARY + echo "- Check that the commit is in the current branch history" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "Error: Invalid commit SHA: $COMMIT_SHA" + exit 1 + fi + echo "✅ Commit SHA validated successfully: $COMMIT_SHA" - name: Set up release variables id: set_vars run: | VERSION="${{ github.event.inputs.version }}" + COMMIT_SHA="${{ github.event.inputs.commit_sha }}" + + # Use provided commit SHA or default to HEAD + if [ -n "$COMMIT_SHA" ]; then + TARGET_COMMIT="$COMMIT_SHA" + else + TARGET_COMMIT="HEAD" + fi + echo "tag_name=$VERSION" >> $GITHUB_OUTPUT echo "changelog_file_path=.changes/${VERSION}.md" >> $GITHUB_OUTPUT + echo "target_commit=$TARGET_COMMIT" >> $GITHUB_OUTPUT + + # Get the actual commit SHA for display + ACTUAL_SHA=$(git rev-parse "$TARGET_COMMIT") + echo "actual_sha=$ACTUAL_SHA" >> $GITHUB_OUTPUT + + echo "✅ Release variables set:" + echo " - Tag name: $VERSION" + echo " - Target commit: $ACTUAL_SHA" + echo " - Changelog file: .changes/${VERSION}.md" - name: Validate release notes file run: | - if [ ! -f "${{ steps.set_vars.outputs.changelog_file_path }}" ]; then - echo "Error: Release notes file not found at ${{ steps.set_vars.outputs.changelog_file_path }}" + CHANGELOG_FILE="${{ steps.set_vars.outputs.changelog_file_path }}" + if [ ! -f "$CHANGELOG_FILE" ]; then + echo "## ❌ Error: Release Notes File Not Found" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "The release notes file was not found at the expected location:" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY + echo "$CHANGELOG_FILE" >> $GITHUB_STEP_SUMMARY + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### 📝 What to do:" >> $GITHUB_STEP_SUMMARY + echo "1. Ensure you have created the changelog file for version \`${{ steps.set_vars.outputs.tag_name }}\`" >> $GITHUB_STEP_SUMMARY + echo "2. The file should be located at: \`.changes/${{ steps.set_vars.outputs.tag_name }}.md\`" >> $GITHUB_STEP_SUMMARY + echo "3. You can use \`changie batch \` to generate the changelog file" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### 📂 Available changelog files:" >> $GITHUB_STEP_SUMMARY + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY + ls -1 .changes/*.md 2>/dev/null || echo "No changelog files found" >> $GITHUB_STEP_SUMMARY + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "Error: Release notes file not found at $CHANGELOG_FILE" exit 1 fi + echo "✅ Release notes file found at: $CHANGELOG_FILE" - name: Create Release with GitHub CLI env: GH_TOKEN: ${{ github.token }} run: | - gh release create ${{ steps.set_vars.outputs.tag_name }} \ + echo "## đŸ—ī¸ Creating Release" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "Creating release with the following details:" >> $GITHUB_STEP_SUMMARY + echo "- **Tag:** \`${{ steps.set_vars.outputs.tag_name }}\`" >> $GITHUB_STEP_SUMMARY + echo "- **Target Commit:** \`${{ steps.set_vars.outputs.actual_sha }}\`" >> $GITHUB_STEP_SUMMARY + echo "- **Notes File:** \`${{ steps.set_vars.outputs.changelog_file_path }}\`" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + + # Create the release with the target commit + if gh release create ${{ steps.set_vars.outputs.tag_name }} \ --title "${{ steps.set_vars.outputs.tag_name }}" \ - --notes-file "${{ steps.set_vars.outputs.changelog_file_path }}" + --notes-file "${{ steps.set_vars.outputs.changelog_file_path }}" \ + --target "${{ steps.set_vars.outputs.target_commit }}"; then + + echo "## ✅ Release Created Successfully!" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "🎉 **Release \`${{ steps.set_vars.outputs.tag_name }}\` has been created!**" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### 📋 Release Details:" >> $GITHUB_STEP_SUMMARY + echo "- **Tag:** \`${{ steps.set_vars.outputs.tag_name }}\`" >> $GITHUB_STEP_SUMMARY + echo "- **Commit:** \`${{ steps.set_vars.outputs.actual_sha }}\`" >> $GITHUB_STEP_SUMMARY + echo "- **Release URL:** [View Release](https://github.com/${{ github.repository }}/releases/tag/${{ steps.set_vars.outputs.tag_name }})" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + else + echo "## ❌ Error: Failed to Create Release" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "The GitHub CLI failed to create the release. This could be due to:" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### 🔍 Common Issues:" >> $GITHUB_STEP_SUMMARY + echo "- A release with tag \`${{ steps.set_vars.outputs.tag_name }}\` already exists" >> $GITHUB_STEP_SUMMARY + echo "- Insufficient permissions to create releases" >> $GITHUB_STEP_SUMMARY + echo "- Network connectivity issues" >> $GITHUB_STEP_SUMMARY + echo "- Invalid release notes format" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### 📝 Next Steps:" >> $GITHUB_STEP_SUMMARY + echo "1. Check if the tag already exists: \`git tag -l '${{ steps.set_vars.outputs.tag_name }}'\`" >> $GITHUB_STEP_SUMMARY + echo "2. Verify you have the necessary permissions to create releases" >> $GITHUB_STEP_SUMMARY + echo "3. Review the workflow run logs for detailed error messages" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "Error: Failed to create release" + exit 1 + fi From 635eadc107fdd33d7d22239951eab46eef0f3b66 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 18 Dec 2025 08:31:07 +0000 Subject: [PATCH 16/21] Refactor GITHUB_STEP_SUMMARY messages to use heredoc syntax Co-authored-by: ayeshurun <98805507+ayeshurun@users.noreply.github.com> --- .github/workflows/create-release.yml | 144 +++++++++++++++------------ 1 file changed, 79 insertions(+), 65 deletions(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 4494fd73..fbaa15b3 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -24,31 +24,37 @@ jobs: - name: Display workflow information run: | - echo "# 🚀 Create Release Workflow" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "## â„šī¸ Workflow Information" >> $GITHUB_STEP_SUMMARY - echo "- **Version:** ${{ github.event.inputs.version }}" >> $GITHUB_STEP_SUMMARY if [ -n "${{ github.event.inputs.commit_sha }}" ]; then - echo "- **Target Commit:** \`${{ github.event.inputs.commit_sha }}\`" >> $GITHUB_STEP_SUMMARY + TARGET_INFO="- **Target Commit:** \`${{ github.event.inputs.commit_sha }}\`" else - echo "- **Target Commit:** Latest commit on current branch (HEAD)" >> $GITHUB_STEP_SUMMARY + TARGET_INFO="- **Target Commit:** Latest commit on current branch (HEAD)" fi - echo "" >> $GITHUB_STEP_SUMMARY + + cat >> $GITHUB_STEP_SUMMARY << EOF + # 🚀 Create Release Workflow + + ## â„šī¸ Workflow Information + - **Version:** ${{ github.event.inputs.version }} + $TARGET_INFO + + EOF - name: Validate commit SHA (if provided) if: ${{ github.event.inputs.commit_sha != '' }} run: | COMMIT_SHA="${{ github.event.inputs.commit_sha }}" if ! git rev-parse --verify "$COMMIT_SHA^{commit}" >/dev/null 2>&1; then - echo "## ❌ Error: Invalid Commit SHA" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "The provided commit SHA \`$COMMIT_SHA\` is not valid or does not exist in this repository." >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "### 📝 Troubleshooting" >> $GITHUB_STEP_SUMMARY - echo "- Verify the commit SHA exists in the repository" >> $GITHUB_STEP_SUMMARY - echo "- Ensure you are using the full commit SHA (or at least 7 characters)" >> $GITHUB_STEP_SUMMARY - echo "- Check that the commit is in the current branch history" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY + cat >> $GITHUB_STEP_SUMMARY << EOF + ## ❌ Error: Invalid Commit SHA + + The provided commit SHA \`$COMMIT_SHA\` is not valid or does not exist in this repository. + + ### 📝 Troubleshooting + - Verify the commit SHA exists in the repository + - Ensure you are using the full commit SHA (or at least 7 characters) + - Check that the commit is in the current branch history + + EOF echo "Error: Invalid commit SHA: $COMMIT_SHA" exit 1 fi @@ -84,24 +90,26 @@ jobs: run: | CHANGELOG_FILE="${{ steps.set_vars.outputs.changelog_file_path }}" if [ ! -f "$CHANGELOG_FILE" ]; then - echo "## ❌ Error: Release Notes File Not Found" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "The release notes file was not found at the expected location:" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "\`\`\`" >> $GITHUB_STEP_SUMMARY - echo "$CHANGELOG_FILE" >> $GITHUB_STEP_SUMMARY - echo "\`\`\`" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "### 📝 What to do:" >> $GITHUB_STEP_SUMMARY - echo "1. Ensure you have created the changelog file for version \`${{ steps.set_vars.outputs.tag_name }}\`" >> $GITHUB_STEP_SUMMARY - echo "2. The file should be located at: \`.changes/${{ steps.set_vars.outputs.tag_name }}.md\`" >> $GITHUB_STEP_SUMMARY - echo "3. You can use \`changie batch \` to generate the changelog file" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "### 📂 Available changelog files:" >> $GITHUB_STEP_SUMMARY - echo "\`\`\`" >> $GITHUB_STEP_SUMMARY - ls -1 .changes/*.md 2>/dev/null || echo "No changelog files found" >> $GITHUB_STEP_SUMMARY - echo "\`\`\`" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY + cat >> $GITHUB_STEP_SUMMARY << EOF + ## ❌ Error: Release Notes File Not Found + + The release notes file was not found at the expected location: + + \`\`\` + $CHANGELOG_FILE + \`\`\` + + ### 📝 What to do: + 1. Ensure you have created the changelog file for version \`${{ steps.set_vars.outputs.tag_name }}\` + 2. The file should be located at: \`.changes/${{ steps.set_vars.outputs.tag_name }}.md\` + 3. You can use \`changie batch \` to generate the changelog file + + ### 📂 Available changelog files: + \`\`\` + $(ls -1 .changes/*.md 2>/dev/null || echo "No changelog files found") + \`\`\` + + EOF echo "Error: Release notes file not found at $CHANGELOG_FILE" exit 1 fi @@ -111,13 +119,15 @@ jobs: env: GH_TOKEN: ${{ github.token }} run: | - echo "## đŸ—ī¸ Creating Release" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "Creating release with the following details:" >> $GITHUB_STEP_SUMMARY - echo "- **Tag:** \`${{ steps.set_vars.outputs.tag_name }}\`" >> $GITHUB_STEP_SUMMARY - echo "- **Target Commit:** \`${{ steps.set_vars.outputs.actual_sha }}\`" >> $GITHUB_STEP_SUMMARY - echo "- **Notes File:** \`${{ steps.set_vars.outputs.changelog_file_path }}\`" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY + cat >> $GITHUB_STEP_SUMMARY << EOF + ## đŸ—ī¸ Creating Release + + Creating release with the following details: + - **Tag:** \`${{ steps.set_vars.outputs.tag_name }}\` + - **Target Commit:** \`${{ steps.set_vars.outputs.actual_sha }}\` + - **Notes File:** \`${{ steps.set_vars.outputs.changelog_file_path }}\` + + EOF # Create the release with the target commit if gh release create ${{ steps.set_vars.outputs.tag_name }} \ @@ -125,31 +135,35 @@ jobs: --notes-file "${{ steps.set_vars.outputs.changelog_file_path }}" \ --target "${{ steps.set_vars.outputs.target_commit }}"; then - echo "## ✅ Release Created Successfully!" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "🎉 **Release \`${{ steps.set_vars.outputs.tag_name }}\` has been created!**" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "### 📋 Release Details:" >> $GITHUB_STEP_SUMMARY - echo "- **Tag:** \`${{ steps.set_vars.outputs.tag_name }}\`" >> $GITHUB_STEP_SUMMARY - echo "- **Commit:** \`${{ steps.set_vars.outputs.actual_sha }}\`" >> $GITHUB_STEP_SUMMARY - echo "- **Release URL:** [View Release](https://github.com/${{ github.repository }}/releases/tag/${{ steps.set_vars.outputs.tag_name }})" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY + cat >> $GITHUB_STEP_SUMMARY << EOF + ## ✅ Release Created Successfully! + + 🎉 **Release \`${{ steps.set_vars.outputs.tag_name }}\` has been created!** + + ### 📋 Release Details: + - **Tag:** \`${{ steps.set_vars.outputs.tag_name }}\` + - **Commit:** \`${{ steps.set_vars.outputs.actual_sha }}\` + - **Release URL:** [View Release](https://github.com/${{ github.repository }}/releases/tag/${{ steps.set_vars.outputs.tag_name }}) + + EOF else - echo "## ❌ Error: Failed to Create Release" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "The GitHub CLI failed to create the release. This could be due to:" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "### 🔍 Common Issues:" >> $GITHUB_STEP_SUMMARY - echo "- A release with tag \`${{ steps.set_vars.outputs.tag_name }}\` already exists" >> $GITHUB_STEP_SUMMARY - echo "- Insufficient permissions to create releases" >> $GITHUB_STEP_SUMMARY - echo "- Network connectivity issues" >> $GITHUB_STEP_SUMMARY - echo "- Invalid release notes format" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "### 📝 Next Steps:" >> $GITHUB_STEP_SUMMARY - echo "1. Check if the tag already exists: \`git tag -l '${{ steps.set_vars.outputs.tag_name }}'\`" >> $GITHUB_STEP_SUMMARY - echo "2. Verify you have the necessary permissions to create releases" >> $GITHUB_STEP_SUMMARY - echo "3. Review the workflow run logs for detailed error messages" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY + cat >> $GITHUB_STEP_SUMMARY << EOF + ## ❌ Error: Failed to Create Release + + The GitHub CLI failed to create the release. This could be due to: + + ### 🔍 Common Issues: + - A release with tag \`${{ steps.set_vars.outputs.tag_name }}\` already exists + - Insufficient permissions to create releases + - Network connectivity issues + - Invalid release notes format + + ### 📝 Next Steps: + 1. Check if the tag already exists: \`git tag -l '${{ steps.set_vars.outputs.tag_name }}'\` + 2. Verify you have the necessary permissions to create releases + 3. Review the workflow run logs for detailed error messages + + EOF echo "Error: Failed to create release" exit 1 fi From 22cc9cb859a54276701237c8a19c5afaafd93f81 Mon Sep 17 00:00:00 2001 From: Alon Yeshurun <98805507+ayeshurun@users.noreply.github.com> Date: Mon, 22 Dec 2025 12:48:32 +0200 Subject: [PATCH 17/21] Update release notes for v1.3.1 --- docs/release-notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/release-notes.md b/docs/release-notes.md index 056089bc..dc41a2b2 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -10,7 +10,7 @@ hide: ### ✨ New Functionality -* Add support of `mv`, `cp` and `import` commands for SQLDatabase item type +* Add support of mv, cp, export and import for SQLDatabase item type * Add new 'job run-rm' command for remove a scheduled job * Enhance `set` command for items to support any settable property path within the item's definition and metadata structure * Add support in `ls` commmand using `-q` flag for filtering based on JMESPath expressions From bd2ad0f40a12bb9b2b911828e23266c9f254420f Mon Sep 17 00:00:00 2001 From: Alon Yeshurun Date: Thu, 25 Dec 2025 09:37:01 +0000 Subject: [PATCH 18/21] Add changelog entry --- .changes/unreleased/optimization-20251225-093649.yaml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changes/unreleased/optimization-20251225-093649.yaml diff --git a/.changes/unreleased/optimization-20251225-093649.yaml b/.changes/unreleased/optimization-20251225-093649.yaml new file mode 100644 index 00000000..21ef5f40 --- /dev/null +++ b/.changes/unreleased/optimization-20251225-093649.yaml @@ -0,0 +1,3 @@ +kind: optimization +body: Add HostApp identifier in the User-Agent header for API requests +time: 2025-12-25T09:36:49.142459793Z From aa0695244fc3c0600c4d3f5a084456b2482f7aec Mon Sep 17 00:00:00 2001 From: Alon Yeshurun Date: Thu, 25 Dec 2025 09:37:40 +0000 Subject: [PATCH 19/21] Remove changelog --- .changes/unreleased/optimization-20251225-093649.yaml | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .changes/unreleased/optimization-20251225-093649.yaml diff --git a/.changes/unreleased/optimization-20251225-093649.yaml b/.changes/unreleased/optimization-20251225-093649.yaml deleted file mode 100644 index 21ef5f40..00000000 --- a/.changes/unreleased/optimization-20251225-093649.yaml +++ /dev/null @@ -1,3 +0,0 @@ -kind: optimization -body: Add HostApp identifier in the User-Agent header for API requests -time: 2025-12-25T09:36:49.142459793Z From 756dd4066b874660c06d443702c066c9e4a3c4b9 Mon Sep 17 00:00:00 2001 From: Alon Yeshurun Date: Thu, 25 Dec 2025 09:51:00 +0000 Subject: [PATCH 20/21] Update host app value --- src/fabric_cli/core/fab_constant.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/fabric_cli/core/fab_constant.py b/src/fabric_cli/core/fab_constant.py index e76c9034..0ae87c6e 100644 --- a/src/fabric_cli/core/fab_constant.py +++ b/src/fabric_cli/core/fab_constant.py @@ -324,9 +324,7 @@ ################################################ ### Only allowed for modification by CLI team ## -ALLOWED_FAB_HOST_APP_VALUES = [ - # "CLI-ADO-Pipeline" -] +ALLOWED_FAB_HOST_APP_VALUES = ["Fabric-AzureDevops-Extension"] ################################################ # Item set constants From ec9ee93e8ee93bce4f4314cdb65f0fa05cf598e6 Mon Sep 17 00:00:00 2001 From: Alon Yeshurun Date: Thu, 25 Dec 2025 11:13:38 +0000 Subject: [PATCH 21/21] Add fab host app version --- src/fabric_cli/client/fab_api_client.py | 35 +++++-- src/fabric_cli/core/fab_constant.py | 3 +- tests/test_core/test_fab_api_client.py | 126 ++++++++++++++++++------ 3 files changed, 123 insertions(+), 41 deletions(-) diff --git a/src/fabric_cli/client/fab_api_client.py b/src/fabric_cli/client/fab_api_client.py index a013bb56..b4344b22 100644 --- a/src/fabric_cli/client/fab_api_client.py +++ b/src/fabric_cli/client/fab_api_client.py @@ -282,14 +282,21 @@ def _handle_successful_response(args: Namespace, response: ApiResponse) -> ApiRe def _build_user_agent(ctxt_cmd: str) -> str: - """Build the User-Agent header for API requests, including context command and HostApp if applicable.""" - base_user_agent = f"{fab_constant.API_USER_AGENT}/{fab_constant.FAB_VERSION} ({ctxt_cmd}; {platform.system()}; {platform.machine()}; {platform.release()})" - host_app_suffix = _get_host_app_suffix() - return f"{base_user_agent}{host_app_suffix}" + """Build the User-Agent header for API requests. + + Example: + ms-fabric-cli/1.0.0 (create; Windows/10; Python/3.10.2) host-app/ado/2.0.0 + """ + user_agent = f"{fab_constant.API_USER_AGENT}/{fab_constant.FAB_VERSION} ({ctxt_cmd}; {platform.system()}/{platform.release()}; Python/{platform.python_version()})" + host_app = _get_host_app() + if host_app: + user_agent += host_app + + return user_agent -def _get_host_app_suffix() -> str: - """Get the HostApp suffix for the User-Agent header based on environment variable. +def _get_host_app() -> str: + """Get the HostApp suffix for the User-Agent header based on environment variables. Returns an empty string if the environment variable is not set or has an invalid value. """ @@ -297,7 +304,7 @@ def _get_host_app_suffix() -> str: if not _host_app_in_env: return "" - host_app = next( + host_app_name = next( ( allowed_app for allowed_app in fab_constant.ALLOWED_FAB_HOST_APP_VALUES @@ -306,10 +313,20 @@ def _get_host_app_suffix() -> str: None, ) - if not host_app: + if not host_app_name: return "" - return f"; HostApp/{host_app}" + host_app = f" host-app/{host_app_name.lower()}" + + # Check for optional version + host_app_version = os.environ.get(fab_constant.FAB_HOST_APP_VERSION_ENV_VAR) + + # validate host_app_version format is a valid version (e.g., 1.0.0) + if host_app_version and re.match( + r"^\d+(\.\d+){0,2}(-[a-zA-Z0-9\.-]+)?$", host_app_version + ): + host_app += f"/{host_app_version}" + return host_app def _print_response_details(response: ApiResponse) -> None: diff --git a/src/fabric_cli/core/fab_constant.py b/src/fabric_cli/core/fab_constant.py index 0ae87c6e..84dfa159 100644 --- a/src/fabric_cli/core/fab_constant.py +++ b/src/fabric_cli/core/fab_constant.py @@ -64,7 +64,8 @@ IDENTITY_TYPE: ["user", "service_principal", "managed_identity"], } -FAB_HOST_APP_ENV_VAR = "FABRIC_CLI_HOST_APP" +FAB_HOST_APP_ENV_VAR = "FAB_HOST_APP" +FAB_HOST_APP_VERSION_ENV_VAR = "FAB_HOST_APP_VERSION" # Other constants FAB_CAPACITY_NAME_NONE = "none" diff --git a/tests/test_core/test_fab_api_client.py b/tests/test_core/test_fab_api_client.py index 75005188..8817fbf1 100644 --- a/tests/test_core/test_fab_api_client.py +++ b/tests/test_core/test_fab_api_client.py @@ -8,7 +8,7 @@ import pytest from fabric_cli.client.fab_api_client import ( - _get_host_app_suffix, + _get_host_app, _transform_workspace_url_for_private_link_if_needed, do_request, ) @@ -311,32 +311,88 @@ def __init__(self): @pytest.mark.parametrize( - "host_app_env, expected_suffix", + "host_app_env, host_app_version_env, expected_suffix", [ - ("VSCode-Extension", "; HostApp/VSCode-Extension"), # Valid, correct case - ("vscode-extension", "; HostApp/VSCode-Extension"), # Valid, lower case - ("VSCodE-ExTenSion", "; HostApp/VSCode-Extension"), # Valid, mixed case ( - "Azure-DevOps-Pipeline", - "; HostApp/Azure-DevOps-Pipeline", - ), # Valid, correct case + "Fabric-AzureDevops-Extension", + None, + " host-app/fabric-azuredevops-extension", + ), ( - "azure-devops-pipeline", - "; HostApp/Azure-DevOps-Pipeline", - ), # Valid, lower case - ("Invalid-App", ""), # Invalid - ("", ""), # Empty - (None, ""), # Not set + "Fabric-AzureDevops-Extension", + "1.2.0", + " host-app/fabric-azuredevops-extension/1.2.0", + ), + ( + "fabric-azuredevops-extension", + "1.2.0", + " host-app/fabric-azuredevops-extension/1.2.0", + ), + ("Invalid-App", "1.0.0", ""), + ("", None, ""), + (None, None, ""), + ( + "Fabric-AzureDevops-Extension", + "1.2.0.4", # Invalid format + " host-app/fabric-azuredevops-extension", + ), + ( + "Fabric-AzureDevops-Extension", + "1.2.a", # Invalid format + " host-app/fabric-azuredevops-extension", + ), + ( + "Fabric-AzureDevops-Extension", + "a.b.c", # Invalid format + " host-app/fabric-azuredevops-extension", + ), + ( + "Fabric-AzureDevops-Extension", + "1", # valid format + " host-app/fabric-azuredevops-extension/1", + ), + ( + "Fabric-AzureDevops-Extension", + "1.2", # valid format + " host-app/fabric-azuredevops-extension/1.2", + ), + ( + "Fabric-AzureDevops-Extension", + "1.0.0", # valid format + " host-app/fabric-azuredevops-extension/1.0.0", + ), + ( + "Fabric-AzureDevops-Extension", + "1.0.0-rc.1", # valid format + " host-app/fabric-azuredevops-extension/1.0.0-rc.1", + ), + ( + "Fabric-AzureDevops-Extension", + "1.0.0-alpha", # valid format + " host-app/fabric-azuredevops-extension/1.0.0-alpha", + ), + ( + "Fabric-AzureDevops-Extension", + "1.0.0-beta", # valid format + " host-app/fabric-azuredevops-extension/1.0.0-beta", + ), ], ) -def test_get_host_app_suffix(host_app_env, expected_suffix, monkeypatch): - """Test the _get_host_app_suffix helper function.""" +def test_get_host_app(host_app_env, host_app_version_env, expected_suffix, monkeypatch): + """Test the _get_host_app helper function.""" if host_app_env is not None: monkeypatch.setenv(fab_constant.FAB_HOST_APP_ENV_VAR, host_app_env) else: monkeypatch.delenv(fab_constant.FAB_HOST_APP_ENV_VAR, raising=False) - result = _get_host_app_suffix() + if host_app_version_env is not None: + monkeypatch.setenv( + fab_constant.FAB_HOST_APP_VERSION_ENV_VAR, host_app_version_env + ) + else: + monkeypatch.delenv(fab_constant.FAB_HOST_APP_VERSION_ENV_VAR, raising=False) + + result = _get_host_app() assert result == expected_suffix @@ -346,27 +402,27 @@ def setup_default_private_links(mock_fab_set_state_config): mock_fab_set_state_config(fab_constant.FAB_WS_PRIVATE_LINKS_ENABLED, "true") +@patch("platform.python_version", return_value="3.11.5") @patch("platform.release", return_value="5.4.0") -@patch("platform.machine", return_value="x86_64") @patch("platform.system", return_value="Linux") @patch("requests.Session.request") @patch("fabric_cli.core.fab_auth.FabAuth") @patch("fabric_cli.core.fab_context.Context") @pytest.mark.parametrize( - "host_app_env, expected_suffix", + "host_app_env, host_app_version_env, expected_suffix", [ - (None, ""), # No env var set - ("VSCode-Extension", "; HostApp/VSCode-Extension"), # Valid and allowed + (None, None, ""), ( - "Azure-DevOps-Pipeline", - "; HostApp/Azure-DevOps-Pipeline", - ), # Valid and allowed + "Fabric-AzureDevops-Extension", + None, + " host-app/fabric-azuredevops-extension", + ), ( - "vscode-extension", - "; HostApp/VSCode-Extension", - ), # Valid and allowed (case-insensitive) - ("Invalid-App", ""), # Invalid and not in allowlist - ("", ""), # Empty value + "Fabric-AzureDevops-Extension", + "1.2.0", + " host-app/fabric-azuredevops-extension/1.2.0", + ), + ("Invalid-App", "1.0.0", ""), ], ) def test_do_request_user_agent_header( @@ -374,9 +430,10 @@ def test_do_request_user_agent_header( mock_auth, mock_request, mock_system, - mock_machine, mock_release, + mock_python_version, host_app_env, + host_app_version_env, expected_suffix, monkeypatch, ): @@ -386,6 +443,13 @@ def test_do_request_user_agent_header( else: monkeypatch.delenv(fab_constant.FAB_HOST_APP_ENV_VAR, raising=False) + if host_app_version_env is not None: + monkeypatch.setenv( + fab_constant.FAB_HOST_APP_VERSION_ENV_VAR, host_app_version_env + ) + else: + monkeypatch.delenv(fab_constant.FAB_HOST_APP_VERSION_ENV_VAR, raising=False) + # Configure mocks mock_auth.return_value.get_access_token.return_value = "dummy-token" mock_context.return_value.command = "test-command" @@ -418,7 +482,7 @@ class DummyResponse: base_user_agent = ( f"{fab_constant.API_USER_AGENT}/{fab_constant.FAB_VERSION} " - f"(test-command; Linux; x86_64; 5.4.0)" + f"(test-command; Linux/5.4.0; Python/3.11.5)" ) expected_user_agent = base_user_agent + expected_suffix