Scoop icon indicating copy to clipboard operation
Scoop copied to clipboard

fix(checkver) use Start-Job for manifest script to not to exit on break

Open sedlund opened this issue 2 years ago • 4 comments

Description

Change the method checkver runs manifest scripts to use Start-Job instead of Invoke-Command. When using Invoke-Command if the script calls a break the parent process will exit.

See: Do not use break outside of a loop, switch, or trap

Using break inside a pipeline break, such as a ForEach-Object script block, not only exits the pipeline, it potentially terminates the entire runspace.

Motivation and Context

Currently autoupdating is broken on all Scoop buckets that have a manifest that runs a break in the autoupdate script portion. Once one manifest is run that has issued a break the Github action will exit and the rest of the bucket will fail to update.

This change starts the manifest script as a separate job allowing the parent process to continue after the manifest script exits, and letting the github action to finish updating the buckets.

  • Closes https://github.com/ScoopInstaller/GithubActions/issues/32
  • Closes https://github.com/ScoopInstaller/Extras/issues/10596
  • Closes https://github.com/ScoopInstaller/Extras/issues/10591
  • Closes https://github.com/ScoopInstaller/Extras/issues/10592
  • Closes https://github.com/ScoopInstaller/Extras/issues/10567
  • Closes https://github.com/ScoopInstaller/Extras/issues/10594
  • Closes https://github.com/ScoopInstaller/Extras/issues/10613
  • Closes https://github.com/ScoopInstaller/Extras/issues/10622

How Has This Been Tested?

I ran the change on my copy of the current (3579b11f99c692f6b68c1ce5119b8e5d6db9f2bb) Extras repo. I have attached the output of the update here. Compare with the current log of Excavator ran during the same period:

  • https://github.com/ScoopInstaller/Extras/actions/runs/4280369231/jobs/7452054609#step:3:642

See where it fails on librewolf. That manifest issues a break command. My local bucket updated 84 manifests.

Checklist:

  • [x] I have read the Contributing Guide.
  • [x] I have ensured that I am targeting the develop branch.
  • [x] I have updated the documentation accordingly.
  • [ ] I have updated the tests accordingly.
  • [x] I have added an entry in the CHANGELOG.

sedlund avatar Feb 27 '23 09:02 sedlund

This didn't used to happen before, did something change in GitHub Actions?

/cc @niheaven

rashil2000 avatar Feb 27 '23 10:02 rashil2000

Nope, this part hasn't been changed.

niheaven avatar Feb 27 '23 14:02 niheaven

This could skip break but it omits all error message in checkver.script.

A better way is NEVER use break in checkver's script field.

niheaven avatar Feb 27 '23 17:02 niheaven

This could skip break but it omits all error message in checkver.script.

A better way is NEVER use break in checkver's script field.

I disagree. randoms should not be be able to run something in the parent namespace. security says no.

sedlund avatar Feb 27 '23 17:02 sedlund