Skip to content

Commit

Permalink
Uncover and Fix Cyclic Dependency, Version-Control Vercel Configs, Fi…
Browse files Browse the repository at this point in the history
…x Turbo Graph. (#2502)

* Driveby: Update requirements within README

* Fix cyclic dependency in GraphQL definitions

* Remove outdated `index.ts` pattern

* Add turbo artifacts to ignores

* Update PR template to refer to turbo graph

* Fix turbo graph of design packages

* Version-Control Vercel build configuration

* Add pipefail to scripts

Co-authored-by: Ahmad Sattar <thehabbos007@gmail.com>

---------

Co-authored-by: Ahmad Sattar <thehabbos007@gmail.com>
  • Loading branch information
Alfred Mountfield and thehabbos007 authored Apr 28, 2023
1 parent eb09d7b commit 45acb52
Show file tree
Hide file tree
Showing 45 changed files with 174 additions and 33 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,7 @@ seed-users.json

# SARIF files
*.sarif

# Turbo
.turbo/
out/
55 changes: 45 additions & 10 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,60 @@

- ...

## 🚀 Has this modified a publishable library?
## Pre-Merge Checklist 🚀

### 🚢 Has this modified a publishable library?

<!-- Confirm you have taken the necessary action to record a changeset or publish a change, as appropriate -->
<!-- AT LEAST ONE box must be checked. Do not delete this section! see libs/README.md for info on publishing -->
<!-- Remove the initial placeholder, and uncomment AT LEAST ONE of these. This MUST be done prior to merging. Do not delete this section! see libs/README.md for info on publishing -->

This PR:

- [ ] modifies an **npm**-publishable library and **I have added a changeset file(s)**
- [ ] modifies a **Cargo**-publishable library and **I have amended the version**
- [ ] modifies a **Cargo**-publishable library, but **it is not yet ready to publish**
- [ ] modifies a **block** that will need publishing via GitHub action once merged
- [ ] does not modify any publishable blocks or libraries, or modifications do not need publishing
- [ ] I am unsure / need advice
- [ ] **⚠️ This is a placeholder, please uncomment at least one of the lines following this one and then delete this. ⚠️**

<!-- - [x] modifies an **npm**-publishable library and **I have added a changeset file(s)** -->

<!-- - [x] modifies a **Cargo**-publishable library and **I have amended the version** -->

<!-- - [x] modifies a **Cargo**-publishable library, but **it is not yet ready to publish** -->

<!-- - [x] modifies a **block** that will need publishing via GitHub action once merged -->

## 📜 Does this require a change to the docs?
<!-- - [x] does not modify any publishable blocks or libraries, or modifications do not need publishing -->

<!-- - [x] I am unsure / need advice -->

### 📜 Does this require a change to the docs?

<!-- If this adds a user facing feature or modifies how an existing feature is used, it likely needs a docs change. -->
<!-- Remove the initial placeholder, and uncomment AT LEAST ONE of these, filling in information as necessary. This MUST be done prior to merging. Do not delete this section! see libs/README.md for info on publishing -->

The changes in this PR:

- [ ] **⚠️ This is a placeholder, please uncomment at least one of the lines following this one and then delete this. ⚠️**

<!-- - [x] is internal and does not require a docs change -->

<!-- - [x] is in a state where docs changes are not _yet_ required but will be
- this is tracked within: [Insert Link Here](link) -->

<!-- - [x] requires changes to docs
- <CHANGES TO DOCS EXPLAINED HERE> -->

### 🕸️ Does this require a change to the Turbo Graph?

<!-- If this adds or moves an existing package, modifies `scripts` in a `package.json`, it likely needs a turbo graph change. -->
<!-- Remove the initial placeholder, and uncomment AT LEAST ONE of these, filling in information as necessary. This MUST be done prior to merging. Do not delete this section! see libs/README.md for info on publishing -->

The changes in this PR:

- [ ] **⚠️ This is a placeholder, please uncomment at least one of the lines following this one and then delete this. ⚠️**

<!-- - [x] affected the execution graph, and the `turbo.json`'s have been updated to reflect this -->

<!-- - [x] does not affect the execution graph -->

- The docs for x need updating to explain that y
<!-- - [x] I am unsure / need advice -->

## ⚠️ Known issues

Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,7 @@ seed-users.json

# SARIF files
*.sarif

# Turborepo
.turbo/
out/
4 changes: 4 additions & 0 deletions .markdownlintignore
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,7 @@ seed-users.json
# Keep license files as is
LICENSE.md
LICENSE-*.md

# Turborepo
.turbo/
out/
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,7 @@ seed-users.json
# Keep license files as is
LICENSE.md
LICENSE-*.md

# Turborepo
.turbo/
out/
2 changes: 1 addition & 1 deletion apps/hash-api/codegen.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { scalars } from "@local/hash-graphql-shared/graphql/scalar-mapping";

const config: CodegenConfig = {
overwrite: true,
schema: "./src/graphql/type-defs/**/*.ts",
schema: "../../libs/@local/hash-graphql-shared/src/graphql/type-defs/**/*.ts",
require: ["ts-node/register"],
generates: {
"./src/graphql/graphql-schema.gen.json": {
Expand Down
2 changes: 1 addition & 1 deletion apps/hash-api/src/graphql/create-apollo-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { performance } from "node:perf_hooks";
import { makeExecutableSchema } from "@graphql-tools/schema";
import { Logger } from "@local/hash-backend-utils/logger";
import { SearchAdapter } from "@local/hash-backend-utils/search/adapter";
import { schema } from "@local/hash-graphql-shared/graphql/type-defs/schema";
import { ApolloServerPluginLandingPageGraphQLPlayground } from "apollo-server-core";
import { ApolloServer } from "apollo-server-express";
import { StatsD } from "hot-shots";
Expand All @@ -15,7 +16,6 @@ import { UploadableStorageProvider } from "../storage";
import { TaskExecutor } from "../task-execution";
import { GraphQLContext } from "./context";
import { resolvers } from "./resolvers";
import { schema } from "./type-defs";

export interface CreateApolloServerParams {
graphApi: GraphApi;
Expand Down
2 changes: 1 addition & 1 deletion apps/hash-frontend/codegen.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { scalars } from "@local/hash-graphql-shared/graphql/scalar-mapping";

const config: CodegenConfig = {
overwrite: true,
schema: "../hash-api/src/graphql/type-defs/**/*.ts",
schema: "../../libs/@local/hash-graphql-shared/src/graphql/type-defs/**/*.ts",
generates: {
"./src/graphql/fragment-types.gen.json": {
plugins: ["fragment-matcher"],
Expand Down
12 changes: 12 additions & 0 deletions apps/hash-frontend/vercel-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

# shellcheck disable=SC1090
source ~/.bashrc

set -euo pipefail

echo "Changing dir to root"
cd ../..

echo "Building frontend"
turbo build --filter='@apps/hash-frontend'
26 changes: 26 additions & 0 deletions apps/hash-frontend/vercel-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

set -euo pipefail

# Setup TurboRepo and get a pruned src folder and lockfile

echo "Installing turbo"
yarn global add turbo

# TODO: investigate why producing a pruned repo results in a broken Vercel build

#echo "Producing pruned repo"
#turbo prune --scope='@apps/hash-frontend'
#
#echo "Deleting contents of non-pruned dir to save space"
#git ls-files -z | xargs -0 rm -f
#git ls-tree --name-only -d -r -z HEAD | sort -rz | xargs -0 rm -rf
#
#echo "Moving pruned repo back to root"
#mv out/* .
#rm out -r

# Install the pruned dependencies

echo "Installing yarn dependencies"
HUSKY=0 yarn install --frozen-lockfile --prefer-offline --force --build-from-source
9 changes: 9 additions & 0 deletions apps/hash-frontend/vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"github": {
"silent": true,
"autoJobCancelation": true
},
"installCommand": "./vercel-install.sh",
"buildCommand": "./vercel-build.sh",
"outputDirectory": "./.next"
}
8 changes: 7 additions & 1 deletion apps/hash/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ This folder contains only the _HASH_ project README. The application is split ac

To run HASH locally, please follow these steps:

1. Make sure you have, [Git](https://git-scm.com), [Node LTS](https://nodejs.org), [Yarn Classic](https://classic.yarnpkg.com) and [Docker](https://docs.docker.com/get-docker/). Building the Docker containers requires [Docker Buildx](https://docs.docker.com/build/install-buildx/).
1. Make sure you have, [Git](https://git-scm.com), [Node LTS](https://nodejs.org), [Yarn Classic](https://classic.yarnpkg.com), [Docker](https://docs.docker.com/get-docker/), [Python](https://www.python.org/downloads/), and [Java](https://www.java.com/download/ie_manual.jsp). Building the Docker containers requires [Docker Buildx](https://docs.docker.com/build/install-buildx/).
Run each of these version commands and make sure the output is expected:

```sh
Expand All @@ -68,6 +68,12 @@ To run HASH locally, please follow these steps:

docker buildx version
## ≥ 0.10.4

java --version
## ≥ 8

python --version
## ≥ 3.11
```

If you have difficulties with `git --version` on macOS you may need to install Xcode Command Line Tools first: `xcode-select --install`.
Expand Down
4 changes: 2 additions & 2 deletions apps/hashdotdesign/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ Storybook app for viewing design system components used in libraries, applicatio

Included packages:

- @hashintel/design-system
- @hashintel/block-design-system
- `@hashintel/design-system`
- `@hashintel/block-design-system`
3 changes: 2 additions & 1 deletion apps/hashdotdesign/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
"description": "HASH design system storybook",
"sideEffects": false,
"scripts": {
"build-storybook": "storybook build",
"build": "storybook build",
"storybook": "storybook dev -p 6006"
},
"devDependencies": {
"@babel/preset-env": "7.20.2",
"@babel/preset-typescript": "7.18.6",
"@hashintel/block-design-system": "0.0.0",
"@hashintel/design-system": "0.0.6",
"@local/eslint-config": "0.0.0-private",
"@local/tsconfig": "0.0.0-private",
Expand Down
12 changes: 12 additions & 0 deletions apps/hashdotdesign/turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": ["//"],
"pipeline": {
"build": {
// Outputs of the build
"outputs": ["./storybook-static/**/*"]
},
"storybook": {
"persistent": true
}
}
}
9 changes: 9 additions & 0 deletions apps/hashdotdesign/vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"github": {
"silent": true,
"autoJobCancelation": true
},
"installCommand": "cd ../.. && yarn install",
"buildCommand": "turbo --filter '@apps/hashdotdesign' build",
"outputDirectory": "storybook-static"
}
2 changes: 1 addition & 1 deletion apps/hashdotdev/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"pipeline": {
"build": {
// Outputs of the build
"outputs": ["./dist/**/*"]
"outputs": ["./.next/**/*"]
}
}
}
8 changes: 8 additions & 0 deletions apps/hashdotdev/vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"github": {
"silent": true,
"autoJobCancelation": true
},
"buildCommand": "turbo --filter '@apps/hashdotdev' build",
"installCommand": "cd ../.. && yarn install"
}
8 changes: 8 additions & 0 deletions libs/@hashintel/block-design-system/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Block Design System

Components for specific use in blocks.

## Running Storybook

The Block Design System can be viewed locally (alongside the [HASH Design System](../design-system)) by running the following command:

```bash
turbo --filter '@apps/hashdotdesign' storybook
```
4 changes: 1 addition & 3 deletions libs/@hashintel/block-design-system/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
"lint:eslint": "eslint --report-unused-disable-directives .",
"lint:tsc": "tsc --noEmit",
"prepublishOnly": "PACKAGE_DIR=$(pwd) yarn workspace @local/repo-chores exe scripts/prepublish.ts",
"postpublish": "PACKAGE_DIR=$(pwd) yarn workspace @local/repo-chores exe scripts/postpublish.ts",
"storybook": "yarn workspace @apps/hashdotdesign storybook",
"test": "jest"
"postpublish": "PACKAGE_DIR=$(pwd) yarn workspace @local/repo-chores exe scripts/postpublish.ts"
},
"dependencies": {
"@hashintel/design-system": "0.0.6",
Expand Down
8 changes: 8 additions & 0 deletions libs/@hashintel/design-system/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

Components for use in other libraries, applications and blocks. Design system components are in the process of gradually being made accessible within the [HASH Storybook](https://ds.hash.dev/).

## Running Storybook

The Block Design System can be viewed locally (alongside the [Block Design System](../block-design-system)) by running the following command:

```bash
turbo --filter '@apps/hashdotdesign' storybook
```

## Publishing

See [`libs/README.md`](../../README.md#publishing)
4 changes: 1 addition & 3 deletions libs/@hashintel/design-system/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
"lint:eslint": "eslint --report-unused-disable-directives .",
"lint:tsc": "tsc --noEmit",
"prepublishOnly": "PACKAGE_DIR=$(pwd) yarn workspace @local/repo-chores exe scripts/prepublish.ts",
"postpublish": "PACKAGE_DIR=$(pwd) yarn workspace @local/repo-chores exe scripts/postpublish.ts",
"storybook": "yarn workspace @apps/hashdotdesign storybook",
"test": "jest"
"postpublish": "PACKAGE_DIR=$(pwd) yarn workspace @local/repo-chores exe scripts/postpublish.ts"
},
"dependencies": {
"@fortawesome/free-regular-svg-icons": "6.0.0",
Expand Down
2 changes: 1 addition & 1 deletion libs/@local/hash-graphql-shared/codegen.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { scalars } from "@local/hash-graphql-shared/graphql/scalar-mapping";

const config: CodegenConfig = {
overwrite: true,
schema: "../../../apps/hash-api/src/graphql/type-defs/**/*.ts",
schema: "./src/graphql/type-defs/**/*.ts",
generates: {
"./src/graphql/fragment-types.gen.json": {
plugins: ["fragment-matcher"],
Expand Down
1 change: 1 addition & 0 deletions libs/@local/hash-graphql-shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@local/hash-graph-client": "0.0.0-private",
"@local/hash-subgraph": "0.0.0-private",
"@sentry/browser": "7.30.0",
"apollo-server-express": "3.9.0",
"node-fetch": "^2.6.7"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion libs/@local/hash-isomorphic-utils/codegen.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { scalars } from "@local/hash-graphql-shared/graphql/scalar-mapping";

const config: CodegenConfig = {
overwrite: true,
schema: "../../../apps/hash-api/src/graphql/type-defs/**/*.ts",
schema: "../hash-graphql-shared/src/graphql/type-defs/**/*.ts",
generates: {
"./src/graphql/fragment-types.gen.json": {
plugins: ["fragment-matcher"],
Expand Down
2 changes: 1 addition & 1 deletion tests/hash-backend-integration/codegen.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { scalars } from "@local/hash-graphql-shared/graphql/scalar-mapping";

const config: CodegenConfig = {
overwrite: true,
schema: "../../apps/hash-api/src/graphql/type-defs/**/*.ts",
schema: "../../libs/@local/hash-graphql-shared/src/graphql/type-defs/**/*.ts",
generates: {
"./src/graphql/fragment-types.gen.json": {
plugins: ["fragment-matcher"],
Expand Down
6 changes: 0 additions & 6 deletions vercel.json

This file was deleted.

0 comments on commit 45acb52

Please sign in to comment.