avoid lazy race conditions (#1364)
We had a few issues with lazy race conditions failing CI. This came from scripts configured to invoke lazy again, rather than through expressing dependencies between scripts. This diff reconfigures lazy to articulate these sorts of things as dependencies instead of through self-invocation. Instead of having lots of separate `build-package`, `build-docs`, etc commands, we now just have a build command with package overrides to express more specific options ### Change Type - [x] `internal` — Any other changes that don't affect the published package (will not publish a new version) ### Release Notes [internal only]
This commit is contained in:
parent
6aa7f9957f
commit
0bd6410d9f
19 changed files with 44 additions and 52 deletions
6
.github/workflows/checks.yml
vendored
6
.github/workflows/checks.yml
vendored
|
@ -49,13 +49,13 @@ jobs:
|
||||||
- name: Check API declarations and docs work as intended
|
- name: Check API declarations and docs work as intended
|
||||||
run: yarn api-check
|
run: yarn api-check
|
||||||
|
|
||||||
- name: Pack public packages
|
|
||||||
run: "yarn lazy pack-tarball | sed -E 's/^.*? ::/::/'"
|
|
||||||
|
|
||||||
- name: Build all projects
|
- name: Build all projects
|
||||||
# the sed pipe makes sure that github annotations come through without
|
# the sed pipe makes sure that github annotations come through without
|
||||||
# turbo's prefix
|
# turbo's prefix
|
||||||
run: "yarn build | sed -E 's/^.*? ::/::/'"
|
run: "yarn build | sed -E 's/^.*? ::/::/'"
|
||||||
|
|
||||||
|
- name: Pack public packages
|
||||||
|
run: "yarn lazy pack-tarball | sed -E 's/^.*? ::/::/'"
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: yarn test
|
run: yarn test
|
||||||
|
|
|
@ -27,10 +27,8 @@
|
||||||
"infinite"
|
"infinite"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "lazy dev-docs",
|
"dev": "next dev",
|
||||||
"dev-docs": "next dev",
|
"build": "next build",
|
||||||
"build": "lazy build-docs",
|
|
||||||
"build-docs": "next build",
|
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "yarn run -T tsx ../../scripts/lint.ts",
|
"lint": "yarn run -T tsx ../../scripts/lint.ts",
|
||||||
"docs-content": "ts-node --project tsconfig.content.json ./scripts/index.ts",
|
"docs-content": "ts-node --project tsconfig.content.json ./scripts/index.ts",
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "yarn run -T tsx scripts/build.ts",
|
"build": "yarn run -T tsx scripts/build.ts",
|
||||||
"build:vscode-editor": "yarn run -T tsx scripts/build.ts",
|
|
||||||
"dev": "yarn run -T tsx scripts/dev.ts",
|
"dev": "yarn run -T tsx scripts/dev.ts",
|
||||||
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
|
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
|
||||||
"lint": "yarn run -T tsx ../../../scripts/lint.ts"
|
"lint": "yarn run -T tsx ../../../scripts/lint.ts"
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
"infinite"
|
"infinite"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev-webdriver": "concurrently --names \"tsc,esbuild\" \"yarn run -T tsx ../../scripts/typecheck.ts --build --watch --preserveWatchOutput\" \"node ./scripts/dev.mjs\"",
|
"dev": "concurrently --names \"tsc,esbuild\" \"yarn run -T tsx ../../scripts/typecheck.ts --build --watch --preserveWatchOutput\" \"node ./scripts/dev.mjs\"",
|
||||||
"lint": "yarn run -T tsx ../../scripts/lint.ts"
|
"lint": "yarn run -T tsx ../../scripts/lint.ts"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -3,23 +3,31 @@ import { LazyConfig } from 'lazyrepo'
|
||||||
export function generateSharedScripts(bublic: '<rootDir>' | '<rootDir>/bublic') {
|
export function generateSharedScripts(bublic: '<rootDir>' | '<rootDir>/bublic') {
|
||||||
return {
|
return {
|
||||||
build: {
|
build: {
|
||||||
runsAfter: { 'build-package': {}, prebuild: {} },
|
baseCommand: 'exit 0',
|
||||||
},
|
runsAfter: { prebuild: {}, 'refresh-assets': {} },
|
||||||
'build:vscode-editor': {
|
workspaceOverrides: {
|
||||||
runsAfter: { 'refresh-assets': {} },
|
'{bublic/,}apps/docs': { runsAfter: { 'docs-content': {} } },
|
||||||
|
'{bublic/,}apps/vscode/*': { runsAfter: { 'refresh-assets': {} } },
|
||||||
|
'{bublic/,}packages/*': {
|
||||||
|
runsAfter: { 'build-api': { in: 'self-only' }, prebuild: { in: 'self-only' } },
|
||||||
|
cache: {
|
||||||
|
inputs: ['api/**/*', 'src/**/*'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
dev: {
|
dev: {
|
||||||
execution: 'independent',
|
execution: 'independent',
|
||||||
runsAfter: { 'refresh-assets': {} },
|
runsAfter: { 'refresh-assets': {} },
|
||||||
cache: 'none',
|
cache: 'none',
|
||||||
},
|
workspaceOverrides: {
|
||||||
'dev-vscode': {
|
'{bublic/,}apps/docs': { runsAfter: { 'docs-content': { in: 'self-only' } } },
|
||||||
runsAfter: { 'build:vscode-editor': {} },
|
'{bublic/,}apps/vscode/*': { runsAfter: { build: { in: 'self-only' } } },
|
||||||
},
|
'{bublic/,}apps/webdriver': {
|
||||||
'dev-webdriver': {
|
runsAfter: { 'refresh-assets': {}, prebuild: {} },
|
||||||
execution: 'independent',
|
cache: 'none',
|
||||||
runsAfter: { 'refresh-assets': {}, prebuild: {}, 'build:vscode-editor': {} },
|
},
|
||||||
cache: 'none',
|
},
|
||||||
},
|
},
|
||||||
test: {
|
test: {
|
||||||
baseCommand: 'yarn run -T jest',
|
baseCommand: 'yarn run -T jest',
|
||||||
|
@ -27,6 +35,7 @@ export function generateSharedScripts(bublic: '<rootDir>' | '<rootDir>/bublic')
|
||||||
},
|
},
|
||||||
'test-coverage': {
|
'test-coverage': {
|
||||||
baseCommand: 'yarn run -T jest --coverage',
|
baseCommand: 'yarn run -T jest --coverage',
|
||||||
|
runsAfter: { 'refresh-assets': {} },
|
||||||
},
|
},
|
||||||
lint: {
|
lint: {
|
||||||
execution: 'independent',
|
execution: 'independent',
|
||||||
|
@ -37,12 +46,6 @@ export function generateSharedScripts(bublic: '<rootDir>' | '<rootDir>/bublic')
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'build-package': {
|
|
||||||
runsAfter: { 'build-api': {}, prebuild: {} },
|
|
||||||
cache: {
|
|
||||||
inputs: ['api/**/*', 'src/**/*'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
'pack-tarball': {
|
'pack-tarball': {
|
||||||
parallel: false,
|
parallel: false,
|
||||||
},
|
},
|
||||||
|
@ -84,12 +87,6 @@ export function generateSharedScripts(bublic: '<rootDir>' | '<rootDir>/bublic')
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'build-docs': {
|
|
||||||
runsAfter: { 'docs-content': {} },
|
|
||||||
},
|
|
||||||
'dev-docs': {
|
|
||||||
runsAfter: { 'docs-content': {} },
|
|
||||||
},
|
|
||||||
'docs-content': {
|
'docs-content': {
|
||||||
runsAfter: { 'build-api': {} },
|
runsAfter: { 'build-api': {} },
|
||||||
cache: {
|
cache: {
|
||||||
|
|
|
@ -37,11 +37,11 @@
|
||||||
"postinstall": "husky install && yarn refresh-assets",
|
"postinstall": "husky install && yarn refresh-assets",
|
||||||
"refresh-assets": "lazy refresh-assets",
|
"refresh-assets": "lazy refresh-assets",
|
||||||
"build": "lazy build",
|
"build": "lazy build",
|
||||||
"build-docs": "lazy build-docs",
|
"build-docs": "lazy build --filter='apps/docs'",
|
||||||
"dev": "lazy run dev --filter='{,bublic/}apps/examples' --filter='{,bublic/}packages/tldraw'",
|
"dev": "lazy run dev --filter='{,bublic/}apps/examples' --filter='{,bublic/}packages/tldraw'",
|
||||||
"dev-docs": "lazy run dev-docs",
|
"dev-docs": "lazy run dev --filter='apps/docs'",
|
||||||
"dev-vscode": "code ./apps/vscode/extension && lazy run dev --filter='{,bublic/}apps/vscode/{extension,editor}'",
|
"dev-vscode": "code ./apps/vscode/extension && lazy run dev --filter='{,bublic/}apps/vscode/{extension,editor}'",
|
||||||
"dev-webdriver": "lazy run dev-webdriver --filter='apps/webdriver'",
|
"dev-webdriver": "lazy run dev --filter='apps/webdriver' --filter='{,bublic/}apps/vscode/*'",
|
||||||
"build-types": "lazy inherit",
|
"build-types": "lazy inherit",
|
||||||
"build-api": "lazy build-api",
|
"build-api": "lazy build-api",
|
||||||
"build-package": "lazy build-package",
|
"build-package": "lazy build-package",
|
||||||
|
|
|
@ -37,8 +37,7 @@
|
||||||
"test": "lazy inherit",
|
"test": "lazy inherit",
|
||||||
"benchmark": "yarn run -T tsx ./scripts/benchmark.ts",
|
"benchmark": "yarn run -T tsx ./scripts/benchmark.ts",
|
||||||
"test-coverage": "lazy inherit",
|
"test-coverage": "lazy inherit",
|
||||||
"build": "lazy build-package",
|
"build": "yarn run -T tsx ../../scripts/build-package.ts",
|
||||||
"build-package": "yarn run -T tsx ../../scripts/build-package.ts",
|
|
||||||
"build-api": "yarn run -T tsx ../../scripts/build-api.ts",
|
"build-api": "yarn run -T tsx ../../scripts/build-api.ts",
|
||||||
"prepack": "yarn run -T tsx ../../scripts/prepack.ts",
|
"prepack": "yarn run -T tsx ../../scripts/prepack.ts",
|
||||||
"postpack": "../../scripts/postpack.sh",
|
"postpack": "../../scripts/postpack.sh",
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "lazy inherit",
|
"test": "lazy inherit",
|
||||||
"test-coverage": "lazy inherit",
|
"test-coverage": "lazy inherit",
|
||||||
"build-package": "yarn run -T tsx ../../scripts/build-package.ts",
|
"build": "yarn run -T tsx ../../scripts/build-package.ts",
|
||||||
"build-api": "yarn run -T tsx ../../scripts/build-api.ts",
|
"build-api": "yarn run -T tsx ../../scripts/build-api.ts",
|
||||||
"prepack": "yarn run -T tsx ../../scripts/prepack.ts",
|
"prepack": "yarn run -T tsx ../../scripts/prepack.ts",
|
||||||
"postpack": "../../scripts/postpack.sh",
|
"postpack": "../../scripts/postpack.sh",
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
"/* GOTCHA */": "files will include ./dist and index.d.ts by default, add any others you want to include in here",
|
"/* GOTCHA */": "files will include ./dist and index.d.ts by default, add any others you want to include in here",
|
||||||
"files": [],
|
"files": [],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build-package": "yarn run -T tsx ../../scripts/build-package.ts",
|
"build": "yarn run -T tsx ../../scripts/build-package.ts",
|
||||||
"build-api": "yarn run -T tsx ../../scripts/build-api.ts",
|
"build-api": "yarn run -T tsx ../../scripts/build-api.ts",
|
||||||
"prepack": "yarn run -T tsx ../../scripts/prepack.ts",
|
"prepack": "yarn run -T tsx ../../scripts/prepack.ts",
|
||||||
"postpack": "../../scripts/postpack.sh",
|
"postpack": "../../scripts/postpack.sh",
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "lazy inherit",
|
"test": "lazy inherit",
|
||||||
"test-coverage": "lazy inherit",
|
"test-coverage": "lazy inherit",
|
||||||
"build-package": "yarn run -T tsx ../../scripts/build-package.ts",
|
"build": "yarn run -T tsx ../../scripts/build-package.ts",
|
||||||
"build-api": "yarn run -T tsx ../../scripts/build-api.ts",
|
"build-api": "yarn run -T tsx ../../scripts/build-api.ts",
|
||||||
"prepack": "yarn run -T tsx ../../scripts/prepack.ts",
|
"prepack": "yarn run -T tsx ../../scripts/prepack.ts",
|
||||||
"postpack": "../../scripts/postpack.sh",
|
"postpack": "../../scripts/postpack.sh",
|
||||||
|
|
|
@ -33,8 +33,7 @@
|
||||||
"test-coverage": "lazy inherit",
|
"test-coverage": "lazy inherit",
|
||||||
"dev": "chokidar '../{editor,ui}/*.css' -c 'node ./scripts/copy-css-files.mjs' --initial",
|
"dev": "chokidar '../{editor,ui}/*.css' -c 'node ./scripts/copy-css-files.mjs' --initial",
|
||||||
"prebuild": "node ./scripts/copy-css-files.mjs",
|
"prebuild": "node ./scripts/copy-css-files.mjs",
|
||||||
"build": "node ./scripts/copy-css-files.mjs",
|
"build": "yarn run -T tsx ../../scripts/build-package.ts",
|
||||||
"build-package": "yarn run -T tsx ../../scripts/build-package.ts",
|
|
||||||
"build-api": "yarn run -T tsx ../../scripts/build-api.ts",
|
"build-api": "yarn run -T tsx ../../scripts/build-api.ts",
|
||||||
"prepack": "yarn run -T tsx ../../scripts/prepack.ts",
|
"prepack": "yarn run -T tsx ../../scripts/prepack.ts",
|
||||||
"postpack": "../../scripts/postpack.sh",
|
"postpack": "../../scripts/postpack.sh",
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
"new-asset": "node ./scripts/new-asset.js",
|
"new-asset": "node ./scripts/new-asset.js",
|
||||||
"index": "node ./scripts/build-index.js && yarn format",
|
"index": "node ./scripts/build-index.js && yarn format",
|
||||||
"format": "yarn run -T prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md}\"",
|
"format": "yarn run -T prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md}\"",
|
||||||
"build-package": "yarn run -T tsx ../../scripts/build-package.ts",
|
"build": "yarn run -T tsx ../../scripts/build-package.ts",
|
||||||
"build-api": "yarn run -T tsx ../../scripts/build-api.ts",
|
"build-api": "yarn run -T tsx ../../scripts/build-api.ts",
|
||||||
"prepack": "yarn run -T tsx ../../scripts/prepack.ts",
|
"prepack": "yarn run -T tsx ../../scripts/prepack.ts",
|
||||||
"postpack": "../../scripts/postpack.sh",
|
"postpack": "../../scripts/postpack.sh",
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "lazy inherit",
|
"test": "lazy inherit",
|
||||||
"test-coverage": "lazy inherit",
|
"test-coverage": "lazy inherit",
|
||||||
"build-package": "yarn run -T tsx ../../scripts/build-package.ts",
|
"build": "yarn run -T tsx ../../scripts/build-package.ts",
|
||||||
"build-api": "yarn run -T tsx ../../scripts/build-api.ts",
|
"build-api": "yarn run -T tsx ../../scripts/build-api.ts",
|
||||||
"prepack": "yarn run -T tsx ../../scripts/prepack.ts",
|
"prepack": "yarn run -T tsx ../../scripts/prepack.ts",
|
||||||
"postpack": "../../scripts/postpack.sh",
|
"postpack": "../../scripts/postpack.sh",
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "lazy inherit",
|
"test": "lazy inherit",
|
||||||
"test-coverage": "lazy inherit",
|
"test-coverage": "lazy inherit",
|
||||||
"build-package": "yarn run -T tsx ../../scripts/build-package.ts",
|
"build": "yarn run -T tsx ../../scripts/build-package.ts",
|
||||||
"build-api": "yarn run -T tsx ../../scripts/build-api.ts",
|
"build-api": "yarn run -T tsx ../../scripts/build-api.ts",
|
||||||
"prepack": "yarn run -T tsx ../../scripts/prepack.ts",
|
"prepack": "yarn run -T tsx ../../scripts/prepack.ts",
|
||||||
"postpack": "../../scripts/postpack.sh",
|
"postpack": "../../scripts/postpack.sh",
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "lazy inherit",
|
"test": "lazy inherit",
|
||||||
"test-coverage": "lazy inherit",
|
"test-coverage": "lazy inherit",
|
||||||
"build-package": "yarn run -T tsx ../../scripts/build-package.ts",
|
"build": "yarn run -T tsx ../../scripts/build-package.ts",
|
||||||
"build-api": "yarn run -T tsx ../../scripts/build-api.ts",
|
"build-api": "yarn run -T tsx ../../scripts/build-api.ts",
|
||||||
"prepack": "yarn run -T tsx ../../scripts/prepack.ts",
|
"prepack": "yarn run -T tsx ../../scripts/prepack.ts",
|
||||||
"postpack": "../../scripts/postpack.sh",
|
"postpack": "../../scripts/postpack.sh",
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "lazy inherit --passWithNoTests",
|
"test": "lazy inherit --passWithNoTests",
|
||||||
"test-coverage": "yarn run -T jest --passWithNoTests --coverage",
|
"test-coverage": "yarn run -T jest --passWithNoTests --coverage",
|
||||||
"build-package": "yarn run -T tsx ../../scripts/build-package.ts",
|
"build": "yarn run -T tsx ../../scripts/build-package.ts",
|
||||||
"build-api": "yarn run -T tsx ../../scripts/build-api.ts",
|
"build-api": "yarn run -T tsx ../../scripts/build-api.ts",
|
||||||
"prepack": "yarn run -T tsx ../../scripts/prepack.ts",
|
"prepack": "yarn run -T tsx ../../scripts/prepack.ts",
|
||||||
"postpack": "../../scripts/postpack.sh",
|
"postpack": "../../scripts/postpack.sh",
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "lazy inherit",
|
"test": "lazy inherit",
|
||||||
"test-coverage": "lazy inherit",
|
"test-coverage": "lazy inherit",
|
||||||
"build-package": "yarn run -T tsx ../../scripts/build-package.ts",
|
"build": "yarn run -T tsx ../../scripts/build-package.ts",
|
||||||
"build-api": "yarn run -T tsx ../../scripts/build-api.ts",
|
"build-api": "yarn run -T tsx ../../scripts/build-api.ts",
|
||||||
"prepack": "yarn run -T tsx ../../scripts/prepack.ts",
|
"prepack": "yarn run -T tsx ../../scripts/prepack.ts",
|
||||||
"postpack": "../../scripts/postpack.sh",
|
"postpack": "../../scripts/postpack.sh",
|
||||||
|
|
|
@ -25,7 +25,7 @@ const expectedPackageScripts = {
|
||||||
// published packages should have these scripts
|
// published packages should have these scripts
|
||||||
const expectedPublishedPackageScripts = {
|
const expectedPublishedPackageScripts = {
|
||||||
...expectedPackageScripts,
|
...expectedPackageScripts,
|
||||||
'build-package': tsScript('build-package.ts'),
|
build: tsScript('build-package.ts'),
|
||||||
'build-api': tsScript('build-api.ts'),
|
'build-api': tsScript('build-api.ts'),
|
||||||
prepack: tsScript('prepack.ts'),
|
prepack: tsScript('prepack.ts'),
|
||||||
postpack: (packageDir: string) => scriptPath(packageDir, 'postpack.sh'),
|
postpack: (packageDir: string) => scriptPath(packageDir, 'postpack.sh'),
|
||||||
|
@ -57,7 +57,7 @@ const perPackageExceptions: Record<string, Record<string, () => string | undefin
|
||||||
},
|
},
|
||||||
'@tldraw/assets': {
|
'@tldraw/assets': {
|
||||||
test: () => undefined,
|
test: () => undefined,
|
||||||
'build-package': () => undefined,
|
build: () => undefined,
|
||||||
'build-api': () => undefined,
|
'build-api': () => undefined,
|
||||||
prepack: () => undefined,
|
prepack: () => undefined,
|
||||||
postpack: () => undefined,
|
postpack: () => undefined,
|
||||||
|
|
|
@ -12,7 +12,7 @@ export async function preparePackage({ sourcePackageDir }: { sourcePackageDir: s
|
||||||
|
|
||||||
const manifest = JSON.parse(readFileSync(path.join(sourcePackageDir, 'package.json'), 'utf8'))
|
const manifest = JSON.parse(readFileSync(path.join(sourcePackageDir, 'package.json'), 'utf8'))
|
||||||
|
|
||||||
execSync('yarn run -T lazy build-package', { cwd: sourcePackageDir, stdio: 'inherit' })
|
execSync('yarn run -T lazy build', { cwd: sourcePackageDir, stdio: 'inherit' })
|
||||||
|
|
||||||
// save package.json and reinstate it in postpack
|
// save package.json and reinstate it in postpack
|
||||||
copyFileSync(
|
copyFileSync(
|
||||||
|
|
Loading…
Reference in a new issue