Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move ARM build to Github Actions #3847

Closed
wants to merge 11 commits into from

Conversation

gaborznagy
Copy link
Collaborator

As we focus more on GitHub Actions, we could use a github-action for testing builds on ARM instead of Travis CI.
The github-action: https://github.com/uraimo/run-on-arch-action
It is using Docker + QEMU on Linux and it can build on armv7 and ppc64le too.

This PR migrates the current Travis config to the run-on-arch github-action.

Notes:

  • contrary to Travis CI it's not a native ARM runner though, it uses QEMU,
  • build time is slow: even after putting dependency installation (including locally-built ones),
    syslog-ng build is still around 27 minutes (Github runners have 2-core CPUs, but it was slow on my 4-core i7 CPU too)
  • it requires a docker image to be built first, in order to run the commands itself.
    We can cache the docker images in the Github Packages (similarly to dbld images).
    image name is: run-on-arch-${GITHUB_REPOSITORY}-${GITHUB_WORKFLOW}-${arch}-${distro}
    The image is used as a cache for later runs, so any change in the image (e.g. new dependency), will trigger the docker build.

Alternative github-action:

  • https://github.com/pguyot/arm-runner-action
    Similarly it can run ARM binaries with QEMU.
    Not docker-based, it uses a chroot environment and an image of the given distribution.
    It also creates an image that can be used on Raspberry PI.
    Currently it is limited to Raspberry PI.

Some example runs: https://github.com/gaborznagy/syslog-ng/actions/workflows/run-on-arm.yml

TODO:

  • fix pip install (warnings about install path)

This is just an interesting idea, unfortunately the runtime is long. The PR is open to discussions. :)

@kira-syslogng
Copy link
Contributor

Build SUCCESS

@kira-syslogng
Copy link
Contributor

Build FAILURE

Copy link
Collaborator

@Kokan Kokan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm
some additiona notes:

git clone https://github.com/Snaipe/Criterion.git -b v2.3.3
cd Criterion
git submodule update --init
cd /tmp && wget https://github.com/Snaipe/Criterion/releases/download/v2.3.3/criterion-v2.3.3.tar.bz2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: that script from dbld could be used here directly

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the benefit of it: logic is not copied, if new Criterion is released it would available instantly, though it would require some changes to dbld: the scripts are expected to run inside the container: e.g. this is in dbld/builddeps:

. /dbld/functions.sh

mkdir build
cd build
cmake -DCMAKE_C_FLAGS=-Werror -DPYTHON_VERSION=3 -DCMAKE_INSTALL_PREFIX=$HOME/install/syslog-ng ..
make --keep-going -j $(nproc) all install
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: we do not really required to do install, you can just skip that (some time can be spared there)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, I'll check it.

@kira-syslogng
Copy link
Contributor

Build FAILURE

@MrAnno
Copy link
Collaborator

MrAnno commented Nov 26, 2021

I think it should not be optional. ARM is a famous architecture, which is worth supporting/testing in the CI. We have also found general hard-to-catch bugs using an ARM32/64 environment. (Also, Travis was not configured with allow_failures either, we took that job seriously as far as I know.)

@gaborznagy
Copy link
Collaborator Author

lgtm some additiona notes:

For security reasons pull requests don't get write-access to the base repository.

With the exception of GITHUB_TOKEN, secrets are not passed to the runner when a workflow is triggered from a forked repository. The permissions for the GITHUB_TOKEN in forked repositories is read-only.

https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#pull_request

You can check my fork to see how caching works, here is a workflow that uses the cached image:
https://github.com/gaborznagy/syslog-ng/runs/4347340237?check_suite_focus=true
In case the run: option is changed, the image is not rebuilt:
https://github.com/gaborznagy/syslog-ng/runs/4351319125?check_suite_focus=true
Here is a test for image rebuild:
https://github.com/gaborznagy/syslog-ng/runs/4301298441?check_suite_focus=true

Image is rebuilt if the install option is changed (hence the docker image is changed too). In general, docker image rebuild is decided by docker build --cache-from=<image>.
Dockerfiles in run-on-arch github action consists of 3 lines, here is the Dockerfile for arch:aarch64, distro:bullseye:

FROM arm64v8/debian:bullseye    
    
COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh    
RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh    

@gaborznagy
Copy link
Collaborator Author

Gabor Nagy added 11 commits December 3, 2021 10:17
As we focus more on GitHub Actions, for testing builds on ARM
we could use a github-action that's using Docker + QEMU on Linux,
instead of Travis CI.
See: github-action: https://github.com/uraimo/run-on-arch-action

This patch migrates the current Travis config to the run-on-arch github-action.
Following patches make it functional (some packages that are pre-installed in Travis has to be installed),
and extend it.

Notes:
 - It's not a native ARM runner though, it uses QEMU
 - Build time is slow: even after putting dependency installation (including locally-built ones),
   syslog-ng build is still around 27 minutes (Github runners have 2-core CPUs, but it was slow on my 4-core i7 CPU too)
 - It requires a docker image to be built first, in order to run.
   We can cache the docker images in the Github Packages (similarly to dbld images)

