Skip to content

feat: refactor and cleanup#479

Closed
nk1408 wants to merge 1 commit into
mainfrom
refactor_squashed
Closed

feat: refactor and cleanup#479
nk1408 wants to merge 1 commit into
mainfrom
refactor_squashed

Conversation

@nk1408

@nk1408 nk1408 commented Dec 2, 2025

Copy link
Copy Markdown
Collaborator

Pull Request

Description

Related Issues

Changes Made

Screenshots (if applicable)

Checklist

  • I have read the Contributor Guidelines.
  • I have performed a self-review of my own code and ensured it follows the project's coding standards.
  • I have tested the changes locally following ManualTestingProcess.md, and all tests related to this pull request pass.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation, if applicable.
  • I have added appropriate unit tests, if applicable.

Additional Notes

Comment on lines +11 to +99
name: Run Playwright Tests
runs-on: ubuntu-latest
timeout-minutes: 60

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Install dependencies
run: npm ci

- name: Install Playwright browsers
run: npm run e2e:install

- name: Run Playwright tests
run: npm run e2e
env:
CI: true

- name: Create or update test report issue
if: always()
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const { repo, owner } = context.repo;
const run_id = context.runId;
const run_url = `https://github.com/${owner}/${repo}/actions/runs/${run_id}`;

// Generate report content
const reportContent = [
'## Test Execution Report',
`Date: ${new Date().toISOString()}`,
`Repository: ${context.repo.owner}/${context.repo.repo}`,
`Branch: ${context.ref}`,
`Commit: ${context.sha}`,
'',
'### Test Results',
'```',
fs.readFileSync('playwright-report/test-results.txt', 'utf8'),
'```',
'',
`[View Workflow Run](${run_url})`
].join('\n');

// Determine issue title and labels based on test status
const isFailure = process.env.TEST_STATUS === 'failure';
const title = isFailure
? `test: Some e2e tests failed - ${new Date().toISOString()}`
: `Test Report - ${new Date().toISOString()}`;
const labels = isFailure ? ['test-failure'] : ['test-report'];

// Search for existing issue
const issues = await github.rest.issues.listForRepo({
owner,
repo,
labels,
state: 'open'
});

const existingIssue = issues.data.find(issue =>
issue.title.includes(isFailure ? 'test: Some e2e tests failed' : 'Test Report') &&
issue.body.includes(run_url)
);

if (existingIssue) {
// Update existing issue
await github.rest.issues.update({
owner,
repo,
issue_number: existingIssue.number,
title,
body: reportContent
});
} else {
// Create new issue
await github.rest.issues.create({
owner,
repo,
title,
body: reportContent,
labels
});
}

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 7 months ago

To resolve this issue, you should add an explicit permissions block to the workflow, restricting the GITHUB_TOKEN permissions to only those necessary. In this specific workflow, most steps only require contents: read to checkout code, but step 35 ("Create or update test report issue") performs write actions on issues GitHub resource, requiring issues: write. Therefore, add the following block either at the root of the workflow (to apply to all jobs where not overridden) or within the test job (to restrict just that job):

permissions:
  contents: read
  issues: write

This change should be made by adding the above permissions block directly below the name key and before the on key, to apply it to the whole workflow as recommended.

Suggested changeset 1
.github/workflows/e2e_tests.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/e2e_tests.yml b/.github/workflows/e2e_tests.yml
--- a/.github/workflows/e2e_tests.yml
+++ b/.github/workflows/e2e_tests.yml
@@ -1,4 +1,7 @@
 name: Scheduled Playwright Tests
+permissions:
+  contents: read
+  issues: write
 
 on:
   schedule:
EOF
@@ -1,4 +1,7 @@
name: Scheduled Playwright Tests
permissions:
contents: read
issues: write

on:
schedule:
Copilot is powered by AI and may make mistakes. Always verify output.
@nk1408 nk1408 closed this Dec 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants