Skip to content

Commit a5aea91

Browse files
committed
haha
1 parent eeff804 commit a5aea91

File tree

5 files changed

+145
-5
lines changed

5 files changed

+145
-5
lines changed

.github/workflows/comment-run-enhanced-flow.yml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ concurrency:
1515
jobs:
1616
run-enhanced-flow:
1717
if: >
18-
${{ github.event.issue.pull_request != null && contains(github.event.comment.body, 'node test-enhanced-flow.js') }}
18+
${{ github.event.issue.pull_request != null && (contains(github.event.comment.body, 'node test-enhanced-flow.js') || contains(github.event.comment.body, '/run-enhanced-flow')) }}
1919
runs-on: ubuntu-latest
2020
timeout-minutes: 120
2121
steps:
@@ -107,9 +107,29 @@ jobs:
107107
with:
108108
script: |
109109
const body = context.payload.comment.body || '';
110-
const re = /node\s+test-enhanced-flow\.js(?:\s+([\s\S]*))?/i; // capture everything after the command on the first line
111-
const m = body.match(re);
112-
const args = m && m[1] ? m[1].trim() : '';
110+
// Handle both formats: node test-enhanced-flow.js and /run-enhanced-flow
111+
const reNode = /node\s+test-enhanced-flow\.js(?:\s+([\s\S]*))?/i; // capture everything after the command on the first line
112+
const reRun = /\/run-enhanced-flow(?:\s+([\s\S]*))?/i; // capture everything after the command on the first line
113+
114+
let args = '';
115+
116+
// Try to match node test-enhanced-flow.js format
117+
let m = body.match(reNode);
118+
if (m && m[1]) {
119+
args = m[1].trim();
120+
} else {
121+
// Try to match /run-enhanced-flow format
122+
m = body.match(reRun);
123+
if (m && m[1]) {
124+
args = m[1].trim();
125+
}
126+
}
127+
128+
// Handle --scenario parameter by converting it to --mode
129+
if (args.includes('--scenario')) {
130+
args = args.replace(/--scenario\s+(\S+)/g, '--mode $1');
131+
}
132+
113133
core.setOutput('args', args);
114134
115135
- name: Run enhanced flow

AutoSnap/test-enhanced-flow-ci.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1288,6 +1288,7 @@ const args = process.argv.slice(2);
12881288
let changedFiles = null;
12891289
let modeArg = null;
12901290
let folderPath = null;
1291+
let scenarioArg = null;
12911292
let singleFilePath = null;
12921293
let listFilePath = null;
12931294
let languageCodeArg = null;
@@ -1318,9 +1319,18 @@ for (let i = 0; i < args.length; i++) {
13181319
} else if ((args[i] === '--lang' || args[i] === '-l') && args[i + 1]) {
13191320
languageCodeArg = args[i + 1];
13201321
i++;
1322+
} else if (args[i] === '--scenario' && args[i + 1]) {
1323+
scenarioArg = args[i + 1];
1324+
i++;
13211325
}
13221326
}
13231327

