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

postupdate script #305

Closed
Blacksmoke16 opened this issue Nov 13, 2019 · 5 comments
Closed

postupdate script #305

Blacksmoke16 opened this issue Nov 13, 2019 · 5 comments

Comments

@Blacksmoke16
Copy link
Member

Currently the postinstall script is ran for both install and update. I propose to only run postinstall on install and introduce a postupdate script to only run on update.

Use case would be preventing something you only need to run once on install from running every time a shard is updated.

@Blacksmoke16 Blacksmoke16 changed the title postupdate update postupdate script Nov 13, 2019
@straight-shoota
Copy link
Member

I don't think that makes much sense. If the behaviour of install changes between versions, you would need to reflect that in an update script. And that can be highly complex when switching forth and back between versions or concurrent branches. Going from one version to another is not always linear.

IMO it's just easier to have a single script that makes sure the final state is what the shard expects. This gives you all the power to do whatever necessary. You should strive for idempotency, not for separate instructions.

@Blacksmoke16
Copy link
Member Author

Blacksmoke16 commented Nov 13, 2019

I was more so thinking of this for like private shards used within a closed-source project. I.e. that may run internal build processes, such as creating rabbitMQ queues for example; things that should happen once on an env when installing the app. Then there are things that should happen when updating a dependency, like writing parameter files based on the current env.

Currently there isn't really a nice way to handle this within Crystal/shards itself.

EDIT: On a related note, it would be nice if it supported an array of commands that it should run:

postinstall:
  - cmd 1
  - cmd 2
  - ..

@jhass
Copy link
Member

jhass commented Nov 14, 2019

So you think to have your install script be idempotent, that is examining the current environment and only doing necessary changes, is too much to ask?

@ysbaddaden
Copy link
Contributor

From the point of view of Shards, there are no updates, only installs. The only update is to build a new lockfile of shards that will be installed. When installing, if the folder exists it's deleted then the shard is installed and the postinstall script is eventually run (when all shards have been installed).

I think the postinstall script must be idempotent. Whatever if the shard was previously installed, whatever version of it was previously installed. You can never assume a previous state.

My worry with a postupdate script is that we either dont prevent postinstall to run, making postupdate pointless, or require every shard to also have a postupdate... that is identical to postinstall, which is just as pointless :-(

@ysbaddaden
Copy link
Contributor

I believe that's the whole reason only the postinstall script was added. We only ever install a shard, and whatever the previous version did, it must be usually redone ror the new version, and it doesn't hurt (e.g. build a binary, install some script to the dependent project, ...). If it does hurt, then the script must check whether something was done or not before doing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants