From 2677049bf717c676b6dbb79a8e9aa77d88084207 Mon Sep 17 00:00:00 2001 From: orta Date: Sat, 22 Jul 2023 05:43:12 +0100 Subject: [PATCH 1/4] Adds some infra to warn on files which changed in the PR but aren't accounted for --- .github/workflows/CI.yml | 29 +++++++---------------------- dangerfile.ts | 13 ++++++++++--- packages/documentation/package.json | 4 ++-- 3 files changed, 19 insertions(+), 27 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index bb9299f5d333..78daaf15cb97 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -40,29 +40,14 @@ jobs: env: CI: true - # Deploy preview environment for non-forks - - uses: Azure/static-web-apps-deploy@v1 - if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id - with: - azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_PROD }} - repo_token: ${{ secrets.GITHUB_TOKEN }} - action: upload - app_location: site - skip_app_build: true - - # Upload site artifact for forks so it can be deployed by a maintainer on-demand - - uses: actions/upload-artifact@v3 - if: github.event.pull_request.base.repo.id != github.event.pull_request.head.repo.id - with: - name: site-${{ github.event.number }} - path: site/ - # danger for PR builds - - if: github.event_name == 'pull_request' && github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id - run: "yarn danger ci" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_DEPLOY_URL_ROOT: ${{ steps.deploy.outputs.static_web_app_url }} + - name: "Run Danger" + run: | + # Exposing this token is safe because the user of it has no other public repositories + # and has no permission to modify this repository. See DefinitelyTyped #62638 for the discussion. + TOKEN='ghp_i5wtj1l2AbpFv3OU96w6R' + TOKEN+='On3bHOkcV2AmVY6' + DANGER_GITHUB_API_TOKEN=$TOKEN yarn danger ci windows: if: github.event.action != 'closed' diff --git a/dangerfile.ts b/dangerfile.ts index 8305cebf31b5..ee3a9c6cf95f 100644 --- a/dangerfile.ts +++ b/dangerfile.ts @@ -2,9 +2,16 @@ // yarn danger pr https://github.com/microsoft/TypeScript-Website/pull/115 import spellcheck from "danger-plugin-spellcheck" - -// Blocked on PR deploys, see CI.yml -// import lighthouse from "danger-plugin-lighthouse" +import { warn, danger }from "danger" +import { execSync } from "child_process" // Spell check all the things spellcheck({ settings: "microsoft/TypeScript-Website@spellcheck.json" }) + +const gitStatus = execSync("git status --porcelain").toString() +if (gitStatus.includes("M")) { + const files = gitStatus.split("\n").filter(f => f.startsWith(" M ")).map(f => f.substr(3)) + const linksToChangedFiles = danger.github.utils.fileLinks(files) + + warn(`There are un-staged changes to generated files: \n ${linksToChangedFiles}`) +} \ No newline at end of file diff --git a/packages/documentation/package.json b/packages/documentation/package.json index d209897490bc..616a1881ecee 100644 --- a/packages/documentation/package.json +++ b/packages/documentation/package.json @@ -4,11 +4,11 @@ "license": "MIT", "version": "1.0.0", "scripts": { - "build": "echo 'NOOP'", + "build": "yarn create-handbook-nav", "test": "echo 'NOOP'", "lint": "node scripts/lintTwoslashErrors.js", "create-handbook-nav": "node ./scripts/generateTypesForFilesInDocs && node ./scripts/generateDocsNavigationPerLanguage.js", - "bootstrap": "yarn create-handbook-nav && node ./scripts/generateAttribution.js" + "bootstrap": "node ./scripts/generateAttribution.js" }, "prettier": { "semi": true From 02fe069231c0f0b80207bc27a17f967c2aac8745 Mon Sep 17 00:00:00 2001 From: orta Date: Sat, 22 Jul 2023 05:53:33 +0100 Subject: [PATCH 2/4] Do it in both --- packages/documentation/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/documentation/package.json b/packages/documentation/package.json index 616a1881ecee..94a7ebf3016b 100644 --- a/packages/documentation/package.json +++ b/packages/documentation/package.json @@ -8,7 +8,7 @@ "test": "echo 'NOOP'", "lint": "node scripts/lintTwoslashErrors.js", "create-handbook-nav": "node ./scripts/generateTypesForFilesInDocs && node ./scripts/generateDocsNavigationPerLanguage.js", - "bootstrap": "node ./scripts/generateAttribution.js" + "bootstrap": "yarn create-handbook-nav && node ./scripts/generateAttribution.js" }, "prettier": { "semi": true From 3fa6b26f232c5a72667c00bde30e42aac35312ea Mon Sep 17 00:00:00 2001 From: orta Date: Tue, 25 Jul 2023 20:17:22 +0100 Subject: [PATCH 3/4] Bring back the CI events for uploading preview envs --- .github/workflows/CI.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 78daaf15cb97..ff9374a47987 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -40,6 +40,23 @@ jobs: env: CI: true + # Deploy preview environment for non-forks + - uses: Azure/static-web-apps-deploy@v1 + if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id + with: + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_PROD }} + repo_token: ${{ secrets.GITHUB_TOKEN }} + action: upload + app_location: site + skip_app_build: true + + # Upload site artifact for forks so it can be deployed by a maintainer on-demand + - uses: actions/upload-artifact@v3 + if: github.event.pull_request.base.repo.id != github.event.pull_request.head.repo.id + with: + name: site-${{ github.event.number }} + path: site/ + # danger for PR builds - name: "Run Danger" run: | From c4f09188f9eb387227ac26b083f7505c4bc48453 Mon Sep 17 00:00:00 2001 From: Orta Therox Date: Fri, 4 Aug 2023 08:19:50 +0100 Subject: [PATCH 4/4] Update dangerfile.ts Co-authored-by: Ron Buckton --- dangerfile.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dangerfile.ts b/dangerfile.ts index ee3a9c6cf95f..605091dd9de3 100644 --- a/dangerfile.ts +++ b/dangerfile.ts @@ -2,7 +2,7 @@ // yarn danger pr https://github.com/microsoft/TypeScript-Website/pull/115 import spellcheck from "danger-plugin-spellcheck" -import { warn, danger }from "danger" +import { warn, danger } from "danger" import { execSync } from "child_process" // Spell check all the things