diff --git a/.github/workflows/api-compliance-runner.yml b/.github/workflows/api-compliance-runner.yml index 784912f1da..d77cd5696f 100644 --- a/.github/workflows/api-compliance-runner.yml +++ b/.github/workflows/api-compliance-runner.yml @@ -49,28 +49,36 @@ jobs: - name: Determine test parameters id: params + env: + PATTERNS_INPUT: ${{ github.event.inputs.patterns }} + MODELS_INPUT: ${{ github.event.inputs.models }} run: | # Use input values or defaults if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then - PATTERNS="${{ github.event.inputs.patterns }}" - MODELS="${{ github.event.inputs.models }}" + PATTERNS="$PATTERNS_INPUT" + MODELS="$MODELS_INPUT" else PATTERNS="" MODELS="" fi - # Build command args - ARGS="" - if [ -n "$PATTERNS" ]; then - ARGS="$ARGS --patterns $PATTERNS" - fi - if [ -n "$MODELS" ]; then - ARGS="$ARGS --models $MODELS" - else - ARGS="$ARGS --models $DEFAULT_MODELS" + if [ -z "$MODELS" ]; then + MODELS="$DEFAULT_MODELS" fi - echo "args=$ARGS" >> $GITHUB_OUTPUT + write_output() { + local name=$1 + local value=$2 + local delimiter="${name}_$(openssl rand -hex 16)" + { + echo "$name<<$delimiter" + printf '%s\n' "$value" + echo "$delimiter" + } >> "$GITHUB_OUTPUT" + } + + write_output patterns "$PATTERNS" + write_output models "$MODELS" - name: Run API compliance tests id: compliance @@ -78,9 +86,16 @@ jobs: LLM_API_KEY: ${{ secrets.LLM_API_KEY_EVAL }} LLM_BASE_URL: https://llm-proxy.eval.all-hands.dev GITHUB_RUN_ID: ${{ github.run_id }} + PATTERNS: ${{ steps.params.outputs.patterns }} + MODELS: ${{ steps.params.outputs.models }} run: | + args=(--models "$MODELS") + if [ -n "$PATTERNS" ]; then + args=(--patterns "$PATTERNS" "${args[@]}") + fi + uv run python tests/integration/api_compliance/run_compliance.py \ - ${{ steps.params.outputs.args }} \ + "${args[@]}" \ --output-dir compliance-results/ continue-on-error: true # Tests may "fail" but that's expected diff --git a/.github/workflows/condenser-runner.yml b/.github/workflows/condenser-runner.yml index 962da506e1..ceeab809e4 100644 --- a/.github/workflows/condenser-runner.yml +++ b/.github/workflows/condenser-runner.yml @@ -228,6 +228,8 @@ jobs: - name: Create consolidated PR comment if: github.event_name == 'pull_request_target' + env: + GH_TOKEN: ${{ github.token }} run: | # Add header to clarify these are non-blocking tests echo "## Condenser Test Results (Non-Blocking)" > final_report.md @@ -240,5 +242,3 @@ jobs: COMMENT_BODY=$(uv run python -c "from openhands.sdk.utils.github import sanitize_openhands_mentions; import sys; print(sanitize_openhands_mentions(sys.stdin.read()), end='')" < final_report.md) # Use GitHub CLI to create comment with explicit PR number echo "$COMMENT_BODY" | gh pr comment ${{ github.event.pull_request.number }} --body-file - - env: - GH_TOKEN: ${{ github.token }} diff --git a/.github/workflows/integration-runner.yml b/.github/workflows/integration-runner.yml index 009c1006d9..9da76653bb 100644 --- a/.github/workflows/integration-runner.yml +++ b/.github/workflows/integration-runner.yml @@ -86,15 +86,18 @@ jobs: echo "Using specified model_ids: $MODEL_IDS" fi + export MODEL_IDS + # Resolve model configs using resolve_model_config.py # Transform output to matrix format for integration tests - MATRIX=$(python3 << EOF + MATRIX=$(python3 << 'EOF' import json + import os import sys sys.path.insert(0, '.github/run-eval') from resolve_model_config import MODELS - model_ids = "$MODEL_IDS".split(",") + model_ids = os.environ["MODEL_IDS"].split(",") model_ids = [m.strip() for m in model_ids if m.strip()] matrix = [] @@ -129,7 +132,6 @@ jobs: id: resolve-issue env: ISSUE_NUMBER_INPUT: ${{ github.event.inputs.issue_number || '' }} - PR_NUMBER: ${{ github.event.pull_request.number }} run: | # Priority: explicit input > PR number from label trigger if [ -n "$ISSUE_NUMBER_INPUT" ]; then @@ -260,6 +262,8 @@ jobs: # Run integration test evaluation - name: Determine test selection + env: + TEST_TYPE_INPUT: ${{ github.event.inputs.test_type }} run: | TEST_TYPE_ARGS="" if [ "${{ github.event_name }}" = "pull_request_target" ] && [ "${{ github.event.label.name }}" = "behavior-test" ]; then @@ -269,7 +273,7 @@ jobs: TEST_TYPE_ARGS="--test-type integration" echo "integration-test label detected; running integration tests only." elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then - test_type="${{ github.event.inputs.test_type }}" + test_type="$TEST_TYPE_INPUT" case "$test_type" in behavior) TEST_TYPE_ARGS="--test-type behavior" @@ -415,8 +419,6 @@ jobs: - name: Consolidate test results env: - EVENT_NAME: ${{ github.event_name }} - PR_NUMBER: ${{ github.event.pull_request.number }} MANUAL_REASON: ${{ github.event.inputs.reason }} COMMIT_SHA: ${{ github.sha }} PYTHONPATH: ${{ github.workspace }} diff --git a/.github/workflows/pr-artifacts.yml b/.github/workflows/pr-artifacts.yml index 5d233e5e51..d5fac6a56c 100644 --- a/.github/workflows/pr-artifacts.yml +++ b/.github/workflows/pr-artifacts.yml @@ -23,8 +23,11 @@ jobs: steps: - name: Check if fork PR id: check-fork + env: + PR_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }} + PR_BASE_REPO: ${{ github.event.pull_request.base.repo.full_name }} run: | - if [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.event.pull_request.base.repo.full_name }}" ]; then + if [ "$PR_HEAD_REPO" != "$PR_BASE_REPO" ]; then echo "is_fork=true" >> $GITHUB_OUTPUT echo "::notice::Fork PR detected - skipping auto-cleanup (manual removal required)" else diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index 1aa6e632ee..2101779743 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -14,12 +14,14 @@ jobs: runs-on: ubuntu-24.04 steps: - name: Validate version format + env: + INPUTS_VERSION: ${{ inputs.version }} run: | - if ! [[ "${{ inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + if ! [[ "$INPUTS_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then echo "❌ Invalid version format. Expected: X.Y.Z (e.g., 1.2.3)" exit 1 fi - echo "✅ Version format is valid: ${{ inputs.version }}" + echo "✅ Version format is valid: $INPUTS_VERSION" - name: Checkout repository uses: actions/checkout@v6 @@ -38,27 +40,35 @@ jobs: git config user.email "github-actions[bot]@users.noreply.github.com" - name: Create release branch + env: + INPUTS_VERSION: ${{ inputs.version }} run: | - BRANCH_NAME="rel-${{ inputs.version }}" + BRANCH_NAME="rel-$INPUTS_VERSION" echo "Creating branch: $BRANCH_NAME" git checkout -b "$BRANCH_NAME" echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV - name: Set package version + env: + INPUTS_VERSION: ${{ inputs.version }} run: | - echo "🔧 Setting version to ${{ inputs.version }}" - make set-package-version version=${{ inputs.version }} + echo "🔧 Setting version to $INPUTS_VERSION" + make set-package-version version="$INPUTS_VERSION" - name: Update sdk_ref default in run-eval workflow - run: python3 .github/scripts/update_sdk_ref_default.py "${{ inputs.version }}" + env: + INPUTS_VERSION: ${{ inputs.version }} + run: python3 .github/scripts/update_sdk_ref_default.py "$INPUTS_VERSION" - name: Commit version changes + env: + INPUTS_VERSION: ${{ inputs.version }} run: | git add . if git diff --staged --quiet; then echo "No changes to commit" else - git commit -m "Release v${{ inputs.version }}" -m "Co-authored-by: openhands " + git commit -m "Release v$INPUTS_VERSION" -m "Co-authored-by: openhands " echo "✅ Changes committed" fi @@ -70,14 +80,15 @@ jobs: - name: Create Pull Request env: GH_TOKEN: ${{ secrets.OPENHANDS_BOT_GITHUB_PAT_PUBLIC }} + INPUTS_VERSION: ${{ inputs.version }} run: | cat > pr_body.txt << 'EOF' - ## Release v${{ inputs.version }} + ## Release v__VERSION__ - This PR prepares the release for version **${{ inputs.version }}**. + This PR prepares the release for version **__VERSION__**. ### Release Checklist - - [x] Version set to ${{ inputs.version }} + - [x] Version set to __VERSION__ - [ ] Fix any deprecation deadlines if they exist - [ ] Integration tests pass (tagged with `integration-test`) - [ ] Behavior tests pass (tagged with `behavior-test`) @@ -87,13 +98,14 @@ jobs: ### What happens on merge When this PR is merged, the `create-release.yml` workflow will automatically: - 1. Create a GitHub release with tag `v${{ inputs.version }}` and auto-generated notes, plus an explicit preamble for merged `release-note-required` PRs + 1. Create a GitHub release with tag `v__VERSION__` and auto-generated notes, plus an explicit preamble for merged `release-note-required` PRs 2. Trigger `pypi-release.yml` to publish all packages to PyPI 3. Trigger `version-bump-prs.yml` to create downstream version bump PRs EOF + sed -i "s/__VERSION__/$INPUTS_VERSION/g" pr_body.txt gh pr create \ - --title "Release v${{ inputs.version }}" \ + --title "Release v$INPUTS_VERSION" \ --body-file pr_body.txt \ --base main \ --head "${{ env.BRANCH_NAME }}" \ @@ -110,10 +122,12 @@ jobs: echo "PR_URL=$PR_URL" >> $GITHUB_ENV - name: Summary + env: + INPUTS_VERSION: ${{ inputs.version }} run: | echo "## ✅ Release Preparation Complete!" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY - echo "- **Version**: ${{ inputs.version }}" >> $GITHUB_STEP_SUMMARY + echo "- **Version**: $INPUTS_VERSION" >> $GITHUB_STEP_SUMMARY echo "- **Branch**: ${{ env.BRANCH_NAME }}" >> $GITHUB_STEP_SUMMARY echo "- **PR URL**: ${{ env.PR_URL }}" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index 8e05fb03ec..319b71af4b 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -28,10 +28,12 @@ jobs: - name: Extract version from release tag id: extract_version + env: + GITHUB_EVENT_RELEASE_TAG_NAME: ${{ github.event.release.tag_name }} run: | # Get version from release tag (e.g., v1.2.3 -> 1.2.3) if [[ "${{ github.event_name }}" == "release" ]]; then - VERSION="${{ github.event.release.tag_name }}" + VERSION="$GITHUB_EVENT_RELEASE_TAG_NAME" VERSION="${VERSION#v}" # Remove 'v' prefix if present else # For manual dispatch, extract from pyproject.toml diff --git a/.github/workflows/release-binaries.yml b/.github/workflows/release-binaries.yml index 71ef04c020..71617a0999 100644 --- a/.github/workflows/release-binaries.yml +++ b/.github/workflows/release-binaries.yml @@ -38,13 +38,16 @@ jobs: steps: - id: resolve shell: bash + env: + GITHUB_EVENT_RELEASE_TAG_NAME: ${{ github.event.release.tag_name }} + INPUTS_RELEASE_TAG: ${{ inputs.release_tag }} run: | set -euo pipefail if [[ "${{ github.event_name }}" == "release" ]]; then - TAG="${{ github.event.release.tag_name }}" + TAG="$GITHUB_EVENT_RELEASE_TAG_NAME" VERSION="${TAG#v}" elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then - TAG="${{ inputs.release_tag }}" + TAG="$INPUTS_RELEASE_TAG" VERSION="${TAG#v}" elif [[ "${{ github.event_name }}" == "push" ]]; then TAG="" diff --git a/.github/workflows/server.yml b/.github/workflows/server.yml index c3ab529464..f7bceb4583 100644 --- a/.github/workflows/server.yml +++ b/.github/workflows/server.yml @@ -351,6 +351,8 @@ jobs: - name: Prepare build context and metadata id: prep + env: + GITHUB_REF: ${{ github.ref }} run: | uv sync --frozen @@ -358,7 +360,7 @@ jobs: # build.py now handles architecture tagging internally via --arch flag # Add --versioned-tag when triggered by a git tag (e.g., v1.0.0) BUILD_CMD="uv run ./openhands-agent-server/openhands/agent_server/docker/build.py --build-ctx-only --arch ${{ matrix.arch }}" - if [[ "${{ github.ref }}" == refs/tags/* ]]; then + if [[ "$GITHUB_REF" == refs/tags/* ]]; then BUILD_CMD="$BUILD_CMD --versioned-tag" fi eval "$BUILD_CMD" @@ -403,37 +405,54 @@ jobs: - name: Cleanup build context if: always() + env: + BUILD_CONTEXT: ${{ steps.prep.outputs.build_context }} run: | - if [ -n "${{ steps.prep.outputs.build_context }}" ] && [ -d "${{ steps.prep.outputs.build_context }}" ]; then - echo "Cleaning up build context: ${{ steps.prep.outputs.build_context }}" - rm -rf "${{ steps.prep.outputs.build_context }}" + if [ -n "$BUILD_CONTEXT" ] && [ -d "$BUILD_CONTEXT" ]; then + echo "Cleaning up build context: $BUILD_CONTEXT" + rm -rf "$BUILD_CONTEXT" fi - name: Summary (${{ matrix.variant }}-${{ matrix.arch }}) - outputs + env: + SHORT_SHA: ${{ steps.prep.outputs.short_sha }} + TAGS: ${{ steps.prep.outputs.tags }} + BUILD_DIGEST: ${{ steps.build.outputs.digest }} run: | - echo "Image: ${{ env.IMAGE }}" - echo "Variant: ${{ env.VARIANT }}" - echo "Architecture: ${{ env.ARCH }}" - echo "Platform: ${{ env.PLATFORM }}" - echo "Short SHA: ${{ steps.prep.outputs.short_sha }}" - echo "Tags: ${{ steps.prep.outputs.tags }}" - echo "Build digest: ${{ steps.build.outputs.digest }}" + echo "Image: $IMAGE" + echo "Variant: $VARIANT" + echo "Architecture: $ARCH" + echo "Platform: $PLATFORM" + echo "Short SHA: $SHORT_SHA" + echo "Tags: $TAGS" + echo "Build digest: $BUILD_DIGEST" - name: Save build info for consolidation + env: + SHORT_SHA: ${{ steps.prep.outputs.short_sha }} + TAGS: ${{ steps.prep.outputs.tags }} + VERSIONED_TAGS_CSV: ${{ steps.prep.outputs.versioned_tags_csv }} run: | mkdir -p build-info - cat > "build-info/${{ matrix.variant }}-${{ matrix.arch }}.json" << EOF - { - "variant": "${{ matrix.variant }}", - "arch": "${{ matrix.arch }}", - "base_image": "${{ matrix.base_image }}", - "image": "${{ env.IMAGE }}", - "short_sha": "${{ steps.prep.outputs.short_sha }}", - "tags": "${{ steps.prep.outputs.tags }}", - "versioned_tags_csv": "${{ steps.prep.outputs.versioned_tags_csv }}", - "platform": "${{ env.PLATFORM }}" - } - EOF + jq -n \ + --arg variant "$VARIANT" \ + --arg arch "$ARCH" \ + --arg base_image "$BASE_IMAGE" \ + --arg image "$IMAGE" \ + --arg short_sha "$SHORT_SHA" \ + --arg tags "$TAGS" \ + --arg versioned_tags_csv "$VERSIONED_TAGS_CSV" \ + --arg platform "$PLATFORM" \ + '{ + variant: $variant, + arch: $arch, + base_image: $base_image, + image: $image, + short_sha: $short_sha, + tags: $tags, + versioned_tags_csv: $versioned_tags_csv, + platform: $platform + }' > "build-info/${{ matrix.variant }}-${{ matrix.arch }}.json" - name: Upload build info artifact uses: actions/upload-artifact@v7 @@ -485,9 +504,11 @@ jobs: - name: Create and push multi-arch manifest for ${{ matrix.variant }} id: create_manifest + env: + GIT_REF: ${{ github.ref }} + SHORT_SHA: ${{ steps.get_sha.outputs.short_sha }} + VARIANT: ${{ matrix.variant }} run: | - SHORT_SHA=${{ steps.get_sha.outputs.short_sha }} - VARIANT=${{ matrix.variant }} AMD64_TAGS_CSV=$(jq -r '.tags' build-info/${VARIANT}-amd64.json) declare -A SEEN_MANIFEST_TAGS=() MANIFEST_TAGS=() @@ -529,7 +550,7 @@ jobs: done # Preserve the latest- alias used by the workspace defaults. - if [ "${{ github.ref }}" == "refs/heads/main" ]; then + if [ "$GIT_REF" == "refs/heads/main" ]; then LATEST_TAG="latest-${VARIANT}" create_manifest "$LATEST_TAG" "main-${VARIANT}" MANIFEST_TAGS+=("$LATEST_TAG") @@ -539,14 +560,17 @@ jobs: # Save manifest info for consolidation mkdir -p manifest-info - cat > "manifest-info/${VARIANT}.json" << EOF - { - "variant": "${VARIANT}", - "image": "${IMAGE}", - "short_sha": "${SHORT_SHA}", - "manifest_tag": "${MANIFEST_TAG_CSV}" - } - EOF + jq -n \ + --arg variant "$VARIANT" \ + --arg image "$IMAGE" \ + --arg short_sha "$SHORT_SHA" \ + --arg manifest_tag "$MANIFEST_TAG_CSV" \ + '{ + variant: $variant, + image: $image, + short_sha: $short_sha, + manifest_tag: $manifest_tag + }' > "manifest-info/${VARIANT}.json" - name: Upload manifest info artifact uses: actions/upload-artifact@v7 @@ -731,13 +755,15 @@ jobs: steps: - name: Generate PR description from build summary id: generate_description + env: + BUILD_SUMMARY_JSON: ${{ needs.consolidate-build-info.outputs.build_summary }} run: | echo "Event: ${{ github.event_name }}" echo "PR number: ${{ github.event.number }}" echo "Run attempt: ${{ github.run_attempt }}" # Parse the build summary JSON - BUILD_SUMMARY='${{ needs.consolidate-build-info.outputs.build_summary }}' + BUILD_SUMMARY="$BUILD_SUMMARY_JSON" echo "Build summary received:" echo "$BUILD_SUMMARY" | jq . diff --git a/.github/workflows/todo-management.yml b/.github/workflows/todo-management.yml index 43f006050f..6b5ea55247 100644 --- a/.github/workflows/todo-management.yml +++ b/.github/workflows/todo-management.yml @@ -71,11 +71,14 @@ jobs: - name: Scan for TODOs id: scan + env: + TODO_IDENTIFIER_INPUT: ${{ github.event.inputs.todo_identifier || 'TODO(openhands)' }} + MAX_TODOS_INPUT: ${{ github.event.inputs.max_todos || '3' }} run: | echo "Scanning for TODO comments..." # Run the scanner and capture output - TODO_IDENTIFIER="${{ github.event.inputs.todo_identifier || 'TODO(openhands)' }}" + TODO_IDENTIFIER="$TODO_IDENTIFIER_INPUT" python /tmp/scanner.py . --identifier "$TODO_IDENTIFIER" > todos.json # Count TODOs @@ -84,7 +87,7 @@ jobs: echo "Found $TODO_COUNT $TODO_IDENTIFIER items" # Limit the number of TODOs to process - MAX_TODOS="${{ github.event.inputs.max_todos || '3' }}" + MAX_TODOS="$MAX_TODOS_INPUT" if [ "$TODO_COUNT" -gt "$MAX_TODOS" ]; then echo "Limiting to first $MAX_TODOS TODOs" python -c " @@ -175,6 +178,7 @@ jobs: TODO_FILE: ${{ matrix.todo.file }} TODO_LINE: ${{ matrix.todo.line }} TODO_DESCRIPTION: ${{ matrix.todo.description }} + BASE_REF: ${{ github.event.pull_request.base.ref || github.ref_name }} PYTHONPATH: '' run: | echo "Processing TODO: $TODO_DESCRIPTION" @@ -282,17 +286,19 @@ jobs: --- *This PR was created automatically by the TODO Management workflow.*" + PR_PAYLOAD=$(jq -n \ + --arg title "$PR_TITLE" \ + --arg body "$PR_BODY" \ + --arg head "$BRANCH_NAME" \ + --arg base "$BASE_REF" \ + '{title: $title, body: $body, head: $head, base: $base}') + # Create PR using GitHub CLI or API curl -X POST \ -H "Authorization: token $GITHUB_TOKEN" \ -H "Accept: application/vnd.github.v3+json" \ "https://api.github.com/repos/${{ github.repository }}/pulls" \ - -d "{ - \"title\": \"$PR_TITLE\", - \"body\": \"$PR_BODY\", - \"head\": \"$BRANCH_NAME\", - \"base\": \"${{ github.ref_name }}\" - }" + -d "$PR_PAYLOAD" summary: needs: [scan-todos, process-todos] diff --git a/.github/workflows/version-bump-prs.yml b/.github/workflows/version-bump-prs.yml index ac42a50518..50ce3549a3 100644 --- a/.github/workflows/version-bump-prs.yml +++ b/.github/workflows/version-bump-prs.yml @@ -23,9 +23,15 @@ jobs: - name: Get version from release or input id: get_version + env: + VERSION_INPUT: ${{ github.event.inputs.version }} run: | - VERSION="${{ github.event.inputs.version }}" - echo "version=$VERSION" >> $GITHUB_OUTPUT + VERSION="$VERSION_INPUT" + if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "❌ Invalid version format. Expected: X.Y.Z (e.g., 1.2.3)" + exit 1 + fi + echo "version=$VERSION" >> "$GITHUB_OUTPUT" echo "📦 Version: $VERSION" - name: Validate version diff --git a/examples/03_github_workflows/03_todo_management/workflow.yml b/examples/03_github_workflows/03_todo_management/workflow.yml index b42f090b41..0cf72f500a 100644 --- a/examples/03_github_workflows/03_todo_management/workflow.yml +++ b/examples/03_github_workflows/03_todo_management/workflow.yml @@ -73,11 +73,14 @@ jobs: - name: Scan for TODOs id: scan + env: + GITHUB_EVENT_INPUTS_TODO_IDENTIFIER: ${{ github.event.inputs.todo_identifier || 'TODO(openhands)' }} + GITHUB_EVENT_INPUTS_MAX_TODOS: ${{ github.event.inputs.max_todos || '3' }} run: | echo "Scanning for TODO comments..." # Run the scanner and capture output - TODO_IDENTIFIER="${{ github.event.inputs.todo_identifier || 'TODO(openhands)' }}" + TODO_IDENTIFIER="$GITHUB_EVENT_INPUTS_TODO_IDENTIFIER" python /tmp/scanner.py . --identifier "$TODO_IDENTIFIER" > todos.json # Count TODOs @@ -86,7 +89,7 @@ jobs: echo "Found $TODO_COUNT $TODO_IDENTIFIER items" # Limit the number of TODOs to process - MAX_TODOS="${{ github.event.inputs.max_todos || '3' }}" + MAX_TODOS="$GITHUB_EVENT_INPUTS_MAX_TODOS" if [ "$TODO_COUNT" -gt "$MAX_TODOS" ]; then echo "Limiting to first $MAX_TODOS TODOs" python -c " @@ -178,6 +181,7 @@ jobs: TODO_LINE: ${{ matrix.todo.line }} TODO_DESCRIPTION: ${{ matrix.todo.description }} PYTHONPATH: '' + BASE_REF: ${{ github.event.pull_request.base.ref || github.ref_name }} run: | echo "Processing TODO: $TODO_DESCRIPTION" echo "File: $TODO_FILE:$TODO_LINE" @@ -284,17 +288,19 @@ jobs: --- *This PR was created automatically by the TODO Management workflow.*" + PR_PAYLOAD=$(jq -n \ + --arg title "$PR_TITLE" \ + --arg body "$PR_BODY" \ + --arg head "$BRANCH_NAME" \ + --arg base "$BASE_REF" \ + '{title: $title, body: $body, head: $head, base: $base}') + # Create PR using GitHub CLI or API curl -X POST \ -H "Authorization: token $GITHUB_TOKEN" \ -H "Accept: application/vnd.github.v3+json" \ "https://api.github.com/repos/${{ github.repository }}/pulls" \ - -d "{ - \"title\": \"$PR_TITLE\", - \"body\": \"$PR_BODY\", - \"head\": \"$BRANCH_NAME\", - \"base\": \"${{ github.ref_name }}\" - }" + -d "$PR_PAYLOAD" summary: needs: [scan-todos, process-todos] diff --git a/examples/03_github_workflows/04_datadog_debugging/workflow.yml b/examples/03_github_workflows/04_datadog_debugging/workflow.yml index 80e2d1b31f..6779784758 100644 --- a/examples/03_github_workflows/04_datadog_debugging/workflow.yml +++ b/examples/03_github_workflows/04_datadog_debugging/workflow.yml @@ -89,17 +89,28 @@ jobs: LLM_MODEL: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PYTHONPATH: '' + INPUTS_QUERY_TYPE: ${{ inputs.query_type }} + INPUTS_DATADOG_QUERY: ${{ inputs.datadog_query }} + INPUTS_REPO_LIST: ${{ inputs.repo_list }} + INPUTS_ISSUE_REPO: ${{ inputs.issue_repo }} + INPUTS_ISSUE_PARENT: ${{ inputs.issue_parent }} + INPUTS_ISSUE_PREFIX: ${{ inputs.issue_prefix }} run: | mkdir -p /tmp/datadog-debug cd /tmp/datadog-debug-script + ISSUE_PARENT_ARG=() + if [ -n "$INPUTS_ISSUE_PARENT" ]; then + ISSUE_PARENT_ARG=(--issue-parent "$INPUTS_ISSUE_PARENT") + fi + python datadog_debugging.py \ - --query-type "${{ inputs.query_type }}" \ - --query "${{ inputs.datadog_query }}" \ - --repos "${{ inputs.repo_list }}" \ + --query-type "$INPUTS_QUERY_TYPE" \ + --query "$INPUTS_DATADOG_QUERY" \ + --repos "$INPUTS_REPO_LIST" \ --working-dir "/tmp/datadog-debug" \ - --issue-repo "${{ inputs.issue_repo }}" \ - --issue-parent "${{ inputs.issue_parent }}" \ - --issue-prefix "${{ inputs.issue_prefix }}" + --issue-repo "$INPUTS_ISSUE_REPO" \ + "${ISSUE_PARENT_ARG[@]}" \ + --issue-prefix "$INPUTS_ISSUE_PREFIX" - name: Upload debugging artifacts if: always() diff --git a/examples/03_github_workflows/05_posthog_debugging/workflow.yml b/examples/03_github_workflows/05_posthog_debugging/workflow.yml index 0464fa603d..b99c0a0c4c 100644 --- a/examples/03_github_workflows/05_posthog_debugging/workflow.yml +++ b/examples/03_github_workflows/05_posthog_debugging/workflow.yml @@ -83,15 +83,26 @@ jobs: LLM_API_KEY: ${{ secrets.LLM_API_KEY }} LLM_BASE_URL: ${{ secrets.LLM_BASE_URL }} LLM_MODEL: ${{ inputs.llm_model }} + INPUTS_QUERY_TYPE: ${{ inputs.query_type }} + INPUTS_POSTHOG_QUERY: ${{ inputs.posthog_query }} + INPUTS_REPO_LIST: ${{ inputs.repo_list }} + INPUTS_ISSUE_REPO: ${{ inputs.issue_repo }} + INPUTS_ISSUE_PARENT: ${{ inputs.issue_parent }} + INPUTS_ISSUE_PREFIX: ${{ inputs.issue_prefix }} run: | cd posthog_debug_tools + ISSUE_PARENT_ARG=() + if [ -n "$INPUTS_ISSUE_PARENT" ]; then + ISSUE_PARENT_ARG=(--issue-parent "$INPUTS_ISSUE_PARENT") + fi + python posthog_debugging.py \ - --query-type "${{ inputs.query_type }}" \ - --query "${{ inputs.posthog_query }}" \ - --repos "${{ inputs.repo_list }}" \ - --issue-repo "${{ inputs.issue_repo }}" \ - ${{ inputs.issue_parent && format('--issue-parent "{0}"', inputs.issue_parent) || '' }} \ - --issue-prefix "${{ inputs.issue_prefix }}" \ + --query-type "$INPUTS_QUERY_TYPE" \ + --query "$INPUTS_POSTHOG_QUERY" \ + --repos "$INPUTS_REPO_LIST" \ + --issue-repo "$INPUTS_ISSUE_REPO" \ + "${ISSUE_PARENT_ARG[@]}" \ + --issue-prefix "$INPUTS_ISSUE_PREFIX" \ --working-dir ./workspace - name: Upload debugging artifacts