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

new(ci): leverage github hosted arm64 runner to test and release for arm64 too #11

Merged
merged 3 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ concurrency:

jobs:
build-and-test:
name: build-and-test-${{ matrix.arch }}
# ubuntu24.04 for podman >= 4.x
runs-on: 'ubuntu-24.04'
runs-on: ${{ (matrix.arch == 'arm64' && 'ubuntu-24.04-arm') || 'ubuntu-24.04' }}
strategy:
fail-fast: false
matrix:
arch: [ amd64, arm64 ]
steps:
# Needed by vcpkg caching
- name: Export GitHub Actions cache environment variables
Expand Down Expand Up @@ -52,7 +57,11 @@ jobs:
- name: Build go-worker executable
run: make -C go-worker exe

- name: Run tests
# Podman is not shipped by beta github arm64 runners:
# https://github.com/actions/partner-runner-images/blob/main/images/arm-ubuntu-22-image.md#not-installed-software
# Building tests fail with: "faccessat /home/runneradmin/.config/containers/storage.conf: permission denied"
- name: Run tests (x64 only)
if: matrix.arch == 'amd64'
run: |
systemctl --user start podman
make test
make test
40 changes: 37 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ permissions:

jobs:
build:
runs-on: 'ubuntu-20.04'
runs-on: ${{ (matrix.arch == 'arm64' && 'ubuntu-22.04-arm') || 'ubuntu-22.04' }}
strategy:
fail-fast: false
matrix:
arch: [ amd64, arm64 ]
container:
image: ubuntu:20.04
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -23,7 +29,7 @@ jobs:

# Needed by containerd go package - build time dep, no runtime.
- name: Install plugin deps
run: sudo apt-get install -y --no-install-recommends libbtrfs-dev
run: apt-get update && apt-get install -y --no-install-recommends libbtrfs-dev

- name: Setup Go
uses: actions/setup-go@v5
Expand All @@ -33,7 +39,35 @@ jobs:
- name: Build plugin library
run: make libcontainer.so

- name: Upload artifact
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: libcontainer-${{ matrix.arch }}
path: 'libcontainer.so'

release:
needs: [build]
runs-on: 'ubuntu-latest'
steps:
- name: Download amd64 plugin
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: libcontainer-amd64

- name: Rename amd64 library
run: mv libcontainer.so libcontainer_amd64.so

- name: Download arm64 plugin
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: libcontainer-arm64

- name: Rename amd64 library
run: mv libcontainer.so libcontainer_arm64.so

- name: Release
uses: softprops/action-gh-release@v2
with:
files: libcontainer.so
files: |
libcontainer_amd64.so
libcontainer_arm64.so
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ endif()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")

# From now on, we have VCPKG_ARCH variable
include(arch)

# compiler related configs
include(compiler)

Expand Down
18 changes: 18 additions & 0 deletions cmake/modules/arch.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
execute_process(
COMMAND uname -m
COMMAND sed "s/x86_64/x64/"
COMMAND sed "s/aarch64/arm64/"
OUTPUT_VARIABLE ARCH_output
ERROR_VARIABLE ARCH_error
RESULT_VARIABLE ARCH_result
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(${ARCH_result} EQUAL 0)
set(VCPKG_ARCH ${ARCH_output})
message(STATUS "Target arch: ${VCPKG_ARCH}")
else()
message(
FATAL_ERROR
"Failed to determine target architecture: ${ARCH_error}"
)
endif()
2 changes: 1 addition & 1 deletion cmake/modules/go-worker.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pkg_check_modules(GPGME REQUIRED gpgme IMPORTED_TARGET)

# Pkg config paths to all gpgme libs (libgpgme, libgpg-error and libassuan)
# to be passed down to go-worker to let it find the needed deps.
set(VCPKG_PKGCONFIG_PATH "${CMAKE_SOURCE_DIR}/vcpkg/packages/gpgme_x64-linux-release/lib/pkgconfig/:${CMAKE_SOURCE_DIR}/vcpkg/packages/libgpg-error_x64-linux-release/lib/pkgconfig/:${CMAKE_SOURCE_DIR}/vcpkg/packages/libassuan_x64-linux-release/lib/pkgconfig/")
set(VCPKG_PKGCONFIG_PATH "${CMAKE_SOURCE_DIR}/vcpkg/packages/gpgme_${VCPKG_ARCH}-linux-release/lib/pkgconfig/:${CMAKE_SOURCE_DIR}/vcpkg/packages/libgpg-error_${VCPKG_ARCH}-linux-release/lib/pkgconfig/:${CMAKE_SOURCE_DIR}/vcpkg/packages/libassuan_${VCPKG_ARCH}-linux-release/lib/pkgconfig/")

ExternalProject_Add(go-worker
DEPENDS PkgConfig::GPGME
Expand Down
21 changes: 1 addition & 20 deletions cmake/modules/vcpkg.cmake
Original file line number Diff line number Diff line change
@@ -1,21 +1,2 @@
execute_process(
COMMAND uname -m
COMMAND sed "s/x86_64/x64/"
COMMAND sed "s/aarch64/arm64/"
OUTPUT_VARIABLE ARCH_output
ERROR_VARIABLE ARCH_error
RESULT_VARIABLE ARCH_result
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(${ARCH_result} EQUAL 0)
set(ARCH ${ARCH_output})
message(STATUS "Target arch: ${ARCH}")
else()
message(
FATAL_ERROR
"Failed to determine target architecture: ${ARCH_error}"
)
endif()

set(VCPKG_TARGET_TRIPLET "${ARCH}-linux-release")
set(VCPKG_TARGET_TRIPLET "${VCPKG_ARCH}-linux-release")
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake CACHE STRING "Vcpkg toolchain file")