Skip to content
This repository was archived by the owner on Jan 28, 2026. It is now read-only.

Commit d374862

Browse files
authored
Merge pull request #122 from DigitalProductInnovationAndDevelopment/fixpublisherror
fixpublisherror test
2 parents 2858309 + 7a34a6d commit d374862

3 files changed

Lines changed: 232 additions & 59 deletions

File tree

action.yml

Lines changed: 123 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,27 @@ runs:
127127
echo "🚀 Setting up GUI-Based Testing Code Review environment..."
128128
mkdir -p artifacts
129129
echo "artifacts-path=artifacts" >> $GITHUB_OUTPUT
130+
131+
# Copy action scripts to workspace if using published action
132+
if [ -d "${{ github.action_path }}/scripts" ]; then
133+
echo "📂 Copying action scripts to workspace..."
134+
mkdir -p .gui-test-review-action/scripts
135+
cp -r "${{ github.action_path }}/scripts"/* .gui-test-review-action/scripts/
136+
137+
# Create a minimal package.json for action dependencies
138+
cat > .gui-test-review-action/package.json << 'EOF'
139+
{
140+
"name": "gui-test-review-action-deps",
141+
"version": "1.0.0",
142+
"private": true,
143+
"dependencies": {
144+
"@octokit/core": "^5.0.0",
145+
"marked": "15.0.12"
146+
}
147+
}
148+
EOF
149+
fi
150+
130151
echo "✅ Environment ready for visual GUI test analysis"
131152
132153
- name: Setup Node.js for GUI test tools
@@ -138,17 +159,31 @@ runs:
138159
shell: bash
139160
run: |
140161
echo "📦 Installing dependencies for GUI test analysis..."
162+
163+
# Install project dependencies if package.json exists
141164
if [ -f "package.json" ]; then
142165
npm install
143166
echo ""
144167
echo "--- Installed Top-Level Dependencies ---"
168+
145169
# List the installed packages. --depth=0 keeps the list clean.
146170
npm list --depth=0
147171
echo "----------------------------------------"
148172
echo "✅ Dependencies installed successfully"
173+
149174
else
150175
echo "⚠️ No package.json found, skipping npm install"
151176
fi
177+
178+
# Install action dependencies if we copied scripts
179+
if [ -d ".gui-test-review-action" ]; then
180+
echo "📦 Installing action dependencies..."
181+
cd .gui-test-review-action
182+
npm install --production
183+
cd ..
184+
fi
185+
186+
echo "✅ Dependencies installed successfully"
152187
153188
- name: Install Playwright browsers for GUI testing
154189
shell: bash
@@ -173,10 +208,19 @@ runs:
173208
REVIEWDOG_REPORTER: ${{ inputs.reviewdog-reporter }}
174209
run: |
175210
echo "🔍 Running code quality analysis for GUI tests..."
176-
if [ -f "${{ github.action_path }}/scripts/lint.js" ]; then
177-
node "${{ github.action_path }}/scripts/lint.js"
211+
212+
# Determine script location
213+
SCRIPT_PATH=""
214+
if [ -f ".gui-test-review-action/scripts/lint.js" ]; then
215+
SCRIPT_PATH=".gui-test-review-action/scripts/lint.js"
216+
elif [ -f "${{ github.action_path }}/scripts/lint.js" ]; then
217+
SCRIPT_PATH="${{ github.action_path }}/scripts/lint.js"
178218
elif [ -f "scripts/lint.js" ]; then
179-
node scripts/lint.js
219+
SCRIPT_PATH="scripts/lint.js"
220+
fi
221+
222+
if [ -n "$SCRIPT_PATH" ]; then
223+
node "$SCRIPT_PATH"
180224
else
181225
echo "⚠️ Lint script not found, skipping code quality analysis"
182226
fi
@@ -191,10 +235,19 @@ runs:
191235
TEST_FILES: ${{ inputs.test-files }}
192236
run: |
193237
echo "🧪 Executing GUI tests on PR branch..."
194-
if [ -f "${{ github.action_path }}/scripts/playwright-test.js" ]; then
195-
node "${{ github.action_path }}/scripts/playwright-test.js"
238+
239+
# Determine script location
240+
SCRIPT_PATH=""
241+
if [ -f ".gui-test-review-action/scripts/playwright-test.js" ]; then
242+
SCRIPT_PATH=".gui-test-review-action/scripts/playwright-test.js"
243+
elif [ -f "${{ github.action_path }}/scripts/playwright-test.js" ]; then
244+
SCRIPT_PATH="${{ github.action_path }}/scripts/playwright-test.js"
196245
elif [ -f "scripts/playwright-test.js" ]; then
197-
node scripts/playwright-test.js
246+
SCRIPT_PATH="scripts/playwright-test.js"
247+
fi
248+
249+
if [ -n "$SCRIPT_PATH" ]; then
250+
node "$SCRIPT_PATH"
198251
else
199252
echo "🎭 Running Playwright tests directly..."
200253
npx playwright test ${{ inputs.test-files }}
@@ -247,10 +300,18 @@ runs:
247300
echo "✅ Main branch test files checked out successfully"
248301
echo "🧪 Running GUI tests on main branch version..."
249302
250-
if [ -f "${{ github.action_path }}/scripts/playwright-test.js" ]; then
251-
node "${{ github.action_path }}/scripts/playwright-test.js"
303+
# Determine script location
304+
SCRIPT_PATH=""
305+
if [ -f ".gui-test-review-action/scripts/playwright-test.js" ]; then
306+
SCRIPT_PATH=".gui-test-review-action/scripts/playwright-test.js"
307+
elif [ -f "${{ github.action_path }}/scripts/playwright-test.js" ]; then
308+
SCRIPT_PATH="${{ github.action_path }}/scripts/playwright-test.js"
252309
elif [ -f "scripts/playwright-test.js" ]; then
253-
node scripts/playwright-test.js
310+
SCRIPT_PATH="scripts/playwright-test.js"
311+
fi
312+
313+
if [ -n "$SCRIPT_PATH" ]; then
314+
node "$SCRIPT_PATH"
254315
else
255316
npx playwright test ${{ inputs.test-files }}
256317
fi
@@ -295,10 +356,19 @@ runs:
295356
shell: bash
296357
run: |
297358
echo "📊 Generating visual flowchart of GUI test execution..."
298-
if [ -f "${{ github.action_path }}/scripts/generate-flowchart.js" ]; then
299-
node "${{ github.action_path }}/scripts/generate-flowchart.js"
359+
360+
# Determine script location
361+
SCRIPT_PATH=""
362+
if [ -f ".gui-test-review-action/scripts/generate-flowchart.js" ]; then
363+
SCRIPT_PATH=".gui-test-review-action/scripts/generate-flowchart.js"
364+
elif [ -f "${{ github.action_path }}/scripts/generate-flowchart.js" ]; then
365+
SCRIPT_PATH="${{ github.action_path }}/scripts/generate-flowchart.js"
300366
elif [ -f "scripts/generate-flowchart.js" ]; then
301-
node scripts/generate-flowchart.js
367+
SCRIPT_PATH="scripts/generate-flowchart.js"
368+
fi
369+
370+
if [ -n "$SCRIPT_PATH" ]; then
371+
node "$SCRIPT_PATH"
302372
else
303373
echo "⚠️ Flowchart script not found, skipping visualization"
304374
fi
@@ -310,10 +380,19 @@ runs:
310380
shell: bash
311381
run: |
312382
echo "📋 Building comprehensive review checklist..."
313-
if [ -f "${{ github.action_path }}/scripts/checklist.js" ]; then
314-
node "${{ github.action_path }}/scripts/checklist.js"
383+
384+
# Determine script location
385+
SCRIPT_PATH=""
386+
if [ -f ".gui-test-review-action/scripts/checklist.js" ]; then
387+
SCRIPT_PATH=".gui-test-review-action/scripts/checklist.js"
388+
elif [ -f "${{ github.action_path }}/scripts/checklist.js" ]; then
389+
SCRIPT_PATH="${{ github.action_path }}/scripts/checklist.js"
315390
elif [ -f "scripts/checklist.js" ]; then
316-
node scripts/checklist.js
391+
SCRIPT_PATH="scripts/checklist.js"
392+
fi
393+
394+
if [ -n "$SCRIPT_PATH" ]; then
395+
node "$SCRIPT_PATH"
317396
else
318397
echo "⚠️ Checklist script not found, skipping checklist generation"
319398
fi
@@ -332,10 +411,21 @@ runs:
332411
shell: bash
333412
run: |
334413
echo "🎨 Building interactive visual dashboard..."
335-
if [ -f "${{ github.action_path }}/scripts/generate-webpage.js" ]; then
336-
node "${{ github.action_path }}/scripts/generate-webpage.js"
414+
415+
# Determine script location and set NODE_PATH if needed
416+
SCRIPT_PATH=""
417+
NODE_PATH_PREFIX=""
418+
if [ -f ".gui-test-review-action/scripts/generate-webpage.js" ]; then
419+
SCRIPT_PATH=".gui-test-review-action/scripts/generate-webpage.js"
420+
NODE_PATH_PREFIX="NODE_PATH=.gui-test-review-action/node_modules:$NODE_PATH"
421+
elif [ -f "${{ github.action_path }}/scripts/generate-webpage.js" ]; then
422+
SCRIPT_PATH="${{ github.action_path }}/scripts/generate-webpage.js"
337423
elif [ -f "scripts/generate-webpage.js" ]; then
338-
node scripts/generate-webpage.js
424+
SCRIPT_PATH="scripts/generate-webpage.js"
425+
fi
426+
427+
if [ -n "$SCRIPT_PATH" ]; then
428+
eval "$NODE_PATH_PREFIX node \"$SCRIPT_PATH\""
339429
else
340430
echo "⚠️ Dashboard script not found, skipping dashboard generation"
341431
fi
@@ -450,10 +540,21 @@ runs:
450540
WEB_REPORT_URL: ${{ inputs.web-report-url || steps.deploy-report.outputs.page_url || format('https://{0}.github.io/{1}/', github.repository_owner, github.event.repository.name) }}
451541
run: |
452542
echo "💬 Posting comprehensive visual feedback to PR..."
453-
if [ -f "${{ github.action_path }}/scripts/summary-comment.js" ]; then
454-
node "${{ github.action_path }}/scripts/summary-comment.js"
543+
544+
# Determine script location and set NODE_PATH if needed
545+
SCRIPT_PATH=""
546+
NODE_PATH_PREFIX=""
547+
if [ -f ".gui-test-review-action/scripts/summary-comment.js" ]; then
548+
SCRIPT_PATH=".gui-test-review-action/scripts/summary-comment.js"
549+
NODE_PATH_PREFIX="NODE_PATH=.gui-test-review-action/node_modules:$NODE_PATH"
550+
elif [ -f "${{ github.action_path }}/scripts/summary-comment.js" ]; then
551+
SCRIPT_PATH="${{ github.action_path }}/scripts/summary-comment.js"
455552
elif [ -f "scripts/summary-comment.js" ]; then
456-
node scripts/summary-comment.js
553+
SCRIPT_PATH="scripts/summary-comment.js"
554+
fi
555+
556+
if [ -n "$SCRIPT_PATH" ]; then
557+
eval "$NODE_PATH_PREFIX node \"$SCRIPT_PATH\""
457558
else
458559
echo "⚠️ Summary comment script not found, skipping PR comment"
459560
fi
@@ -499,4 +600,4 @@ runs:
499600
echo "📈 Summary:"
500601
cat artifacts/test-summary.txt
501602
fi
502-
echo "════════════════════════════════════════════════════════"
603+
echo "════════════════════════════════════════════════════════"

scripts/generate-webpage.js

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,27 @@
1212

1313
const fs = require('fs');
1414
const path = require('path');
15-
const marked = require('marked');
15+
16+
// Dynamic require for marked module
17+
let marked;
18+
try {
19+
// Try local node_modules first
20+
marked = require('marked');
21+
} catch (e1) {
22+
try {
23+
// Try action's node_modules
24+
marked = require(path.join(process.cwd(), '.gui-test-review-action/node_modules/marked'));
25+
} catch (e2) {
26+
try {
27+
// Try parent directory
28+
marked = require(path.join(__dirname, '../node_modules/marked'));
29+
} catch (e3) {
30+
console.error('Could not load marked module. Please ensure marked is installed.');
31+
console.error('You can install it with: npm install marked@15.0.12');
32+
process.exit(1);
33+
}
34+
}
35+
}
1636

1737
/* ─── paths ───────────────────────────────────────────── */
1838
const ART = 'artifacts';
@@ -29,35 +49,51 @@ const pre = txt=>`<pre>${txt}</pre>`;
2949

