Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .github/workflows/attw-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: "Are the types wrong?"
on: [pull_request]
permissions:
pull-requests: write

Comment on lines +2 to +5
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow uses github.rest.issues.* APIs to create/update PR comments, but the token permissions only grant pull-requests: write. To avoid 403s, add the required permissions explicitly (typically issues: write, and often contents: read as well). Also consider guarding the commenting step for forked PRs where GITHUB_TOKEN is read-only, so the workflow doesn’t fail unexpectedly.

Copilot uses AI. Check for mistakes.
jobs:
build:
name: Are the types wrong?
runs-on: ubuntu-latest
steps:
- name: Setup node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: 22

- name: Checkout PR branch
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Install and build
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
ELECTRON_DISABLE_SANDBOX: 1
run: |
npm ci
npm run build

- name: Run ATTW check
continue-on-error: true
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
ELECTRON_DISABLE_SANDBOX: 1
run: |
npm run test:attw || true
Comment on lines +27 to +33
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow currently can’t fail the check: continue-on-error: true plus npm run test:attw || true ensures ATTW failures/type issues never fail the job. If the intent is an automated validation check (per PR title/description), remove the error suppression (or add a later step that explicitly fails the job when ATTW reports problems).

Copilot uses AI. Check for mistakes.

- name: Parse ATTW results and comment
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const { execSync } = require('child_process');

// Run the parse script to get markdown output
let commentBody;
try {
commentBody = execSync('node scripts/parse-attw-results.js --format=markdown', {
encoding: 'utf8',
stdio: ['pipe', 'pipe', 'pipe']
});
} catch (error) {
// Script exits with code 1 if there are problems, but we still want the output
commentBody = error.stdout || error.message;
}

if (!commentBody || !commentBody.includes('Are The Types Wrong? Report')) {
console.log('No valid output from parse script');
return;
}

// Post or update comment
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});

const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment.user.type === 'Bot' is very broad and could match other automation accounts, leading this workflow to overwrite an unrelated bot’s comment as long as it contains the same header text. Prefer matching on comment.user.login === 'github-actions[bot]' (or a unique marker string in the body) to ensure only this workflow’s own comment is updated.

Suggested change
comment.user.type === 'Bot' &&
comment.user.login === 'github-actions[bot]' &&

Copilot uses AI. Check for mistakes.
comment.body.includes('Are The Types Wrong? Report')
);

if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: commentBody
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: commentBody
});
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ Gemfile.lock
*.iml
zscaler-root-ca.crt*
.ts38-validation
# Arethetypeswrong working files
attw-results.json
Loading
Loading