Skip to content

Commit ea12f05

Browse files
committed
build: add support for ARM architecture
Signed-off-by: behnazh-w <[email protected]>
1 parent 6e41a3d commit ea12f05

File tree

6 files changed

+247
-96
lines changed

6 files changed

+247
-96
lines changed

.github/workflows/_build.yaml

+62-25
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2022 - 2023, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2022 - 2025, Oracle and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
33

44
# This is a trusted builder implemented as a reusable workflow that can be called by other
@@ -25,32 +25,48 @@
2525
name: Build the package
2626
on:
2727
workflow_call:
28-
outputs:
29-
artifacts-sha256:
30-
description: The hash of the artifacts
31-
value: ${{ jobs.build.outputs.artifacts-sha256 }}
3228
permissions:
3329
contents: read
3430
env:
35-
ARTIFACT_OS: ubuntu-latest # The default OS for release.
36-
ARTIFACT_PYTHON: '3.11' # The default Python version for release.
37-
PACKAGE_PATH: src/macaron # The relative Python package path to the repo.
31+
RELEASE_OS_X86_64: ubuntu-24.04 # Default OS for x86_64-compatible release artifacts.
32+
RELEASE_OS_ARM64: ubuntu-24.04-arm # Default OS for ARM64-compatible release artifacts.
33+
RELEASE_PYTHON_VERSION: '3.11' # Default Python version used for release artifacts.
34+
PACKAGE_PATH: src/macaron # The relative Python package path to the repo.
3835

3936
jobs:
4037
build:
41-
outputs:
42-
artifacts-sha256: ${{ steps.compute-hash.outputs.artifacts-sha256 }}
4338
name: Build Macaron
4439
runs-on: ${{ matrix.os }}
4540
strategy:
4641
fail-fast: false
4742
matrix:
4843
# It is recommended to pin a Runner version specifically:
4944
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
50-
os: [ubuntu-latest]
45+
os: [ubuntu-24.04, ubuntu-24.04-arm]
5146
python: ['3.11']
47+
48+
outputs:
49+
arch-env: ${{ steps.set-arch-env.outputs.arch_env }}
50+
5251
steps:
5352

53+
# Create a GitHub Actions environment variable that maps a matrix.os value to a more descriptive environment
54+
# value (e.g., ubuntu-x86-64 or ubuntu-arm64).
55+
- name: Determine architecture label
56+
id: set-arch-env
57+
shell: bash
58+
run: |
59+
if [[ "${{ matrix.os }}" == "ubuntu-24.04" ]]; then
60+
echo "arch_env=ubuntu-x86-64" >> "$GITHUB_OUTPUT"
61+
elif [[ "${{ matrix.os }}" == "ubuntu-24.04-arm" ]]; then
62+
echo "arch_env=ubuntu-arm64" >> "$GITHUB_OUTPUT"
63+
else
64+
echo "arch_env=unknown" >> "$GITHUB_OUTPUT"
65+
fi
66+
67+
- name: Test the env variable
68+
run: echo "Architecture-specific value ${{ steps.set-arch-env.outputs.arch_env }}"
69+
5470
- name: Check out repository
5571
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
5672
with:
@@ -91,24 +107,33 @@ jobs:
91107
GITHUB_TOKEN: ${{ github.token }}
92108

93109
# Generate the requirements.txt that contains the hash digests of the dependencies and
94-
# generate the SBOM using CycloneDX SBOM generator.
110+
# generate the SBOM using CyclonDX SBOM generator for the release Python version and
111+
# supported release OS targets.
95112
- name: Generate requirements.txt and SBOM
96-
if: matrix.os == env.ARTIFACT_OS && matrix.python == env.ARTIFACT_PYTHON
113+
if: >
114+
matrix.python == env.RELEASE_PYTHON_VERSION &&
115+
(matrix.os == env.RELEASE_OS_X86_64 || matrix.os == env.RELEASE_OS_ARM64)
97116
run: make requirements sbom
98117

