Add Poetry package manager support for Python #2172
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test Scenario Workflow | |
| on: | |
| issue_comment: | |
| types: [created] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| test-scenario: | |
| # Only run when the comment starts with /test-scenario on a PR | |
| if: >- | |
| ${{ | |
| startsWith(github.event.comment.body, '/test-scenario') && | |
| github.event.issue.pull_request | |
| }} | |
| runs-on: ubuntu-latest | |
| env: | |
| REPO_OWNER: dotnet | |
| REPO_NAME: aspire-playground | |
| GH_CLI_VERSION: 2.81.0 | |
| GH_PLAYGROUND_TOKEN: ${{ secrets.GH_PLAYGROUND_TOKEN }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Parse and validate scenario name | |
| id: parse_scenario | |
| env: | |
| COMMENT_BODY: ${{ github.event.comment.body }} | |
| run: | | |
| echo "Comment body: $COMMENT_BODY" | |
| # Extract scenario name from comment | |
| SCENARIO_NAME=$(echo "$COMMENT_BODY" | \ | |
| grep -oP '^/test-scenario\s+\K[a-z0-9]+(-[a-z0-9]+)*[a-z0-9]$' | head -1) | |
| if [ -z "$SCENARIO_NAME" ]; then | |
| echo "Error: Invalid or missing scenario name" | |
| echo "Expected format: /test-scenario scenario-name" | |
| echo "Scenario name must be lowercase alphanumeric with hyphens" | |
| exit 1 | |
| fi | |
| echo "Scenario name: $SCENARIO_NAME" | |
| echo "scenario_name=$SCENARIO_NAME" >> $GITHUB_OUTPUT | |
| - name: Check for prompt file | |
| id: check_prompt | |
| run: | | |
| SCENARIO_NAME="${{ steps.parse_scenario.outputs.scenario_name }}" | |
| PROMPT_FILE="tests/agent-scenarios/${SCENARIO_NAME}/prompt.md" | |
| if [ ! -f "$PROMPT_FILE" ]; then | |
| echo "Error: Prompt file not found at $PROMPT_FILE" | |
| exit 1 | |
| fi | |
| echo "Found prompt file: $PROMPT_FILE" | |
| echo "prompt_file=$PROMPT_FILE" >> $GITHUB_OUTPUT | |
| - name: Download and install GitHub CLI | |
| run: | | |
| CURRENT_VERSION="" | |
| if command -v gh &> /dev/null; then | |
| CURRENT_VERSION=$(gh --version | \ | |
| grep -oP 'gh version \K[0-9]+\.[0-9]+\.[0-9]+' | head -1) | |
| echo "Current GitHub CLI version: $CURRENT_VERSION" | |
| fi | |
| if [ "$CURRENT_VERSION" = "$GH_CLI_VERSION" ]; then | |
| echo "GitHub CLI v${GH_CLI_VERSION} already installed" | |
| else | |
| echo "Downloading GitHub CLI v${GH_CLI_VERSION}..." | |
| DOWNLOAD_URL="https://github.com/cli/cli/releases/download/v${GH_CLI_VERSION}" | |
| ARCHIVE_NAME="gh_${GH_CLI_VERSION}_linux_amd64.tar.gz" | |
| curl -fsSL "${DOWNLOAD_URL}/${ARCHIVE_NAME}" -o gh.tar.gz | |
| tar -xzf gh.tar.gz | |
| sudo mv "gh_${GH_CLI_VERSION}_linux_amd64/bin/gh" /usr/local/bin/ | |
| rm -rf gh.tar.gz "gh_${GH_CLI_VERSION}_linux_amd64" | |
| echo "Verifying GitHub CLI installation..." | |
| gh --version | |
| fi | |
| - name: Create issue and assign to copilot | |
| id: create_issue | |
| run: | | |
| echo "Creating issue in aspire-playground repository..." | |
| PROMPT_FILE="${{ steps.check_prompt.outputs.prompt_file }}" | |
| SCENARIO_NAME="${{ steps.parse_scenario.outputs.scenario_name }}" | |
| SOURCE_PR_URL="${{ github.event.issue.html_url }}" | |
| SOURCE_PR_NUMBER="${{ github.event.issue.number }}" | |
| SOURCE_REPO="${{ github.repository }}" | |
| # Auth using the token | |
| gh auth login --with-token <<< "$GH_PLAYGROUND_TOKEN" | |
| # Build the issue body with context from the source PR and the prompt | |
| ISSUE_TITLE="Test Scenario: ${SCENARIO_NAME}" | |
| # Read prompt content first | |
| PROMPT_CONTENT=$(cat "$PROMPT_FILE") | |
| # Build issue body using printf with proper format strings to avoid injection | |
| printf -v ISSUE_BODY '%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s' \ | |
| "## Test Scenario Request" \ | |
| "" \ | |
| "**Scenario:** ${SCENARIO_NAME}" \ | |
| "**Source PR:** ${SOURCE_PR_URL}" \ | |
| "**Source Repository:** ${SOURCE_REPO}" \ | |
| "" \ | |
| "---" \ | |
| "" \ | |
| "$PROMPT_CONTENT" \ | |
| "" \ | |
| "---" \ | |
| "" \ | |
| "This issue was created automatically from PR #${SOURCE_PR_NUMBER} in ${SOURCE_REPO}." | |
| # Create the issue and assign to copilot | |
| echo "Creating issue with title: $ISSUE_TITLE" | |
| ISSUE_OUTPUT=$(gh issue create \ | |
| --repo "${REPO_OWNER}/${REPO_NAME}" \ | |
| --title "$ISSUE_TITLE" \ | |
| --body "$ISSUE_BODY" \ | |
| --assignee "copilot-swe-agent" \ | |
| 2>&1) | |
| echo "Issue creation output:" | |
| echo "$ISSUE_OUTPUT" | |
| # Extract the issue URL from the output | |
| ISSUE_URL=$(echo "$ISSUE_OUTPUT" | \ | |
| grep -oP 'https://github.com/[^/]+/[^/]+/issues/\d+' | head -1) | |
| if [ -z "$ISSUE_URL" ]; then | |
| echo "Error: Could not extract issue URL from output" | |
| exit 1 | |
| fi | |
| echo "Successfully created issue: $ISSUE_URL" | |
| echo "issue_url=$ISSUE_URL" >> $GITHUB_OUTPUT | |
| # Extract issue number for later use | |
| ISSUE_NUMBER=$(echo "$ISSUE_URL" | grep -oP '/issues/\K\d+') | |
| echo "issue_number=$ISSUE_NUMBER" >> $GITHUB_OUTPUT | |
| - name: Comment on PR with issue link | |
| uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const issueUrl = '${{ steps.create_issue.outputs.issue_url }}'; | |
| const scenarioName = '${{ steps.parse_scenario.outputs.scenario_name }}'; | |
| const comment = `🤖 **AI Agent Task Created** | |
| Scenario: **${scenarioName}** | |
| An AI agent has been assigned to execute this scenario. | |
| 📝 **Issue:** ${issueUrl} | |
| Please navigate to the issue for more details and to track progress.`; | |
| await github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: comment | |
| }); |