From 3f61ce43e9110035e5da726850509814243da4dd Mon Sep 17 00:00:00 2001 From: Vlad Frangu Date: Sat, 28 Dec 2024 21:47:37 +0200 Subject: [PATCH] chore: revert for now and make the script fail in CI --- .github/workflows/check-deno.yml | 2 +- scripts/actions/report-deno-not-ran.mjs | 49 +++---------------------- 2 files changed, 7 insertions(+), 44 deletions(-) diff --git a/.github/workflows/check-deno.yml b/.github/workflows/check-deno.yml index e8a2ce40..bd626ef9 100644 --- a/.github/workflows/check-deno.yml +++ b/.github/workflows/check-deno.yml @@ -1,7 +1,7 @@ name: Deno on: - pull_request_target: + pull_request: types: - opened - synchronize diff --git a/scripts/actions/report-deno-not-ran.mjs b/scripts/actions/report-deno-not-ran.mjs index 16bca2c5..2eb3d743 100644 --- a/scripts/actions/report-deno-not-ran.mjs +++ b/scripts/actions/report-deno-not-ran.mjs @@ -1,25 +1,11 @@ /* eslint-disable @typescript-eslint/restrict-template-expressions */ import { execSync } from 'node:child_process'; -import { readFile } from 'node:fs/promises'; import process from 'node:process'; -import { Octokit } from '@octokit/action'; -const octokit = new Octokit(); const [OWNER, REPOSITORY] = process.env.GITHUB_REPOSITORY.split('/'); const commitUrl = `https://github.com/${OWNER}/${REPOSITORY}/commit/${process.env.GITHUB_SHA}`; -/** @type {import('@octokit/webhooks-types').PullRequestOpenedEvent | import('@octokit/webhooks-types').PullRequestSynchronizeEvent} */ -// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -const prEvent = JSON.parse(await readFile(process.env.GITHUB_EVENT_PATH, 'utf8')); - -const { - pull_request: { - number, - user: { login }, - }, -} = prEvent; - console.info(`👀 Verifying that deno types are up to date with commit ${process.env.GITHUB_SHA}`); console.debug('Running build:deno script'); execSync(`npm run build:deno`); @@ -32,23 +18,6 @@ const diff = execSync(`git diff --name-only ${process.env.GITHUB_SHA}`) if (!diff.length) { console.info('✅ Nothing to do here!'); - const allReviews = await octokit.pulls.listReviews({ - owner: OWNER, - pull_number: number, - repo: REPOSITORY, - }); - - const lastReviewByBot = allReviews.data.filter((item) => item.user?.id === 41_898_282).at(-1); - - if (lastReviewByBot?.state === 'CHANGES_REQUESTED') { - await octokit.pulls.dismissReview({ - owner: OWNER, - repo: REPOSITORY, - pull_number: number, - message: 'No longer applicable as deno types are in sync once again! 🎉', - review_id: lastReviewByBot.id, - }); - } process.exit(0); } @@ -56,15 +25,15 @@ if (!diff.length) { console.debug(`⚠️ Found ${diff.length} different files.`, { diff }); const messageBody = [ - `Hey @${login}! Taking a look at commit ${commitUrl}, it seems that you forgot to run \`npm run build:deno\`. Here are the files that are different from the base:`, + `Taking a look at commit ${commitUrl}, it seems that you forgot to run \`npm run build:deno\`. Here are the files that are different from the base:`, '', ]; for (const file of diff) { messageBody.push( - `- [Node: \`${file.slice(5)}\`](https://github.com/${process.env.GITHUB_REPOSITORY}/blob/${ + `- \`${file.slice(5)}\`: Node (https://github.com/${process.env.GITHUB_REPOSITORY}/blob/${ process.env.GITHUB_SHA - }/${file.slice(5)}) - [Deno: \`${file}\`](https://github.com/${process.env.GITHUB_REPOSITORY}/blob/${ + }/${file.slice(5)}) - Deno (https://github.com/${process.env.GITHUB_REPOSITORY}/blob/${ process.env.GITHUB_SHA }/${file})`, ); @@ -72,13 +41,7 @@ for (const file of diff) { messageBody.push('', 'Please run `npm run build:deno` and commit the results to update the deno types.'); -console.info('🔈 Requesting changes in the pull request'); -await octokit.pulls.createReview({ - event: 'REQUEST_CHANGES', - body: messageBody.join('\n'), - owner: OWNER, - repo: REPOSITORY, - pull_number: number, -}); +console.error('❌ Deno types are not up to date with the commit!'); +console.error(messageBody.join('\n')); -console.info('✅ Done!'); +process.exit(1);