Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flaky build when generating Blueprint JSON schema #789

Closed
adamziel opened this issue Nov 24, 2023 · 1 comment
Closed

Flaky build when generating Blueprint JSON schema #789

adamziel opened this issue Nov 24, 2023 · 1 comment
Labels
[Type] Bug An existing feature does not function as intended [Type] Repo / Project Management

Comments

@adamziel
Copy link
Collaborator

adamziel commented Nov 24, 2023

Occasionally, a CI build fails when generating the JSON schema. I wasn't able to reproduce this problem locally.

Here's an example:

https://github.com/WordPress/wordpress-playground/actions/runs/6980311277/job/18995331724?pr=788

/home/runner/work/wordpress-playground/wordpress-playground/node_modules/ts-json-schema-generator/dist/src/SchemaGenerator.js:67
        throw new NoRootTypeError_1.NoRootTypeError(fullName);
              ^

NoRootTypeError: No root type "Blueprint" found
    at SchemaGenerator.findNamedNode (/home/runner/work/wordpress-playground/wordpress-playground/node_modules/ts-json-schema-generator/dist/src/SchemaGenerator.js:67:15)
    at SchemaGenerator.getRootNodes (/home/runner/work/wordpress-playground/wordpress-playground/node_modules/ts-json-schema-generator/dist/src/SchemaGenerator.js:43:26)
    at SchemaGenerator.createSchema (/home/runner/work/wordpress-playground/wordpress-playground/node_modules/ts-json-schema-generator/dist/src/SchemaGenerator.js:22:32)
    at file:///home/runner/work/wordpress-playground/wordpress-playground/packages/playground/blueprints/bin/generate-schema.js:17:44
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25) {
  type: 'Blueprint'
}

Most likely, there's some race condition at play and the schema generator runs before the type declarations are ready. It shouldn't be the case, since the NX schema generation task has a dependency set up as follows:

		"build:blueprint-schema": {
			"executor": "nx:run-commands",
			"options": {
				"commands": [
					"node packages/playground/blueprints/bin/generate-schema.js"
				],
				"parallel": false
			},
			"dependsOn": ["build:rollup-declarations"]
		}

However, it's still happening.

Proposed solution

Tracking the race condition might be challenging, let's start by adding a simple retry.

@adamziel adamziel added [Type] Bug An existing feature does not function as intended [Type] Repo / Project Management labels Nov 24, 2023
adamziel added a commit that referenced this issue Nov 24, 2023
Schema creation sometimes fails in CI, most likely
due to a race condition. Let's retry a few times before
giving up.

@see #789

Restart the build 10 times on this PR and confirm the schema generation
error doesn't occur.
adamziel added a commit that referenced this issue Nov 24, 2023
Schema creation sometimes fails in CI, most likely
due to a race condition. Let's retry a few times before
giving up.

@see #789

Restart the build 10 times on this PR and confirm the schema generation
error doesn't occur.
adamziel added a commit that referenced this issue Nov 24, 2023
Schema creation sometimes fails in CI, most likely due to a race
condition. Let's retry a few times before giving up.

See #789

## Testing instructions

Restart the build 7 times on this PR and confirm the schema generation
error doesn't occur.
@adamziel
Copy link
Collaborator Author

It seems like #790 and project.json changes in #801 solved this problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug An existing feature does not function as intended [Type] Repo / Project Management
Projects
None yet
Development

No branches or pull requests

1 participant