1328+
// If scenario is specified but mode is not, use scenario as mode
1329+
if (scenarioArg && !modeArg) {
1330+
console.log(`🔄 Using scenario '${scenarioArg}' as mode`);
1331+
modeArg = scenarioArg;
1332+
}
1333+
13241334
// Validate exclusive options
13251335
const exclusiveOptions = [folderPath, singleFilePath, changedFiles, listFilePath].filter(Boolean);
13261336
if (exclusiveOptions.length > 1) {
@@ -1329,6 +1339,9 @@ if (exclusiveOptions.length > 1) {
13291339
process.exit(1);
13301340
}
13311341

1342+
// Detect if running in GitHub Actions or CI environment
1343+
const isCI = process.env.CI === 'true' || process.env.GITHUB_ACTIONS === 'true' || true; // Force CI mode to avoid interactive prompts
1344+
13321345
// Determine execution mode and process files accordingly
13331346
let executionMode = 'default';
13341347
let filesToProcess = [];
@@ -1357,7 +1370,7 @@ if (singleFilePath) {
13571370
console.log(`🔍 Classifying file: ${singleFilePath}`);
13581371
let mode;
13591372

1360-
if (modeArg && ['new_feature', 'ui_change', 'default'].includes(modeArg)) {
1373+
if (modeArg && ['new_feature', 'ui_change', 'default'].includes(modeArg.toLowerCase())) {
13611374
// Force specific mode if provided
13621375
mode = modeArg;
13631376
console.log(`🎯 Forced mode: ${mode.toUpperCase()}`);

apply-patch.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
# Apply the patch to fix interactive prompts in GitHub Actions
3+
4+
echo "Applying patch to fix interactive prompts in GitHub Actions..."
5+
git apply fix-interactive-prompt.patch
6+
7+
if [ $? -eq 0 ]; then
8+
echo "Patch applied successfully!"
9+
else
10+
echo "Failed to apply patch. Please check the patch file and try again."
11+
exit 1
12+
fi
13+
14+
echo "Done!"

existing-changes.diff

Whitespace-only changes.

fix-interactive-prompt.patch

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
diff --git a/AutoSnap/test-enhanced-flow-ci.js b/AutoSnap/test-enhanced-flow-ci.js
2+
index 123456..789012 100644
3+
--- a/AutoSnap/test-enhanced-flow-ci.js
4+
+++ b/AutoSnap/test-enhanced-flow-ci.js
5+
@@ -1290,6 +1290,7 @@ const args = process.argv.slice(2);
6+
let changedFiles = null;
7+
let modeArg = null;
8+
let folderPath = null;
9+
+let scenarioArg = null;
10+
let singleFilePath = null;
11+
let listFilePath = null;
12+
let languageCodeArg = null;
13+
@@ -1306,6 +1307,9 @@ for (let i = 0; i < args.length; i++) {
14+
} else if ((args[i] === '--mode' || args[i] === '-m') && args[i + 1]) {
15+
modeArg = args[i + 1];
16+
i++;
17+
+ } else if (args[i] === '--scenario' && args[i + 1]) {
18+
+ scenarioArg = args[i + 1];
19+
+ i++;
20+
} else if (args[i] === '--folder' && args[i + 1]) {
21+
folderPath = args[i + 1];
22+
i++;
23+
@@ -1321,6 +1325,12 @@ for (let i = 0; i < args.length; i++) {
24+
}
25+
}
26+
27+
+// If scenario is specified but mode is not, use scenario as mode
28+
+if (scenarioArg && !modeArg) {
29+
+ console.log(`🔄 Using scenario '${scenarioArg}' as mode`);
30+
+ modeArg = scenarioArg;
31+
+}
32+
+
33+
// Validate exclusive options
34+
const exclusiveOptions = [folderPath, singleFilePath, changedFiles, listFilePath].filter(Boolean);
35+
if (exclusiveOptions.length > 1) {
36+
@@ -1329,6 +1339,9 @@ if (exclusiveOptions.length > 1) {
37+
process.exit(1);
38+
}
39+
40+
+// Detect if running in GitHub Actions or CI environment
41+
+const isCI = process.env.CI === 'true' || process.env.GITHUB_ACTIONS === 'true';
42+
+
43+
// Determine execution mode and process files accordingly
44+
let executionMode = 'default';
45+
let filesToProcess = [];
46+
@@ -1357,7 +1370,7 @@ if (singleFilePath) {
47+
console.log(`🔍 Classifying file: ${singleFilePath}`);
48+
let mode;
49+
50+
- if (modeArg && ['new_feature', 'ui_change', 'default'].includes(modeArg)) {
51+
+ if (modeArg && ['new_feature', 'ui_change', 'default'].includes(modeArg.toLowerCase())) {
52+
// Force specific mode if provided
53+
mode = modeArg;
54+
console.log(`🎯 Forced mode: ${mode.toUpperCase()}`);
55+
@@ -1677,7 +1690,7 @@ const processNewFeature = async (filePath) => {
56+
// Determine if a specific mode was specified on the command line
57+
const modeIndex = args.findIndex(arg => arg === '--mode' || arg === '-m');
58+
if (modeIndex !== -1 && args[modeIndex + 1]) {
59+
- const mode = args[modeIndex + 1];
60+
+ const mode = args[modeIndex + 1].toLowerCase();
61+
if (['new_feature', 'ui_change', 'default'].includes(mode)) {
62+
console.log(`🎯 Using command-line specified mode: ${mode.toUpperCase()}`);
63+
return mode;
64+
@@ -1685,6 +1698,16 @@ const processNewFeature = async (filePath) => {
65+
console.warn(`⚠️ Invalid mode specified: ${mode}, will determine automatically`);
66+
}
67+
68+
+ // Check if scenario was specified
69+
+ const scenarioIndex = args.findIndex(arg => arg === '--scenario');
70+
+ if (scenarioIndex !== -1 && args[scenarioIndex + 1]) {
71+
+ const scenario = args[scenarioIndex + 1].toLowerCase();
72+
+ if (['new_feature', 'ui_change', 'default'].includes(scenario)) {
73+
+ console.log(`🎯 Using command-line specified scenario as mode: ${scenario.toUpperCase()}`);
74+
+ return scenario;
75+
+ }
76+
+ }
77+
+
78+
// If in CI environment, default to new_feature mode for single files
79+
if (isCI) {
80+
console.log(`🤖 CI environment detected, defaulting to NEW_FEATURE mode for single file`);
81+
@@ -1693,6 +1716,12 @@ const processNewFeature = async (filePath) => {
82+
83+
// Interactive mode selection for single file
84+
console.log(`\nAvailable modes for single file:`);
85+
+
86+
+ // If running in CI environment, default to new_feature without prompting
87+
+ if (isCI) {
88+
+ console.log(`🤖 CI environment detected, using NEW_FEATURE mode without prompting`);
89+
+ return 'new_feature';
90+
+ }
91+
92+
const readline = await import('node:readline');
93+
const rl = readline.createInterface({

0 commit comments

Comments
 (0)