99118
# Remove the old requirements.txt file (which includes _all_ packages) and generate a
100-
# new one for the package and its actual and required dependencies only.
119+
# new one for the package and its actual and required dependencies only. Run this step
120+
# for the release Python version and supported release OS targets only.
101121
- name: Prune packages and generate required requirements.txt
102-
if: matrix.os == env.ARTIFACT_OS && matrix.python == env.ARTIFACT_PYTHON
122+
if: >
123+
matrix.python == env.RELEASE_PYTHON_VERSION &&
124+
(matrix.os == env.RELEASE_OS_X86_64 || matrix.os == env.RELEASE_OS_ARM64)
103125
run: |
104126
rm requirements.txt
105127
make prune requirements
106128
107129
# Find the paths to the artifact files that will be included in the release, compute
108-
# the SHA digest for all the release files and encode them using Base64, and export it
109-
# from this job.
130+
# the SHA digest for all the release files and encode them using Base64, and upload it
131+
# from this job. Run this step for the release Python version and supported release
132+
# OS targets only.
110133
- name: Compute package hash
111-
if: matrix.os == env.ARTIFACT_OS && matrix.python == env.ARTIFACT_PYTHON
134+
if: >
135+
matrix.python == env.RELEASE_PYTHON_VERSION &&
136+
(matrix.os == env.RELEASE_OS_X86_64 || matrix.os == env.RELEASE_OS_ARM64)
112137
id: compute-hash
113138
shell: bash
114139
run: |
@@ -123,19 +148,32 @@ jobs:
123148
DIGEST=$(sha256sum "$TARBALL_PATH" "$WHEEL_PATH" "$REQUIREMENTS_PATH" "$SBOM_PATH" \
124149
"$SBOM_GO_PATH" "$HTML_DOCS_PATH" "$BUILD_EPOCH_PATH" | base64 -w0)
125150
echo "Digest of artifacts is $DIGEST."
126-
echo "artifacts-sha256=$DIGEST" >> "$GITHUB_OUTPUT"
151+
echo "$DIGEST" > artifacts-sha256-file-${{ steps.set-arch-env.outputs.arch_env }}
127152
128153
# For now only generate artifacts for the specified OS and Python version in env variables.
129154
# Currently reusable workflows do not support setting strategy property from the caller workflow.
130155
- name: Upload the package artifact for debugging and release
131-
if: matrix.os == env.ARTIFACT_OS && matrix.python == env.ARTIFACT_PYTHON
156+
if: >
157+
matrix.python == env.RELEASE_PYTHON_VERSION &&
158+
(matrix.os == env.RELEASE_OS_X86_64 || matrix.os == env.RELEASE_OS_ARM64)
132159
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
133160
with:
134-
name: artifact-${{ matrix.os }}-python-${{ matrix.python }}
135-
path: dist
161+
name: artifacts-${{ steps.set-arch-env.outputs.arch_env }}
162+
path: ./dist*/
136163
if-no-files-found: error
137164
retention-days: 7
138165

166+
# Run this step for the release Python version and supported release OS targets only.
167+
- name: Upload artifacts sha256
168+
if: >
169+
matrix.python == env.RELEASE_PYTHON_VERSION &&
170+
(matrix.os == env.RELEASE_OS_X86_64 || matrix.os == env.RELEASE_OS_ARM64)
171+
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
172+
with:
173+
name: artifacts-sha256-file-${{ steps.set-arch-env.outputs.arch_env }}
174+
path: artifacts-sha256-file-${{ steps.set-arch-env.outputs.arch_env }}
175+
retention-days: 7
176+
139177
# This job calls the reusable workflow _build_docker.yaml to build and test
140178
# the Docker image. Note that the built image is not pushed to ghcr.io here.
141179
build_docker_image:
@@ -145,7 +183,6 @@ jobs:
145183
packages: read
146184
uses: ./.github/workflows/_build_docker.yaml
147185
with:
148-
artifact-sha256: ${{ needs.build.outputs.artifacts-sha256 }}
149-
# TODO: use ${{ env.ARTIFACT_OS }} and ${{ env.ARTIFACT_PYTHON }}
186+
# TODO: use ${{ env.RELEASE_OS_X86_64 }}
150187
# when this issue is addressed: https://github.com/actions/runner/issues/2394.
151-
artifact-name: artifact-ubuntu-latest-python-3.11
188+
artifact-architecture: ubuntu-x86-64

.github/workflows/_build_docker.yaml

+26-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2023 - 2024, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2023 - 2025, Oracle and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
33

44
# This is a reuseable workflow to build and test the Docker image. Note that this workflow does not
@@ -10,10 +10,7 @@ name: Build and push Docker image
1010
on:
1111
workflow_call:
1212
inputs:
13-
artifact-name:
14-
required: true
15-
type: string
16-
artifact-sha256:
13+
artifact-architecture:
1714
required: true
1815
type: string
1916
permissions:
@@ -40,18 +37,36 @@ jobs:
4037
- name: Download artifact
4138
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
4239
with:
43-
name: ${{ inputs.artifact-name }}
44-
path: dist
40+
path: downloads
4541

4642
# Verify hashes by first computing hashes for the artifacts and then comparing them
4743
# against the hashes for the artifact.
4844
- name: Verify the artifact hash
49-
env:
50-
ARTIFACT_HASH: ${{ inputs.artifact-sha256 }}
5145
run: |
5246
set -euo pipefail
53-
echo "Hash of package should be $ARTIFACT_HASH."
54-
echo "$ARTIFACT_HASH" | base64 --decode | sha256sum --strict --check --status || exit 1
47+
cd downloads
48+
ARCH=${{ inputs.artifact-architecture }}
49+
HASH_DIR="artifacts-sha256-file-${ARCH}"
50+
ARTIFACT_DIR="artifacts-${ARCH}"
51+
HASH_FILE="${HASH_DIR}/artifacts-sha256-file-${ARCH}"
52+
53+
echo "Verifying artifacts for ${ARCH}"
54+
echo "Decoding expected SHA256 digest:"
55+
DECODED_HASH=$(base64 --decode "${HASH_FILE}")
56+
echo "$DECODED_HASH"
57+
58+
pushd "${ARTIFACT_DIR}"
59+
echo "$DECODED_HASH" | sha256sum --strict --check --status || {
60+
echo "Hash verification failed for ${ARCH}!"
61+
exit 1
62+
}
63+
popd
64+
65+
# Copy the target dist folder to the repo directory for the subsequent steps.
66+
cd ..
67+
cp -r "${ARTIFACT_DIR}"/dist .
68+
69+
echo "Hash verified successfully for ${ARCH}."
5570
5671
# Build the Docker image without pushing it.
5772
- name: Build the Docker image

.github/workflows/_deploy-github-pages.yaml

+26-13
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
# Copyright (c) 2023 - 2023, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2023 - 2025, Oracle and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
33

44
# This workflow deploys the documentations to GitHub Pages.
55
name: Deploy static content to Pages
66
on:
77
workflow_call:
88
inputs:
9-
artifact-name:
10-
type: string
9+
artifact-architecture:
1110
required: true
12-
description: The artifact name that contains docs content
13-
artifact-sha256:
1411
type: string
15-
required: true
16-
description: The sha of the artifact that contains docs content
12+
description: The artifact distribution that contains docs content.
1713
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
1814
permissions:
1915
contents: read
@@ -37,18 +33,35 @@ jobs:
3733
- name: Download artifact
3834
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
3935
with:
40-
name: ${{ inputs.artifact-name }}
41-
path: dist
36+
path: downloads
4237

4338
# Verify hashes by first computing hashes for the artifacts and then comparing them
4439
# against the hashes for the artifact.
4540
- name: Verify the artifact hash
46-
env:
47-
ARTIFACT_HASH: ${{ inputs.artifact-sha256 }}
4841
run: |
4942
set -euo pipefail
50-
echo "Hash of package should be $ARTIFACT_HASH."
51-
echo "$ARTIFACT_HASH" | base64 --decode | sha256sum --strict --check --status || exit 1
43+
cd downloads
44+
ARCH=${{ inputs.artifact-architecture }}
45+
HASH_DIR="artifacts-sha256-file-${ARCH}"
46+
ARTIFACT_DIR="artifacts-${ARCH}"
47+
HASH_FILE="${HASH_DIR}/artifacts-sha256-file-${ARCH}"
48+
49+
echo "Verifying artifacts for ${ARCH}"
50+
echo "Decoding expected SHA256 digest:"
51+
DECODED_HASH=$(base64 --decode "${HASH_FILE}")
52+
echo "$DECODED_HASH"
53+
54+
pushd "${ARTIFACT_DIR}"
55+
echo "$DECODED_HASH" | sha256sum --strict --check --status || {
56+
echo "Hash verification failed for ${ARCH}!"
57+
exit 1
58+
}
59+
popd
60+
61+
# Copy the target dist folder to the repo directory for the subsequent steps.
62+
cp -r "${ARTIFACT_DIR}"/dist ../
63+
64+
echo "Hash verified successfully for ${ARCH}."
5265
5366
# Prepare the docs content.
5467
- name: Prepare docs for release

.github/workflows/pr-change-set.yaml

+45-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2022 - 2023, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2022 - 2025, Oracle and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
33

