-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat(action): Add reusable GitHub action #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| name: "Run AI SDK Integration Tests" | ||
| description: "Run AI SDK integration tests for a specific language (js or python) and report failures" | ||
| author: "Sentry Telemetry Experience Team" | ||
|
|
||
| branding: | ||
| icon: "triangle" | ||
| color: "purple" | ||
|
|
||
| inputs: | ||
| language: | ||
| description: "SDK language to test. One of: js, python" | ||
| required: true | ||
| openai-api-key: | ||
| description: "OpenAI API key" | ||
| required: true | ||
| anthropic-api-key: | ||
| description: "Anthropic API key" | ||
| required: true | ||
| google-api-key: | ||
| description: "Google API key for GenAI" | ||
| required: true | ||
|
|
||
| outputs: | ||
| success: | ||
| description: "Whether all tests passed" | ||
| value: ${{ steps.run-tests.outputs.success }} | ||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "20" | ||
|
|
||
| - name: Setup Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.13" | ||
|
|
||
| - name: Install orchestration dependencies | ||
| shell: bash | ||
| working-directory: ${{ github.action_path }}/shared/orchestration | ||
| run: npm install | ||
|
|
||
| - name: Setup SDK dependencies | ||
| shell: bash | ||
| working-directory: ${{ github.action_path }} | ||
| run: npm run cli setup | ||
|
|
||
| - name: Run tests | ||
| id: run-tests | ||
| shell: bash | ||
| working-directory: ${{ github.action_path }} | ||
| env: | ||
| OPENAI_API_KEY: ${{ inputs.openai-api-key }} | ||
| ANTHROPIC_API_KEY: ${{ inputs.anthropic-api-key }} | ||
| GOOGLE_API_KEY: ${{ inputs.google-api-key }} | ||
| run: | | ||
| set +e | ||
| npm run cli run ${{ inputs.language }} --reports ctrf | ||
| EXIT_CODE=$? | ||
| set -e | ||
|
|
||
| if [ $EXIT_CODE -eq 0 ]; then | ||
| echo "success=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "success=false" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| exit $EXIT_CODE | ||
|
|
||
| - name: Create or update issue on failure | ||
| if: failure() | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| const language = '${{ inputs.language }}'; | ||
| const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; | ||
|
|
||
| // Try to read test results from CTRF report | ||
| let resultsContent = 'Test execution failed. Check the [workflow run](' + runUrl + ') for details.'; | ||
| const ctrfPath = '${{ github.action_path }}/shared/orchestration/test-results/ctrf-report.json'; | ||
This comment was marked as outdated.
Sorry, something went wrong.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, this should be the correct path. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: CTRF test report is written to 🔍 Detailed AnalysisThe GitHub action has a path mismatch for the CTRF test report file. The 💡 Suggested FixEither add 🤖 Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. |
||
|
|
||
| if (fs.existsSync(ctrfPath)) { | ||
| try { | ||
| const results = JSON.parse(fs.readFileSync(ctrfPath, 'utf8')); | ||
| resultsContent = '### Test Results\n\n```json\n' + JSON.stringify(results, null, 2) + '\n```'; | ||
| } catch (e) { | ||
| console.log('Could not parse test results:', e.message); | ||
| } | ||
| } | ||
|
|
||
| const issueLabel = 'ai-integration-test-failure'; | ||
| const today = new Date().toISOString().split('T')[0]; | ||
|
|
||
| const body = `## AI Integration Test Failure | ||
|
|
||
| **Language**: ${language} | ||
| **Date**: ${new Date().toISOString()} | ||
| **Workflow Run**: ${runUrl} | ||
|
|
||
| ${resultsContent} | ||
|
|
||
| --- | ||
| *This issue was automatically created by the [AI Integration Testing framework](https://github.com/getsentry/testing-ai-sdk-integrations).* | ||
| `; | ||
|
|
||
| // Check for existing open issues with the label | ||
| const issues = await github.rest.issues.listForRepo({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| labels: issueLabel, | ||
| state: 'open' | ||
| }); | ||
|
Comment on lines
+112
to
+117
This comment was marked as outdated.
Sorry, something went wrong.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The action is intended to be used with a single language, should be fine. |
||
|
|
||
| if (issues.data.length > 0) { | ||
| // Update existing issue | ||
| await github.rest.issues.update({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: issues.data[0].number, | ||
| body: body | ||
| }); | ||
| console.log(`Updated existing issue #${issues.data[0].number}`); | ||
| } else { | ||
| // Create new issue | ||
| const newIssue = await github.rest.issues.create({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| title: `AI Integration Tests Failed (${language}) - ${today}`, | ||
| body: body, | ||
| labels: [issueLabel, 'automated'] | ||
| }); | ||
| console.log(`Created new issue #${newIssue.data.number}`); | ||
| } | ||
This comment was marked as outdated.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not correct.
The
cliscript inpackage.jsonhascd shared/orchestration && npm run cli --So when we run
npm run cli run jsit: