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

ci: add github action to build for aarch64 #103

Merged
merged 1 commit 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
72 changes: 72 additions & 0 deletions .github/workflows/bazel_build_aarch64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# yamllint disable rule:line-length
---
name: Bazel
on: # yamllint disable-line rule:truthy
pull_request:
branches: ['*']

jobs:
build_aarch64:
runs-on: ubuntu-latest
container:
image: dtors/base-cpp:latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Configure Git Safe Directory
run: |
git config --global --add safe.directory $(pwd)

- name: Find affected files
id: affected_files
run: |
git fetch origin ${{ github.base_ref }} --depth=1
git diff --diff-filter=ACM --name-only origin/${{ github.base_ref }} > affected_files.txt
echo "Affected files:"
cat affected_files.txt

- name: Find affected Bazel targets
id: bazel_targets
run: |
> affected_targets.txt

while read file; do
if [[ "$file" == *.c || "$file" == *.cc || "$file" == *.cpp || "$file" == *.cxx || "$file" == *.h || "$file" == *.hpp || "$file" == *.hxx ]]; then
echo "Finding targets for: $file"
targets=$(bazelisk query --output=package "$file")/...
echo "$targets" >> affected_targets.txt
fi
done < affected_files.txt

sort -u affected_targets.txt -o affected_targets.txt
echo "Affected targets:"
cat affected_targets.txt

echo "targets=$(cat affected_targets.txt | tr -s '\n' ' ' | sed 's/^[ \t]*//;s/[ \t]*$//')" >> $GITHUB_ENV
shell: bash

- name: Setup bazel cache
if: env.targets != ''
uses: actions/cache@v4
env:
cache-name: bazel-cache
with:
path: |
~/.cache/bazelisk
~/.cache/bazel
key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.ref }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-development

- name: Build affected targets
if: env.targets != ''
run: |
echo "Building targets for aarch64: $targets"
bazelisk build $targets --platforms=//bazel/platforms:aarch64_linux
shell: bash

- name: No targets to build
if: env.targets == ''
run: echo "No affected Bazel targets found. Skipping build."
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on: # yamllint disable-line rule:truthy
branches: ['*']

jobs:
build:
build_x86:
runs-on: ubuntu-latest
container:
image: dtors/base-cpp:latest
Expand Down Expand Up @@ -63,8 +63,8 @@ jobs:
- name: Build affected targets
if: env.targets != ''
run: |
echo "Building targets: $targets"
bazelisk build $targets
echo "Building targets for x86: $targets"
bazelisk build $targets --platforms=//bazel/platforms:x86_64_linux
shell: bash

- name: No targets to build
Expand Down
Loading