From 154811bedb0a10db5c806024461a546a75e798e8 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Wed, 15 Mar 2023 19:26:36 +1030 Subject: [PATCH] chore: fix build --- .eslintrc.js | 6 +++--- .github/actions/prepare-build/action.yml | 18 ++++++++++++++---- .github/workflows/ci.yml | 21 ++++++++++++++++++++- package.json | 5 +++-- packages/types/package.json | 6 +++--- packages/types/tools/copy-ast-spec.ts | 6 ++++-- packages/website/package.json | 2 +- patches/@types+esquery+1.0.2.patch | 20 -------------------- yarn.lock | 7 ------- 9 files changed, 48 insertions(+), 43 deletions(-) delete mode 100644 patches/@types+esquery+1.0.2.patch diff --git a/.eslintrc.js b/.eslintrc.js index ae87c5f87c50..66097b17f060 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,5 +1,5 @@ // @ts-check -/** @type {import('@typescript-eslint/utils').TSESLint.Linter.Config} */ +/** @type {import('./packages/utils/src/ts-eslint/Linter').Linter.Config} */ module.exports = { root: true, plugins: [ @@ -410,9 +410,9 @@ module.exports = { }, }, { - files: ['./packages/website-eslint/src/mock/**/*.js'], + files: ['./packages/website-eslint/src/mock/**/*.js', '*.d.ts'], rules: { - // mocks have to mirror their original + // mocks and declaration files have to mirror their original package 'import/no-default-export': 'off', }, }, diff --git a/.github/actions/prepare-build/action.yml b/.github/actions/prepare-build/action.yml index d656587ca56a..65d5fdd535c0 100644 --- a/.github/actions/prepare-build/action.yml +++ b/.github/actions/prepare-build/action.yml @@ -10,13 +10,23 @@ runs: id: build-cache with: path: '**/dist/**' - key: ${{ runner.os }}-build-${{ github.ref }} + key: ${{ runner.os }}-build-${{ github.ref }}-${{ github.run_id }} + # We don't want to share builds across runs even for the same branch + # because each commit can have different build artifacts and we don't + # want to accidentally share artifacts and poison the build output restore-keys: | - ${{ runner.os }}-build- + ${{ runner.os }}-build-${{ github.ref }}-${{ github.run_id }} + + # If the cache was hit, then we still run the types build because we generate source files + - name: Build AST Spec + if: steps['build-cache'].outputs.cache-hit == 'true' + shell: bash + run: | + SKIP_AST_SPEC_REBUILD=true npx nx run types:build - # if the cache was hit - this will run in <1s - name: Build + if: steps['build-cache'].outputs.cache-hit != 'true' shell: bash # Website will be built by the Netlify GitHub App run: | - npx nx run-many --target=build --parallel --exclude website + npx nx run-many --target=build --parallel --exclude=website --exclude=website-eslint --exclude=ast-spec --exclude=types diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 87208103d2cb..5acd1e3c4587 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -177,6 +177,25 @@ jobs: # Sadly 1 day is the minimum retention-days: 1 + website_build: + name: Build Website + needs: [install, build] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Install + uses: ./.github/actions/prepare-install + with: + node-version: ${{ env.PRIMARY_NODE_VERSION }} + - name: Build Base + uses: ./.github/actions/prepare-build + + - name: Build Website + shell: bash + run: | + npx nx run-many --target=build --projects=website-eslint,website + ## TODO - re-enable once we fix them # https://github.com/typescript-eslint/typescript-eslint/issues/6508 # website_tests: @@ -187,7 +206,7 @@ jobs: # # We technically do not need to wait for build within the pipeline any more because the build we care about is happening within Netlify, however, # # it is highly likely that if the CI one fails, the Netlify one will as well, so in order to not waste unncessary Github Actions minutes/resources, # # we do still keep this requirement here. - # needs: [build] + # needs: [website_build] # runs-on: ubuntu-latest # steps: # - name: Checkout diff --git a/package.json b/package.json index a1b30c81f1a5..ada19c9419f9 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "url": "https://github.com/typescript-eslint/typescript-eslint/issues" }, "scripts": { - "build": "nx run-many --target=build --parallel --exclude website", + "build": "nx run-many --target=build --parallel --exclude website --exclude website-eslint", "check-clean-workspace-after-install": "git diff --quiet --exit-code", "check-configs": "nx run-many --target=check-configs --parallel", "check-docs": "nx run-many --target=check-docs --parallel", @@ -44,8 +44,9 @@ "postinstall": "nx run repo-tools:postinstall-script", "pre-commit": "yarn lint-staged", "start": "nx run website:start", - "test": "nx run-many --target=test --parallel --exclude integration-tests", + "test": "nx run-many --target=test --parallel --exclude integration-tests --exclude website --exclude website-eslint", "test-integration": "nx run integration-tests:test", + "test-website": "nx run-many --target=test --projects=website,website-eslint", "typecheck": "nx run-many --target=typecheck --parallel" }, "engines": { diff --git a/packages/types/package.json b/packages/types/package.json index 4c4af9a7ace5..03ce915d1f1b 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -35,7 +35,7 @@ "estree" ], "scripts": { - "prebuild": "tsx ./tools/copy-ast-spec.ts", + "copy-ast-spec": "tsx ./tools/copy-ast-spec.ts", "build": "tsc -b tsconfig.build.json", "postbuild": "downlevel-dts dist _ts4.2/dist --to=4.2", "clean": "tsc -b tsconfig.build.json --clean", @@ -47,7 +47,7 @@ }, "nx": { "targets": { - "prebuild": { + "copy-ast-spec": { "dependsOn": [ { "target": "build", @@ -65,7 +65,7 @@ "projects": "dependencies" }, { - "target": "prebuild", + "target": "copy-ast-spec", "projects": "self" } ] diff --git a/packages/types/tools/copy-ast-spec.ts b/packages/types/tools/copy-ast-spec.ts index a8df1b7b2f10..dc2227ae48bc 100644 --- a/packages/types/tools/copy-ast-spec.ts +++ b/packages/types/tools/copy-ast-spec.ts @@ -67,8 +67,10 @@ async function copyFile( } async function main(): Promise { - // ensure the package is built - await execAsync('yarn', ['build'], { cwd: AST_SPEC_PATH }); + if (process.env.SKIP_AST_SPEC_REBUILD) { + // ensure the package is built + await execAsync('yarn', ['build'], { cwd: AST_SPEC_PATH }); + } await Promise.all([ copyFile('dist', 'ast-spec.ts', code => diff --git a/packages/website/package.json b/packages/website/package.json index 91f8eb179ee5..d643cbcd1a83 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -47,11 +47,11 @@ "@axe-core/playwright": "^4.4.5", "@docusaurus/module-type-aliases": "~2.2.0", "@playwright/test": "^1.27.1", - "@types/esquery": "^1.0.2", "@types/react": "^18.0.9", "@types/react-helmet": "^6.1.5", "@types/react-router-dom": "^5.3.3", "@typescript-eslint/eslint-plugin": "5.55.0", + "@typescript-eslint/types": "5.55.0", "copy-webpack-plugin": "^11.0.0", "cross-fetch": "*", "globby": "^11.1.0", diff --git a/patches/@types+esquery+1.0.2.patch b/patches/@types+esquery+1.0.2.patch deleted file mode 100644 index 89ee7d2f1f94..000000000000 --- a/patches/@types+esquery+1.0.2.patch +++ /dev/null @@ -1,20 +0,0 @@ -diff --git a/node_modules/@types/esquery/index.d.ts b/node_modules/@types/esquery/index.d.ts -index ba54dba..c101712 100755 ---- a/node_modules/@types/esquery/index.d.ts -+++ b/node_modules/@types/esquery/index.d.ts -@@ -4,12 +4,14 @@ - // Brad Zacher - // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - --import { Node } from 'estree'; -+import { TSESTree } from '@typescript-eslint/types'; - - export as namespace esquery; - - export = query; - -+type Node = TSESTree.Node; -+ - /** Query the code AST using the selector string. */ - declare function query(ast: Node, selector: string): Node[]; - diff --git a/yarn.lock b/yarn.lock index b759e466c22f..a89e87fe57aa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3460,13 +3460,6 @@ version "0.0.0" uid "" -"@types/esquery@^1.0.2": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@types/esquery/-/esquery-1.0.2.tgz#ccab4b6bd1aec356d5daa5b3abc55eac703c332d" - integrity sha512-qeAoHiWfqF4ST6An3DM2r1743bWL7B5hW4oNR9tWkdOjFUR1aK2j0jnYvW6h30VGDeXQ+1bWOYTej4JVo/5+PA== - dependencies: - "@types/estree" "*" - "@types/estree@*": version "0.0.0" uid ""