Skip to content

heheh

heheh #17

name: PR Comment - Run Enhanced Flow
on:
issue_comment:
types: [created]
permissions:
contents: write
pull-requests: write
concurrency:
group: pr-comment-enhanced-flow-${{ github.event.issue.number || github.run_id }}
cancel-in-progress: false
jobs:
run-enhanced-flow:
if: >
${{ github.event.issue.pull_request != null && contains(github.event.comment.body, 'node test-enhanced-flow.js') }}
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- name: Checkout PR head
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: refs/pull/${{ github.event.issue.number }}/head
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
- name: Enable Corepack (Yarn)
run: corepack enable
- name: Remove npm lockfiles to avoid Yarn conflicts
shell: bash
run: |
rm -f package-lock.json || true
rm -f AutoSnap/package-lock.json || true
rm -f AutoSnap/tracewrightt/package-lock.json || true
- name: Install root dependencies (optional)
shell: bash
run: |
if [ -f yarn.lock ]; then
yarn install --frozen-lockfile || yarn install
else
echo 'No root yarn.lock, skipping'
fi
- name: Install AutoSnap dependencies
working-directory: AutoSnap
shell: bash
run: |
yarn install --frozen-lockfile || yarn install
- name: Install tracewrightt and build
working-directory: AutoSnap/tracewrightt
shell: bash
run: |
echo "🔧 Installing tracewrightt dependencies..."
yarn install --frozen-lockfile || yarn install
echo "🏗️ Building tracewrightt..."
yarn build || echo "⚠️ tracewrightt build failed, will fallback to ts-node at runtime"
- name: Install Playwright Chromium and system deps
working-directory: AutoSnap
shell: bash
run: |
npx playwright install --with-deps chromium
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Python requirements
working-directory: AutoSnap
shell: bash
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt || echo "Python requirements install failed, script has fallbacks"
- name: Create CI clone of test-enhanced-flow.js and patch paths
working-directory: AutoSnap
shell: bash
run: |
cp test-enhanced-flow.js test-enhanced-flow-ci.js
# Patch hardcoded Windows fallback path(s) to repo-relative path for CI
sed -i "s#C:/Users/Rohith\.MR/test/HelpManualAutomationTest/docs/1-Getting-Started/addorg\.md#docs/1-Getting-Started/addorg.md#g" test-enhanced-flow-ci.js
# Ensure CI runs headless Chromium and not Chrome channel
sed -i "s/headless: false/headless: true/g" test-enhanced-flow-ci.js
sed -i "/channel: 'chrome',/d" test-enhanced-flow-ci.js
- name: Ensure Azure env defaults
shell: bash
run: |
: "${AZURE_OPENAI_API_KEY:=placeholder}"
: "${AZURE_OPENAI_ENDPOINT:=https://example.invalid/}"
echo "AZURE_OPENAI_API_KEY=$AZURE_OPENAI_API_KEY" >> $GITHUB_ENV
echo "AZURE_OPENAI_ENDPOINT=$AZURE_OPENAI_ENDPOINT" >> $GITHUB_ENV
- name: Extract command args from comment
id: parse
uses: actions/github-script@v7
with:
script: |
const body = context.payload.comment.body || '';
const re = /node\s+test-enhanced-flow\.js(?:\s+([\s\S]*))?/i; // capture everything after the command on the first line
const m = body.match(re);
const args = m && m[1] ? m[1].trim() : '';
core.setOutput('args', args);
- name: Run enhanced flow
shell: bash
env:
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT }}
LLM_PROVIDER: gemini
DISABLE_IMG_AS: "true"
run: |
args="${{ steps.parse.outputs.args }}"
if [ -n "$args" ]; then
echo "Running: node AutoSnap/test-enhanced-flow-ci.js $args"
node AutoSnap/test-enhanced-flow-ci.js $args 2>&1 | tee enhanced-flow-ci-run.log
else
echo "No args provided in comment. Running default: node AutoSnap/test-enhanced-flow-ci.js"
node AutoSnap/test-enhanced-flow-ci.js 2>&1 | tee enhanced-flow-ci-run.log
fi
- name: Upload logs and outputs
uses: actions/upload-artifact@v4
if: always()
with:
name: enhanced-flow-artifacts
path: |
enhanced-flow-ci-run.log
enhanced-flow-log.txt
changed-files-*.txt
changed-files-screenshots.txt
token_usage_summary.txt
AutoSnap/enhanced-flow-log.txt
AutoSnap/token_usage_summary.txt
AutoSnap/changed-files-*.txt
AutoSnap/api_logs/
AutoSnap/screenshots/
docs/**/img_as/**
spanish/**/img_as/**
docs/**/img/**
spanish/**/img/**
if-no-files-found: ignore
- name: Get PR head info
id: pr_info
uses: actions/github-script@v7
with:
script: |
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
});
core.setOutput('head_ref', pr.data.head.ref);
core.setOutput('head_repo', pr.data.head.repo.full_name);
const canPush = pr.data.head.repo.full_name === `${context.repo.owner}/${context.repo.repo}`;
core.setOutput('can_push', canPush ? 'true' : 'false');
- name: Commit screenshots and markdown to PR branch
if: ${{ steps.pr_info.outputs.can_push == 'true' }}
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HEAD_REPO: ${{ steps.pr_info.outputs.head_repo }}
HEAD_REF: ${{ steps.pr_info.outputs.head_ref }}
run: |
set -e
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Simple approach: add all changes including new and modified files
echo "Adding all changes..."
git add -A
# Show what will be committed
echo "Files to be committed:"
git status --short
# Check if there are changes to commit
if git diff --staged --quiet; then
echo "No changes to commit."
exit 0
fi
# Commit and push
git commit -m "chore(ci): add screenshots and update markdown from enhanced flow run [skip ci]"
git push "https://x-access-token:${GITHUB_TOKEN}@github.com/${HEAD_REPO}.git" HEAD:${HEAD_REF}
- name: Reply on PR with run summary
if: always()
uses: actions/github-script@v7
with:
script: |
const args = `${{ steps.parse.outputs.args }}` || '(none)';
const runUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
const body = [
`▶️ Ran: node test-enhanced-flow.js ${args}`.trim(),
`• Status: ${process.env.STATE || 'completed (see job result above)'}`,
`• Logs & outputs uploaded as artifact: enhanced-flow-artifacts`,
`• Workflow run: ${runUrl}`
].join('\n');
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body
});