Skip to content

Commit 35493f6

Browse files
committed
Support native ARM64 runners and multi-arch Docker manifests
1 parent 5bc68b3 commit 35493f6

3 files changed

Lines changed: 72 additions & 22 deletions

File tree

.github/workflows/graphs/build-test-publish.act

Lines changed: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ nodes:
106106
fi
107107

108108

109-
export CC=gcc
110-
export CXX=g++
109+
# On Linux, each arch has its own native runner, so skip non-native arch builds.
110+
111+
if [[ "$CURRENT_OS" == "linux" && "$ARCH" != "$CURRENT_ARCH" ]]; then
112+
echo "Skipping $CURRENT_OS-$ARCH build on $CURRENT_ARCH runner (native runner handles this)."
113+
exit 0
114+
fi
111115

112-
# Cgo requires a cross-compiler that is not installed on GitHub runners
113-
as of now.
114116

115-
[[ "$CURRENT_OS" == "linux" && "$ARCH" == "arm64" ]] &&
116-
CC=aarch64-linux-gnu-gcc &&
117-
CXX=aarch64-linux-gnu-g++
117+
export CC=gcc export CXX=g++
118118

119119

120120
# Download P4 API SDK for the target platform
@@ -128,7 +128,7 @@ nodes:
128128
BUILD_FLAGS="-X actionforge/actrun-cli/build.Production=true -X actionforge/actrun-cli/build.License=$LICENSE -X actionforge/actrun-cli/build.Version=$GITHUB_REF_NAME"
129129

130130
# Run Go tests if target matches the current system
131-
[[ "$CURRENT_OS" == "$CURRENT_OS" && "$ARCH" == "$CURRENT_ARCH" ]] && eval "go test -ldflags=\"$BUILD_FLAGS\" -o \"$OUTPUT_CLI\" ."
131+
[[ "$OS" == "$CURRENT_OS" && "$ARCH" == "$CURRENT_ARCH" ]] && eval "go test -ldflags=\"$BUILD_FLAGS\" -o \"$OUTPUT_CLI\" ."
132132

133133
# Determine P4 API paths and CGO flags per platform
134134
P4_INCLUDE="$(pwd)/p4api/include"
@@ -225,8 +225,6 @@ nodes:
225225
build_lib
226226

227227
run_e2e_tests
228-
229-
exit 0
230228
env: []
231229
comment: build the cli and dll
232230
- id: length-v1-nectarine-squirrel-peacock
@@ -291,8 +289,13 @@ nodes:
291289
y: 3570
292290
inputs:
293291
script: |-
294-
# check the build node script
295-
sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
292+
# Install cross-compiler only if needed (x64 runner building for arm64).
293+
# With native arm64 runners, this is typically skipped.
294+
if [[ "$CURRENT_ARCH" != "arm64" ]]; then
295+
sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
296+
else
297+
echo "Running on native arm64 runner, no cross-compiler needed."
298+
fi
296299
comment: Install a GCC/G++ version capable of cross-compiling
297300
- id: switch-platform-v1-dog-snake-ivory
298301
type: core/switch-platform@v1
@@ -734,9 +737,14 @@ nodes:
734737
y: 1430
735738
inputs:
736739
script: |
737-
echo "DEBUG publish: OS=$OS ARCH=$ARCH TARGET_TYPE=$TARGET_TYPE BUILD_DIR=$BUILD_DIR DIST_NEW=$DIST_NEW"
738740
mkdir -p "$DIST_NEW"
739741

742+
# On Linux, skip splitting for non-native arch (not built on this runner).
743+
if [[ "$OS" == "linux" && "$ARCH" != "$CURRENT_ARCH" ]]; then
744+
echo "Skipping split for $OS-$ARCH on $CURRENT_ARCH runner."
745+
exit 0
746+
fi
747+
740748

