crystal-lang / install-crystal

GitHub Action: Install Crystal programming language
https://crystal-lang.github.io/install-crystal/configurator.html
MIT License
68 stars 8 forks source link

Download fails when a release is missing binary artifacts #12

Open straight-shoota opened 2 years ago

straight-shoota commented 2 years ago

When making a Crystal release, we first tag a commit and publish a release on GitHub. The build pipeline only start after that has happend, and artifacts such as the distribution packages are added as soon as the pipeline has finished. During this time frame, the release has no binary packages attached and install-crystal for latest fails because there's no package to download.

Example: https://github.com/crystal-lang/shards/runs/6133683332

Installing package dependencies
Looking for crystal-lang/crystal-lang release (latest)
sudo -n apt-get install -qy --no-install-recommends --no-upgrade -- libevent-dev libgmp-dev libpcre3-dev libssl-dev libxml2-dev libyaml-dev
Getting Crystal release (1.4.1)
Found Crystal release https://github.com/crystal-lang/crystal/releases/tag/1.4.1

Error: TypeError: Cannot read property 'url' of undefined

The time frame is not that long (it usually takes about 1 hour for the distribution packages to appear), but it's still bad to have all actions during that time. And there could always be unforseeable issues causing delays. So it's better to be safe.

A fix should be relatively easy. If there's no download available, we can circle back and try the second to last release.

straight-shoota commented 2 years ago

Hm, just checking for the number of assets is not very resilient.

https://github.com/crystal-lang/install-crystal/blob/f4525e00a2562e4675c25d29a25d138755bfe874/index.js#L295-L297

There could be some assets, but just the one we're currently looking for might be missing.

My idea would be to refactor the control flow. getLatestTag could return the list of tags and then we iterate until we find one that provides the requested artifact.