Alternative github-action:
 - https://github.com/pguyot/arm-runner-action
    Similarly it can run ARM-based binaries with QEMU.
    Not docker-based, it uses a chroot environment and an image of the given distribution.
    It also creates an image that can be used on Raspberry PI.
    Currently it is limited to Raspberry PI.

Signed-off-by: Gabor Nagy <gabor.nagy@oneidentity.com>
Signed-off-by: Gabor Nagy <gabor.nagy@oneidentity.com>
With this change only I saw a ~70 minutes runtime changing to ~47 minutes.
This would significantly improve the running time once only syslog-ng will be built during runtime:
from around ~47 minutes to ~ 25 minutes.

Image name it not entirely configurable, it looks like this:
"run-on-arch-${GITHUB_REPOSITORY}-${GITHUB_WORKFLOW}-${arch}-${distro}"
E.g.
`run-on-arch-gaborznagy-syslog-ng-arm-docker-aarch64-bullseye
`

Signed-off-by: Gabor Nagy <gabor.nagy@oneidentity.com>
run-on-arch doesn't support Debian Testing (yet)

https://github.com/uraimo/run-on-arch-action

Signed-off-by: Gabor Nagy <gabor.nagy@oneidentity.com>
Travis provided several build-tools by-default.
On docker we have to install these manually.

Also, enable additional modules by installing their dependencies
(e.g. libpaho-mqtt-c).

Signed-off-by: Gabor Nagy <gabor.nagy@oneidentity.com>
This way we don't have to fetch criterion's submodules
This is how we build criterion in dbld too.

Also remove sudo usage, and build criterion under /tmp/

Signed-off-by: Gabor Nagy <gabor.nagy@oneidentity.com>
Also remove usage of sudo.

Signed-off-by: Gabor Nagy <gabor.nagy@oneidentity.com>
Signed-off-by: Gabor Nagy <gabor.nagy@oneidentity.com>
…age build

Since they have to be updated manually,
we can build and install them during image build to save significant time.

- bison build time is around 16 minutes 30 seconds
- criterion build time is 5 minutes 30 seconds
(syslog-ng build time is around 20 minutes)

Signed-off-by: Gabor Nagy <gabor.nagy@oneidentity.com>
Signed-off-by: Gabor Nagy <gabor.nagy@oneidentity.com>
Signed-off-by: Gabor Nagy <gabor.nagy@oneidentity.com>
@gaborznagy
Copy link
Collaborator Author

@kira-syslogng retest this please;

@kira-syslogng
Copy link
Contributor

Build SUCCESS

@alltilla
Copy link
Collaborator

There were some improvements around ARM runners by GitHub: https://resources.github.com/devops/actions/arm-virtual-hardware/

Haven't read it thoroughly, but we could take a look.

@gaborznagy
Copy link
Collaborator Author

There were some improvements around ARM runners by GitHub: https://resources.github.com/devops/actions/arm-virtual-hardware/

Haven't read it thoroughly, but we could take a look.

Thanks for the info. It still looks like it requires AWS.
I'll check it out during the weekend in more detail. And the alternatives too, just for fun (like Cirrus CI). :)

@alltilla
Copy link
Collaborator

One thing to consider, is that we already use AWS for Kira, maybe we can utilize that.

@n-rodriguez
Copy link

Hi there! Any news?

@bazsi
Copy link
Collaborator

bazsi commented Apr 7, 2023 via email

@alltilla
Copy link
Collaborator

alltilla commented Feb 5, 2024

@bazsi @MrAnno In the light of the AxoSyslog arm images, do we want to keep this PR open? I know that we don't have a per PR arm build, but it seems good enough to find errors there in the nightly builds.

@MrAnno
Copy link
Collaborator

MrAnno commented Feb 5, 2024

We need something that runs per-PR on ARM.
I don't have a strong opinion about the details of this anymore, anything running under 25 minutes is okay for me.

We can close this PR and open an issue instead, if that's convenient for you.

@czanik
Copy link
Contributor

czanik commented Feb 5, 2024

Testing ARM should be a lot faster now, as instead of emulation, it runs now on Ampere servers. At least my Twitter feed was loud about it a few weeks ago.

@MrAnno
Copy link
Collaborator

MrAnno commented Feb 12, 2024

@HofiOne
Copy link
Collaborator

HofiOne commented Feb 16, 2024

Also, a bit out of topic, but still "aarch64":

https://github.blog/2023-10-02-introducing-the-new-apple-silicon-powered-m1-macos-larger-runner-for-github-actions/

i could sware that i checked this multiple times at that time and did not yet work for none large or xlarge targets, thanks for pointing this out again!

#4833

@MrAnno
Copy link
Collaborator

MrAnno commented May 17, 2024

I'll revisit this topic and add an ARM-based workflow for running our tests, so let's close this one for now.

@MrAnno MrAnno closed this May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants