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

Don't run postinstall script separately from yarn install #531

Merged
merged 1 commit into from
Oct 24, 2023

Conversation

michalinacienciala
Copy link
Contributor

@michalinacienciala michalinacienciala commented Jun 6, 2023

Background:
Previously we've been running postinstall script in a separate step from the yarn install command. We've been doing that as a workaround for a problem we had with the postinstall script in the @threshold-network/solidity-contracts package (the script in that package often randomly failed). Running yarn upgrade with --ignore-scripts flag prevented the execution of postinstall script in the main project and its dependencies. And running yarn run postinstall after did execute the postinstall script in the main project.

The change:
Recently we have refactored the @threshold-network/solidity-contracts project and got rid of the problematic script. We can go back to executing yarn install without the --ignore-scripts flag.
We still need to execute yarn run postinstall in couple of places though - we need to do that after yarn upgrade commands, as yarn upgrade does not execute the postinstall scripts in the main project (and we have a script in the threshold-network/token-dashboard project that we need to execute).

Ref:
threshold-network/solidity-contracts#142
threshold-network/solidity-contracts#143
keep-network/tbtc-v2#629

Background:
Previously we've been running postinstall script in a separate step from the
`yarn install` command. We've been doing that as a workaround for a problem we
had with the postinstall script in the `@threshold-network/solidity-contracts`
package (the script in that package often randomly failed). Running `yarn
upgrade` with `--ignore-scripts` flag prevented the execution of postinstall
script in the main project and its depandencies. And running `yarn run
postinstall` after did execute the postinstall script in the main project.

The change:
Recently we have refactored the `@threshold-network/solidity-contracts` project
and got rid of the problematic script. We can go back to executing `yarn
install` without the `--ignore-scripts` flag.
We still need to execute `yarn run postinstall` in couple of places though - we
need to do that after `yarn upgrade` commands, as `yarn upgrade` does not
execute the postinstall scripts in the main project (and we have a script in the
`threshold-network/token-dashboard` project that we need to execute).
@github-actions
Copy link

github-actions bot commented Jun 6, 2023

dimpar added a commit to keep-network/tbtc-v2 that referenced this pull request Jun 9, 2023
Background:
Previously we've been running postinstall script in a separate step from
the `yarn install` command. We've been doing that as a workaround for a
problem we had with the postinstall script in the
`@threshold-network/solidity-contracts` package (the script in that
package often randomly failed). Running `yarn upgrade` with
`--ignore-scripts` flag prevented the execution of postinstall script in
the main project and its depandencies. And running `yarn run
postinstall` after did execute the postinstall script in the main
project.

The change:
Recently we have refactored the `@threshold-network/solidity-contracts`
project and got rid of the problematic script. We can go back to
executing `yarn install` without the `--ignore-scripts` flag.

Ref:
threshold-network/solidity-contracts#142
threshold-network/solidity-contracts#143
threshold-network/token-dashboard#531
@dimpar
Copy link
Contributor

dimpar commented Jun 14, 2023

Why are we removing --ignore-scripts here? The postinstall script task https://github.com/threshold-network/token-dashboard/blob/main/package.json#L79 doesn't seem to be related in any way to the changes from threshold-network/solidity-contracts#143 where we removed the prepare-dependencies.sh script. It looks to me that here the flag --ignore-scripts is set because of the chakra issues which are something different.
Having said that, I'm not sure if we should touch anything here.

@michalinacienciala
Copy link
Contributor Author

Why are we removing --ignore-scripts here? The postinstall script task https://github.com/threshold-network/token-dashboard/blob/main/package.json#L79 doesn't seem to be related in any way to the changes from threshold-network/solidity-contracts#143 where we removed the prepare-dependencies.sh script. It looks to me that here the flag --ignore-scripts is set because of the chakra issues which are something different.
Having said that, I'm not sure if we should touch anything here.

When yarn install is executed without --ignore-scripts, it by default executes the commands assigned to the postinstall script. It also executes all the postinstall scripts of the installed dependencies.
When a yarn install is run with the --ignore-scripts flag, neither the scripts from the main project nor from its dependencies are installed.
The yarn run postinstall command executes postinstall script of just the main project, not of it's dependencies.

As we have a dependency to @threshold-network/solidity-contracts set in token-dashboard, it means that we execute the postinstall script of that dependency when running yarn install. That was problematic when the installed @threshold-network/solidity-contracts had a postinstall script prepare-dependencies.sh that was sometimes randomly failing. That's why we decided to run install with the --ignore-scripts. But this would cause the postinstall script of the token-dashboard project be not executed, so we added a separate yarn run postinstall step. See 3b06a28.
Now that we removed the faulty script from the dependency and updated yarn.lock to use the lates @threshold-network/solidity-contracts package , we can go back to running installation using just yarn install --frozen-lockfile command.

And one more explanation, regarding the change removing --ignore-scripts from the yarn upgrade... command, but not removing the yarn run postinstall step afterwards: the yarn upgrade <package> command runs only the postinstall scripts of the upgraded packages, it does not run the postinstall script of the main project. So we are removing --ignore-scripts flag (as we no longer worry about executing prepare-dependencies.sh), but we still need to use yarn run postinstall to run the chakra-related script in the main project.

@dimpar
Copy link
Contributor

dimpar commented Jun 23, 2023

Ok, thanks for the explanation. It makes sense.

@dimpar dimpar enabled auto-merge June 23, 2023 13:58
@lukasz-zimnoch lukasz-zimnoch merged commit b24fdc3 into main Oct 24, 2023
@lukasz-zimnoch lukasz-zimnoch deleted the no-longer-ignore-scripts branch October 24, 2023 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
☁️ infrastructure CI, Infrastructure, Workflows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants