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

[Bug]: build steps are run twice during CI #671

Closed
2 tasks done
johnhooks opened this issue Nov 8, 2022 · 9 comments · Fixed by #667
Closed
2 tasks done

[Bug]: build steps are run twice during CI #671

johnhooks opened this issue Nov 8, 2022 · 9 comments · Fixed by #667
Assignees
Labels
bug Something isn't working

Comments

@johnhooks
Copy link
Contributor

johnhooks commented Nov 8, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

During local development I've notice when running yarn install it will call the prepare scripts of all the workspace packages. Is this intended behavior?

This also happens in the CI build pipeline. So babel, tsc and api-extractor are all run twice. Because they are run after yarn install and also during yarn build. What is the right way to remove this duplication?

Certain script names are special. If defined, the preinstall script is called by yarn before your package is installed. For compatibility reasons, scripts called install, postinstall, prepublish, and prepare will all be called after your package has finished installing.

^^ reference

Expected behavior

Build steps should not be duplicated in CI or local development.

Steps to reproduce

yarn install
yarn build

Version

2.0.0-alpha.9

Environment

Node.js 16.13.0

Code of Conduct

  • I agree to follow this project's Code of Conduct
@johnhooks johnhooks added the bug Something isn't working label Nov 8, 2022
@johnhooks johnhooks changed the title [Bug]: the prepare script is run when the workspace packages are installed [Bug]: build steps are run twice during CI Nov 8, 2022
@johnhooks
Copy link
Contributor Author

The prepare script is bring rerun in every CircleCI job. So to complete the whole workflow it is run 6 times unnecessary.

@sarahdayan
Copy link
Collaborator

This was initially necessary to check the types and run tests.

It's no longer necessary during tests since 2d408ca, and no longer necessary during type checks since 676b1b6.

It's still necessary to have access to the built artifacts, though, when checking the build size and when building the documentation site (for this page to exist).

The CircleCI job that tests the build size seems to be the only one that requires a build now. In this case, we might do it directly in config.yml (and just the UMD builds) instead.

Regarding the release, Ship.js takes care of building anyway, so building on prepare isn't useful.

Finally, regarding the documentation, this is taken care of not in the CI but directly on Vercel, using their GitHub integration. We could handle this by building as the first step in all website: scripts. Bonus if we can build only if necessary so we don't re-build whenever we stop and start the server locally.

What do you think?

@johnhooks
Copy link
Contributor Author

johnhooks commented Nov 11, 2022

This will need to be reconsidered if prepare is changed

.codesandbox/ci.json

{
  "buildCommand": false,
  "^": "buildCommand is false because `yarn prepare` is going to build packages anyway.",
}

@johnhooks
Copy link
Contributor Author

johnhooks commented Nov 11, 2022

Take aways

  • Removing prepare from all the package scripts would be okay.
    NOTE: I am going to add a prepare script to the currencies package to generate the currency files in PR refactor: generate currency source files #670. That would be necessary for many other steps of the workflow. (Though its a pretty quick step)

  • Having a build job in the workflow is still necessary. Though none of the jobs ,other than test_size, require it.

  • Most jobs don't need to attach the workspace, unless they need the build artifacts, like test_size

  • Building the website and examples in CircleCI isn't necessary because they are part of the ci/codesandbox and integrations with Vercel.

@johnhooks
Copy link
Contributor Author

Should the example projects have "private": true in their package.json?

They aren't published to npm and add it would disable building them in CircleCI because all the lerna commands have the --no-private flag applied.

@sarahdayan
Copy link
Collaborator

Should the example projects have "private": true in their package.json?

We can do this, yes!

@johnhooks
Copy link
Contributor Author

@sarahdayan is the test_types job necessary? The build job runs tsc and api-extractor to generate the declaration files. If there is a type error the build job will fail.

@sarahdayan
Copy link
Collaborator

@johnhooks Hmm I guess it's useful to see at a glance, in the CI, what has failed. If the test_types job is red I know immediately what the issue is, so does the person who opened a PR but doesn't have access to CircleCI.

If this happens in the build job you don't immediately know what the problem is.

Is test_types a bottleneck right now?

@johnhooks
Copy link
Contributor Author

It's just a duplication. If its helpful to you, then I'll shelve the idea. If I can figure out how to use Turbo effectively in CI, it will be a none issue because the build steps could be structured in a way to prevent a second call to tsc but still show you the error is a type issue.

sarahdayan added a commit that referenced this issue Dec 31, 2022
fixes #671

Co-authored-by: Sarah Dayan <5370675+sarahdayan@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants