canonical / action-build

A Github action for building Snapcraft projects
MIT License
42 stars 22 forks source link

Fail action when the build fails to produce the exact number of snaps requested #67

Open Hook25 opened 11 months ago

Hook25 commented 11 months ago

Description

In checkbox we use this action to trigger remote builds via snapcraft. Right now we don't get any failure out of it even when it actually should fail because as long as at least one snap is produced the action will pass (Snapcraft never returns 1 due toremote-build failing). This is a problem in general, but specifically right now we are dealing with some flaky builds and we are unable to retry them because we have no way of knowing if snapcraft failed or not.

This introduces a new check after a build is done, comparing the amount of requested artifacts (namely: 1 for any build that does not include a --build-(on|for)) against the number that is actually produced. If the two differ, an error is raised

Testing

This introduces two new tests (and fixes the text for 0 snaps), to test that a mismatch between requested and produced always fails. I have tested this contribution via npm test and npm run all

jhenstridge commented 11 months ago

As the description of the input mentions, snapcraft-args was intended to let a snap opt into experimental features:

https://github.com/snapcore/action-build/blob/96195148af52105f8a203a3abe867c8aea0eea79/action.yml#L31-L38

It is not intended to let you run arbitrary snapcraft commands, and doing so is an unsupported configuration. Given that most of the code in this action deals with wrangling the build environment to get LXD working (which isn't needed by snapcraft remote-build), you might be better off not using the action at all.

If you just want snapcraft available for your job, you can run sudo snap install --classic snapcraft in a step.