44
# This workflow checks and tests the package code, builds all package
@@ -23,3 +23,47 @@ jobs:
2323
permissions:
2424
contents: read
2525
packages: read
26+
27+
verify_artifacts:
28+
needs: [build]
29+
name: Verify artifacts
30+
runs-on: ubuntu-latest
31+
permissions:
32+
contents: read
33+
34+
steps:
35+
36+
# Download all uploaded artifacts in the build job into the 'downloads' directory.
37+
# This includes built package distributions and SHA256 hash files from some matrix jobs.
38+
# The `path` input ensures all artifacts are placed under the 'downloads/' folder while
39+
# maintaining their respective artifact subdirectory structure.
40+
- name: Download artifact
41+
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
42+
with:
43+
path: downloads
44+
45+
# Verify hashes by first computing hashes for the artifacts and then comparing them
46+
# against the hashes computed by the build job.
47+
- name: Verify the artifact hash
48+
run: |
49+
set -euo pipefail
50+
cd downloads
51+
for ARCH in "ubuntu-x86-64" "ubuntu-arm64"; do
52+
HASH_DIR="artifacts-sha256-file-${ARCH}"
53+
ARTIFACT_DIR="artifacts-${ARCH}"
54+
HASH_FILE="${HASH_DIR}/artifacts-sha256-file-${ARCH}"
55+
56+
echo "Verifying artifacts for ${ARCH}"
57+
echo "Decoding expected SHA256 digest:"
58+
DECODED_HASH=$(base64 --decode "${HASH_FILE}")
59+
echo "$DECODED_HASH"
60+
61+
pushd "${ARTIFACT_DIR}"
62+
echo "$DECODED_HASH" | sha256sum --strict --check --status || {
63+
echo "Hash verification failed for ${ARCH}!"
64+
exit 1
65+
}
66+
popd
67+
68+
echo "Hash verified successfully for ${ARCH}"
69+
done

.github/workflows/release.yaml

+27-11
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ on:
1313
permissions:
1414
contents: read
1515
env:
16-
ARTIFACT_NAME: artifact-ubuntu-latest-python-3.11
1716
# This is the username and email for the user who commits and pushes the release
1817
# commit. In an organisation that should be a dedicated devops account.
1918
USER_NAME: behnazh-w
@@ -133,18 +132,36 @@ jobs:
133132
- name: Download artifact
134133
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
135134
with:
136-
name: ${{ env.ARTIFACT_NAME }}
137-
path: dist
135+
path: downloads
138136

139137
# Verify hashes by first computing hashes for the artifacts and then comparing them
140138
# against the hashes computed by the build job.
141139
- name: Verify the artifact hash
142-
env:
143-
ARTIFACT_HASH: ${{ needs.build.outputs.artifacts-sha256 }}
144140
run: |
145141
set -euo pipefail
146-
echo "Hash of package should be $ARTIFACT_HASH."
147-
echo "$ARTIFACT_HASH" | base64 --decode | sha256sum --strict --check --status || exit 1
142+
cd downloads
143+
for ARCH in "ubuntu-x86-64" "ubuntu-arm64"; do
144+
HASH_DIR="artifacts-sha256-file-${ARCH}"
145+
ARTIFACT_DIR="artifacts-${ARCH}"
146+
HASH_FILE="${HASH_DIR}/artifacts-sha256-file-${ARCH}"
147+
148+
echo "Verifying artifacts for ${ARCH}"
149+
echo "Decoding expected SHA256 digest:"
150+
DECODED_HASH=$(base64 --decode "${HASH_FILE}")
151+
echo "$DECODED_HASH"
152+
153+
pushd "${ARTIFACT_DIR}"
154+
echo "$DECODED_HASH" | sha256sum --strict --check --status || {
155+
echo "Hash verification failed for ${ARCH}!"
156+
exit 1
157+
}
158+
popd
159+
160+
# Copy the target dist folder to the repo directory for the subsequent steps.
161+
cp -r "${ARTIFACT_DIR}"/dist ../
162+
163+
echo "Hash verified successfully for ${ARCH}"
164+
done
148165
149166
# Log in to ghcr.io to push the Docker image.
150167
- name: Log in to GitHub Container Registry
@@ -329,10 +346,9 @@ jobs:
329346
pages: write
330347
id-token: write
331348
with:
332-
# TODO: use ${{ env.ARTIFACT_NAME }} when this issue is addressed:
333-
# https://github.com/actions/runner/issues/2394.
334-
artifact-name: artifact-ubuntu-latest-python-3.11
335-
artifact-sha256: ${{ needs.build.outputs.artifacts-sha256 }}
349+
# TODO: use ${{ env.RELEASE_OS_X86_64 }}
350+
# when this issue is addressed: https://github.com/actions/runner/issues/2394.
351+
artifact-architecture: ubuntu-x86-64
336352

337353
# Send out release notifications after the Release was published on GitHub.
338354
# Uncomment the `if` to disable sending release notifications.

0 commit comments

Comments
 (0)