3050
/* ─── load artefacts ─────────────────────────────────── */
3151
const lint = readJSON('lint-summary.json');
32-
const p = lint.prettier;
33-
const e = lint.eslint;
52+
const p = lint.prettier || {};
53+
const e = lint.eslint || {};
3454

3555
const playPR = readJSON('playwright-summary-pr.json');
3656
const playMain = readJSON('playwright-summary-main.json');
3757
const hasMainPlay = fs.existsSync(path.join(ART,'playwright-summary-main.json'));
3858

39-
const checklistMD = fs.readFileSync(path.join(ART,'checklist.md'),'utf8');
59+
let checklistMD = '';
60+
try {
61+
checklistMD = fs.readFileSync(path.join(ART,'checklist.md'),'utf8');
62+
} catch (e) {
63+
console.warn('Checklist not found, continuing without it');
64+
}
4065

4166
/* ─── copy assets ────────────────────────────────────── */
4267
for(const dir of ['pr-report','main-report']){
4368
const src=path.join(ART,dir);
44-
if(fs.existsSync(src)) fs.cpSync(src,path.join(OUT,dir),{recursive:true});
69+
if(fs.existsSync(src)) {
70+
try {
71+
fs.cpSync(src,path.join(OUT,dir),{recursive:true});
72+
} catch (e) {
73+
console.warn(`Could not copy ${dir}:`, e.message);
74+
}
75+
}
76+
}
77+
if(fs.existsSync(path.join(ART,'flowchart.png'))) {
78+
try {
79+
fs.copyFileSync(path.join(ART,'flowchart.png'),path.join(OUT,'flowchart.png'));
80+
} catch (e) {
81+
console.warn('Could not copy flowchart:', e.message);
82+
}
4583
}
46-
if(fs.existsSync(path.join(ART,'flowchart.png')))
47-
fs.copyFileSync(path.join(ART,'flowchart.png'),path.join(OUT,'flowchart.png'));
4884

