My snapcraft CI started failing (PPA-dependency?)

Hello,

I had an Ubuntu-18.04 CI lane building snaps without issues, until suddenly it started failing with this error:

Err:21 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 libxml2-utils amd64 2.9.10+dfsg-2+ubuntu18.04.1+deb.sury.org+1

[3862](https://github.com/nblockchain/geewallet/runs/660590328#step:3:3862) 404 Not Found [IP: 91.189.95.83 80]

[3863](https://github.com/nblockchain/geewallet/runs/660590328#step:3:3863)Fetched 3532 kB in 0s (14.5 MB/s)

[3864](https://github.com/nblockchain/geewallet/runs/660590328#step:3:3864)E: Failed to fetch http://ppa.launchpad.net/ondrej/php/ubuntu/pool/main/libx/libxml2/libxml2-utils_2.9.10+dfsg-2+ubuntu18.04.1+deb.sury.org+1_amd64.deb 404 Not Found [IP: 91.189.95.83 80]

The attempt to install this package is not actually done by my script, but by the snapcraft command itself. Why does snapcraft depend on some PPA that might stop existing?

Full log for the failed build: https://github.com/nblockchain/geewallet/runs/660590328
Full log for the previous build that worked: https://github.com/nblockchain/geewallet/runs/509098168

That PPA seems to be coming from the GitHub Actions base image: https://github.com/actions/virtual-environments/blob/ubuntu18/20200406.2/images/linux/Ubuntu1804-README.md mentions “PHP 7.1 (PHP 7.1.33-14+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Mar 20 2020 13:57:43) ( NTS ))”. So their image is called “ubuntu18” but also includes a bunch of non-Ubuntu things, which is a bit confusing.

Given the specific error and the fact that the libxml2 was last updated in that PPA on 2020-05-06, it looks like apt update hasn’t been run inside that image for more than a week. Launchpad assumes that apt update is run on at least the daily cycle that Ubuntu defaults to, so it removes old packages after a day or two. This is arguably something that GitHub should do, but you can also probably work around it by ensuring apt update is run before snapcraft.

But do be aware that, as described above, the GitHub images seem to be quite dirty and won’t necessarily generate the result that you expect.

The root cause is likely that you’ve missed an apt-get update call in your workflow. The GH Actions runners are spun up from an image that could be weeks old with a stale apt package list. In this case, a PPA configured in the image published out a new libxml2 package, causing the old version to become unpublished. An apt-get update call would let it find the new package. Note that this problem isn’t specific to PPAs: I’ve seen it happen for cases where the package list for the official bionic-updates repo was out of date.

If you want to build and publish snaps more easily from a Github Actions workflow, perhaps consider using the snapcore/action-build@v1 and snapcore/action-publish@v1 actions?

The build action uses LXD to build your snap, so avoids some of the weirdness present in Github’s VM images. To get the most out of it, you’d probably need to update your snapcraft.yaml file a bit to have the software build run by Snapcraft though. At present, it looks like you’re relying on assets built before running Snapcraft.

Thanks guys, it seems in fact that a simple apt update at the beginning of the CI recipe fixed it.

Thanks for the suggestion about using snapcore actions, but actually I’d prefer to move out from GithubCI to use GitLabCI (but I got a problem with the latter that hopefully I’ll fix soon, with the help of this forum… I’ll open another thread for that).