Skip to content

Commit 079beb3

Browse files
authored
feat(action)!: Add language scoped setups (#12)
Updates the action `language` to be optional. If none is passed, both js and py tests are set up and run, otherwise only the specific language.
1 parent 1d2f7e5 commit 079beb3

4 files changed

Lines changed: 43 additions & 13 deletions

File tree

action.yml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ branding:
88

99
inputs:
1010
language:
11-
description: "SDK language to test. One of: js, python"
12-
required: true
11+
description: "SDK language to test. One of: js, py, or leave empty for both"
12+
required: false
13+
default: ""
1314
openai-api-key:
1415
description: "OpenAI API key"
1516
required: true
@@ -34,6 +35,7 @@ runs:
3435
node-version: "20"
3536

3637
- name: Setup Python
38+
if: inputs.language == 'py' || inputs.language == ''
3739
uses: actions/setup-python@v5
3840
with:
3941
python-version: "3.13"
@@ -46,7 +48,12 @@ runs:
4648
- name: Setup SDK dependencies
4749
shell: bash
4850
working-directory: ${{ github.action_path }}
49-
run: npm run cli setup
51+
run: |
52+
if [ -z "${{ inputs.language }}" ]; then
53+
npm run cli setup
54+
else
55+
npm run cli setup ${{ inputs.language }}
56+
fi
5057
5158
- name: Run tests
5259
id: run-tests
@@ -58,7 +65,11 @@ runs:
5865
GOOGLE_API_KEY: ${{ inputs.google-api-key }}
5966
run: |
6067
set +e
61-
npm run cli run ${{ inputs.language }} --reports ctrf
68+
if [ -z "${{ inputs.language }}" ]; then
69+
npm run cli run -- --all --reports ctrf
70+
else
71+
npm run cli run ${{ inputs.language }} -- --reports ctrf
72+
fi
6273
EXIT_CODE=$?
6374
set -e
6475
@@ -77,7 +88,8 @@ runs:
7788
script: |
7889
const fs = require('fs');
7990
const path = require('path');
80-
const language = '${{ inputs.language }}';
91+
const language = '${{ inputs.language }}' || 'all';
92+
const languageDisplay = language === 'all' ? 'js & py' : language;
8193
const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
8294
8395
// Try to read test results from CTRF report
@@ -98,7 +110,7 @@ runs:
98110
99111
const body = `## AI Integration Test Failure
100112
101-
**Language**: ${language}
113+
**Language**: ${languageDisplay}
102114
**Date**: ${new Date().toISOString()}
103115
**Workflow Run**: ${runUrl}
104116
@@ -130,7 +142,7 @@ runs:
130142
const newIssue = await github.rest.issues.create({
131143
owner: context.repo.owner,
132144
repo: context.repo.repo,
133-
title: `AI Integration Tests Failed (${language}) - ${today}`,
145+
title: `AI Integration Tests Failed (${languageDisplay}) - ${today}`,
134146
body: body,
135147
labels: [issueLabel, 'automated']
136148
});

shared/orchestration/src/cli.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,23 @@ program
221221
* Setup command - Install all dependencies
222222
*/
223223
program
224-
.command("setup")
225-
.description("Install all dependencies across the repository")
224+
.command("setup [language]")
225+
.description("Install all dependencies across the repository (optionally filter by 'js' or 'py')")
226226
.option("--local-sentry-python <path>", "Use local Sentry Python SDK (sentry-python)")
227227
.option("--local-sentry-javascript <path>", "Use local Sentry JavaScript SDK (sentry-javascript)")
228-
.action(async (options) => {
228+
.action(async (language, options) => {
229+
// Validate language argument if provided
230+
if (language && language !== 'js' && language !== 'py') {
231+
console.log(chalk.red(`Error: Invalid language "${language}". Must be "js" or "py".`));
232+
console.log(chalk.gray('Examples:'));
233+
console.log(chalk.gray(' npm run cli setup (all SDKs)'));
234+
console.log(chalk.gray(' npm run cli setup js (JS only)'));
235+
console.log(chalk.gray(' npm run cli setup py (Python only)'));
236+
process.exit(1);
237+
}
238+
229239
await setup({
240+
language: language as 'js' | 'py' | undefined,
230241
localSentryPythonPath: options.localSentryPython,
231242
localSentryJavaScriptPath: options.localSentryJavascript
232243
});

shared/orchestration/src/setup.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,13 @@ async function setupPythonSDK(sdkPath: string, absolutePath: string, options?: L
348348
return results;
349349
}
350350

351+
/**
352+
* Check if we should setup SDKs for a given language
353+
*/
354+
function shouldSetupLanguage(language: 'js' | 'py', options?: SetupOptions): boolean {
355+
return !options?.language || options.language === language;
356+
}
357+
351358
/**
352359
* Main setup function
353360
*/
@@ -368,7 +375,7 @@ export async function setup(options?: SetupOptions): Promise<void> {
368375
const pySDKs = sdks.filter(sdk => sdk.language === 'py');
369376

370377
// Setup JavaScript SDKs
371-
if (jsSDKs.length > 0) {
378+
if (shouldSetupLanguage('js', options) && jsSDKs.length > 0) {
372379
console.log(chalk.bold('JavaScript SDKs'));
373380
for (const sdk of jsSDKs) {
374381
const result = await setupJavaScriptSDK(sdk.path, sdk.absolutePath, options);
@@ -378,7 +385,7 @@ export async function setup(options?: SetupOptions): Promise<void> {
378385
}
379386

380387
// Setup Python SDKs
381-
if (pySDKs.length > 0) {
388+
if (shouldSetupLanguage('py', options) && pySDKs.length > 0) {
382389
console.log(chalk.bold('Python SDKs'));
383390
for (const sdk of pySDKs) {
384391
const results = await setupPythonSDK(sdk.path, sdk.absolutePath, options);

shared/orchestration/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export interface LocalSentryOptions {
4646
}
4747

4848
export interface SetupOptions extends LocalSentryOptions {
49-
// Future: add other setup-specific options here
49+
language?: 'js' | 'py'; // Filter by language (e.g., "js" or "py")
5050
}
5151

5252
export interface RunOptions extends LocalSentryOptions {

0 commit comments

Comments
 (0)