4985
/* ─── Prettier & ESLint cards (unchanged) ───────────── */
5086
const prettierCard = card(
5187
'Prettier',
5288
p.filesWithIssues
5389
? pill(`${p.filesWithIssues} file${p.filesWithIssues!==1?'s':''}`,'#d32f2f')+
5490
pill(`${p.totalChanges} place${p.totalChanges!==1?'s':''}`,'#f57f17')+
55-
`<ul>${p.files.map(f=>`<li>${f}</li>`).join('')}</ul>`+
91+
`<ul>${(p.files||[]).map(f=>`<li>${f}</li>`).join('')}</ul>`+
5692
(p.totalChanges>50?`<div class="warning-box">
5793
<strong>⚠️ Warning:</strong> Too many changes for inline comments.<br>
5894
<pre style="margin-top:.5em;font-size:12px">npx prettier "tests/**/*.{js,jsx,ts,tsx}" --write</pre>
5995
</div>`:'')+
60-
`<details><summary>Diff sample (first 20 lines)</summary>${pre(p.sample)}</details>`
96+
`<details><summary>Diff sample (first 20 lines)</summary>${pre(p.sample||'')}</details>`
6197
: pill('No issues','#388e3c')
6298
);
6399

@@ -76,8 +112,8 @@ const eslintCard = card(
76112
const mdPlaywright = `
77113
| Run | Total | Passed | Failed | Skipped | Pass-rate | Duration |
78114
|-----|------:|-------:|-------:|--------:|-----------|---------:|
79-
| **PR** | ${playPR.total??0} | ${playPR.passed??0} | ${playPR.failed??0} | ${playPR.skipped??0} | ${playPR.pass_rate??0}% | ${playPR.duration??0}ms |
80-
${hasMainPlay?`| **Main** | ${playMain.total??0} | ${playMain.passed??0} | ${playMain.failed??0} | ${playMain.skipped??0} | ${playMain.pass_rate??0}% | ${playMain.duration??0}ms |`:''}`;
115+
| **PR** | ${playPR.total??0} | ${playPR.passed??0} | ${playPR.failed??0} | ${playPR.skipped??0} | ${playPR.pass_rate??0}% | ${playPR.duration??0} ms |
116+
${hasMainPlay?`| **Main** | ${playMain.total??0} | ${playMain.passed??0} | ${playMain.failed??0} | ${playMain.skipped??0} | ${playMain.pass_rate??0}% | ${playMain.duration??0} ms |`:''}`;
81117

82118
const linkParts=[];
83119
if(fs.existsSync(path.join(OUT,'pr-report/index.html')))
@@ -97,7 +133,7 @@ const playCard = card(
97133
const flowCard = fs.existsSync(path.join(OUT,'flowchart.png'))
98134
? card('Flow-chart',`<a href="flowchart.png"><img src="flowchart.png" style="max-width:100%"></a>`)
99135
: '';
100-
const checklistCard = card('Checklist', marked.parse(checklistMD));
136+
const checklistCard = checklistMD ? card('Checklist', marked.parse(checklistMD)) : '';
101137

102138
/* ─── HTML shell ─────────────────────────────────────── */
103139
const html = /*html*/`
@@ -131,5 +167,4 @@ ${checklistCard}
131167

132168
/* ─── write page ─────────────────────────────────────── */
133169
fs.writeFileSync(path.join(OUT,'index.html'),html,'utf8');
134-
console.log('✨ Dashboard written → web-report/index.html');
135-
170+
console.log('✨ Dashboard written → web-report/index.html');

0 commit comments

Comments
 (0)