agileek / hassio-addons

Some home assistant addons I manage
21 stars 5 forks source link

GitHub Action to Build libsignal for x86-64, arm64, and armv7 #47

Closed tholland15 closed 2 years ago

tholland15 commented 2 years ago

After a lot of trial and error I finally got all of this working. This is an action triggered on workflow_dispatch so it only runs when requested. Editing LIBSIGNAL_VERSION will download and compile that version for all 3 architectures.

x86_64 Nothing special here, this is compiled normally using cargo and the resulting binary is copied to the repo and committed.

arm64 & armv7 Both of these are compiled natively under their respective architectures using qemu virtualization. This avoids the cross compiling issues that this project and others were previously facing while trying to cross compile libsignal for various arm architectures. Note that in these jobs the sources of dependencies are downloaded and vendored ahead of time before we jump into qemu virtualization for two reasons:

  1. This is much more performant, as resolving and downloading dependencies and updating the cargo indexes is much faster outside of virtualization.
  2. Qemu has a bug when virtualizing 32-bit architectures on 64-bit hosts that prevents cargo from downloading any dependencies. Therefore it is impossible to simply do cargo build while virtualizing armv7.

Therefore we use cargo vendor to resolve and download all of the dependencies into the source directory before jumping into virtualization to install rust and do the compiling itself in cargo's offline mode. Finally, we copy the resulting binary and commit it.

tholland15 commented 2 years ago

I've been debugging some minor issues and I now expect this PR to be updated shortly with the binaries for arm64 and armv7 once the github action I'm currently running completes (About 90 minutes from now).

MichaelBitard commented 2 years ago

I think I've merged your PR too fast but that's ok, I have to disable signed commits and it should pass.

tholland15 commented 2 years ago

Yes it's still failing as I'm sure you saw with:

  POST git-receive-pack (chunked)
  remote: error: GH006: Protected branch update failed for refs/heads/master.        
  remote: error: 5 of 5 required status checks are expected.        
  error: failed to push some refs to 'https://github.com/agileek/hassio-addons'

Would it be better for me to make it open a PR with the new binaries on a build instead of trying to commit them directly to master? That's an easy change.

tholland15 commented 2 years ago

Just opened a new draft PR #49 that does a pull request when the binaries are built instead of trying to commit directly to master. I'm running it locally to ensure the PR is created as expected.