741749
if [[ "$TARGET_TYPE" == "cli" ]]; then
742750
if [[ "$OS" == "linux" || "$OS" == "macos" ]]; then
@@ -774,8 +782,12 @@ nodes:
774782
y: 1440
775783
inputs:
776784
script: |
777-
echo "DEBUG package: OS=$OS ARCH=$ARCH TARGET_TYPE=$TARGET_TYPE DIST_NEW=$DIST_NEW"
778-
ls -la "$DIST_NEW" || true
785+
# On Linux, skip extras for non-native arch (not built on this runner).
786+
if [[ "$OS" == "linux" && "$ARCH" != "$CURRENT_ARCH" ]]; then
787+
echo "Skipping extras for $OS-$ARCH on $CURRENT_ARCH runner."
788+
exit 0
789+
fi
790+
779791
if [[ "$TARGET_TYPE" == "py" ]]; then
780792
# Add Python libraries
781793
cp -r api/python/** $DIST_NEW
@@ -815,7 +827,7 @@ nodes:
815827
x: 8860
816828
y: 1060
817829
inputs:
818-
if-no-files-found: error
830+
if-no-files-found: warn
819831
compression-level: '6'
820832
retention-days: '2'
821833
- id: string-fmt-v1-orange-mulberry-octopus
@@ -1557,6 +1569,12 @@ nodes:
15571569
dst:
15581570
node: for-each-loop-v1-octopus-jellyfish-rabbit
15591571
port: exec
1572+
- src:
1573+
node: concurrent-for-each-loop-v1-kiwano-dog-gray
1574+
port: exec-completed
1575+
dst:
1576+
node: group-outputs-v1-navy-durian-violet
1577+
port: exec-lime-banana-jackfruit
15601578
- src:
15611579
node: branch-v1-lime-peacock-kiwano
15621580
port: exec-otherwise
@@ -6048,14 +6066,27 @@ nodes:
60486066
VERSION="${GITHUB_REF_NAME}"
60496067

60506068

6069+
# Determine the native platform for this runner.
6070+
6071+
if [[ "$CURRENT_ARCH" == "arm64" ]]; then
6072+
PLATFORM="linux/arm64"
6073+
else
6074+
PLATFORM="linux/amd64"
6075+
fi
6076+
6077+
60516078
docker buildx create --use
60526079

6080+
6081+
# Build and push a single-arch image tagged with the arch suffix.
6082+
# The multi-arch manifest is created by a separate workflow job
6083+
# after both Linux runners complete.
6084+
60536085
docker buildx build \
6054-
--platform linux/amd64,linux/arm64 \
6086+
--platform "$PLATFORM" \
60556087
--build-arg IMG_VERSION="$VERSION" \
60566088
--build-arg IMG_SOURCE="https://github.com/$GITHUB_REPOSITORY" \
6057-
-t "$IMAGE:$VERSION" \
6058-
-t "$IMAGE:latest" \
6089+
-t "$IMAGE:${VERSION}-${CURRENT_ARCH}" \
60596090
--push \
60606091
.
60616092
env: []

.github/workflows/workflow.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
strategy:
7474
matrix:
7575
license: [free] # add pro when ready
76-
os: [ubuntu-latest, windows-latest, macos-latest]
76+
os: [windows-latest, ubuntu-latest, ubuntu-24.04-arm, macos-latest]
7777

7878
runs-on: ${{ matrix.os }}
7979

@@ -102,4 +102,23 @@ jobs:
102102
graph-file: build-test-publish.act
103103
inputs: ${{ toJson(inputs) }}
104104
secrets: ${{ toJson(secrets) }}
105-
matrix: ${{ toJson(matrix) }}
105+
matrix: ${{ toJson(matrix) }}
106+
107+
docker-manifest:
108+
name: Create Docker Multi-Arch Manifest
109+
needs: build-test-publish
110+
if: startsWith(github.ref, 'refs/tags/') && (github.event_name == 'workflow_dispatch' || (github.event_name == 'push'))
111+
runs-on: ubuntu-latest
112+
steps:
113+
- name: Create multi-arch manifest
114+
run: |
115+
IMAGE="ghcr.io/actionforge/actrun"
116+
VERSION="${GITHUB_REF_NAME}"
117+
118+
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
119+
120+
docker buildx imagetools create \
121+
-t "$IMAGE:$VERSION" \
122+
-t "$IMAGE:latest" \
123+
"$IMAGE:${VERSION}-x64" \
124+
"$IMAGE:${VERSION}-arm64"

nodes/run@v1.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var winBashExes = []struct {
4040
{Path: "C:\\msys64\\usr\\bin\\bash.exe", Mount: ""},
4141
{Path: "C:\\cygwin64\\bin\\bash.exe", Mount: "/cygdrive"},
4242
}
43-
var bashArgs = []string{"--noprofile", "--norc", "-eo", "pipefail", "-l"}
43+
var bashArgs = []string{"--noprofile", "--norc", "-e", "-o", "pipefail"}
4444
var winBashPath string // Path to bash.exe that is valid for all run calls
4545
var winBashMount string
4646

0 commit comments

Comments
 (0)