Skip to content

Commit 164ab95

Browse files
committed
Test macos build workflow
1 parent 36c05e1 commit 164ab95

6 files changed

Lines changed: 136 additions & 7 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ permissions:
2121

2222
jobs:
2323
build:
24-
uses: 'openvoxproject/shared-actions/.github/workflows/build_vanagon.yml@main'
24+
uses: 'openvoxproject/shared-actions/.github/workflows/build_vanagon.yml@macos'
2525
with:
2626
ref: ${{ inputs.ref }}
2727
project_name: ${{ inputs.project_name }}

.github/workflows/macos-test.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Build MacOS
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
ref:
7+
description: 'Tag to build'
8+
required: true
9+
project_name:
10+
description: 'The vanagon project to build'
11+
required: false
12+
default: 'agent-runtime-main'
13+
platform_list:
14+
description: 'A comma-separated list of platforms to build for. Do not include spaces. If not provided, will use the default list of macOS platforms.'
15+
required: false
16+
type: string
17+
default: 'osx-15-arm64,osx-15-x86_64'
18+
19+
permissions:
20+
contents: read # minimal required permissions to clone repo
21+
22+
env:
23+
ENDPOINT_URL: ${{ secrets.S3_ENDPOINT_URL }}
24+
BUCKET_NAME: ${{ secrets.S3_ARTIFACTS_BUCKET_NAME }}
25+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
26+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
27+
# https://github.com/boto/boto3/issues/4398#issuecomment-2619946229
28+
AWS_REQUEST_CHECKSUM_CALCULATION: "WHEN_REQUIRED"
29+
AWS_RESPONSE_CHECKSUM_VALIDATION: "WHEN_REQUIRED"
30+
VANAGON_LOCATION: 'https://github.com/openvoxproject/vanagon#macos_test'
31+
32+
jobs:
33+
set-matrix:
34+
runs-on: ubuntu-latest
35+
outputs:
36+
macos_matrix: ${{ steps.set-matrix.outputs.macos_matrix }}
37+
steps:
38+
- id: set-matrix
39+
run: |
40+
default_list=(
41+
'osx-15-arm64'
42+
'osx-15-x86_64'
43+
)
44+
if [[ -n "${{ inputs.platform_list }}" ]]; then
45+
IFS=',' read -r -a platforms <<< "${{ inputs.platform_list }}"
46+
else
47+
platforms=("${default_list[@]}")
48+
fi
49+
echo "macos_matrix=$(jq --monochrome-output --compact-output --null-input '$ARGS.positional' --args -- ${platforms[@]})" >> "${GITHUB_OUTPUT}"
50+
51+
build_macos:
52+
needs: set-matrix
53+
runs-on: macos-latest
54+
timeout-minutes: 7200
55+
if: needs.set-matrix.outputs.macos_matrix != '[]'
56+
strategy:
57+
fail-fast: false
58+
matrix:
59+
platform: ${{ fromJson(needs.set-matrix.outputs.macos_matrix) }}
60+
steps:
61+
- name: Checkout code at tag
62+
uses: actions/checkout@v5
63+
with:
64+
ref: ${{ inputs.ref }}
65+
66+
- name: Set architecture variables
67+
id: arch
68+
run: |
69+
if [[ "${{ matrix.platform }}" == *"x86_64"* ]]; then
70+
echo "arch=x86_64" >> $GITHUB_OUTPUT
71+
echo "needs_brew_reinstall=true" >> $GITHUB_OUTPUT
72+
else
73+
echo "arch=arm64" >> $GITHUB_OUTPUT
74+
echo "needs_brew_reinstall=false" >> $GITHUB_OUTPUT
75+
fi
76+
77+
- name: Setup brew and Ruby (x86_64 only)
78+
if: steps.arch.outputs.needs_brew_reinstall == 'true'
79+
# We must fully uninstall the existing brew install as we need
80+
# the x86_64 version, and then we must install Ruby ourselves
81+
run: |
82+
brew list --cask | xargs -r brew uninstall --cask --force
83+
brew list --formula | xargs -r brew uninstall --force --ignore-dependencies
84+
brew autoremove
85+
sudo /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)" -- --force
86+
sudo rm -rf /opt/homebrew
87+
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
88+
arch -x86_64 /bin/bash -c 'brew install ruby@3.2'
89+
echo >> $HOME/.bash_profile
90+
echo 'eval "$(/usr/local/bin/brew shellenv)"' >> $HOME/.bash_profile
91+
echo 'GEM_PATH=/usr/local/lib/ruby/gems/3.2.0/bin' >> $HOME/.bash_profile
92+
echo 'export PATH="$GEM_PATH:/usr/local/opt/ruby@3.2/bin:$PATH"' >> $HOME/.bash_profile
93+
94+
- name: Install Ruby (arm64 only)
95+
if: steps.arch.outputs.needs_brew_reinstall == 'false'
96+
uses: ruby/setup-ruby@v1
97+
with:
98+
ruby-version: '3.2'
99+
100+
- name: test
101+
run: |
102+
echo ".bash_profile"
103+
cat ~/.bash_profile
104+
echo ".bashrc"
105+
cat ~/.bashrc
106+
arch -x86_64 /bin/bash -c 'which ruby; ruby --version; which gem; gem --version; which bundle; bundle --version; which brew; brew --version;echo $PATH'
107+
- name: Bundle install
108+
run: |
109+
arch -${{ steps.arch.outputs.arch }} /bin/bash -c 'bundle install --retry=3 && bundle update'
110+
111+
- name: Run build script
112+
run: |
113+
rm -rf output
114+
arch -${{ steps.arch.outputs.arch }} /bin/bash -c 'bundle exec rake vox:build["${{ inputs.project_name }}","${{ matrix.platform }}"]'
115+
116+
- name: Install awscli
117+
run: |
118+
arch -${{ steps.arch.outputs.arch }} /bin/bash -c 'brew install awscli'
119+
120+
- name: Upload output to S3
121+
run: arch -${{ steps.arch.outputs.arch }} /bin/bash -c 'bundle exec rake vox:upload["${{ inputs.ref }}","${{ matrix.platform }}"]'

configs/platforms/osx-15-arm64.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
plat.inherit_from_default
33

44
packages = %w[automake cmake pkg-config]
5-
plat.provision_with "su test -c '/opt/homebrew/bin/brew install #{packages.join(' ')}'"
5+
# We uninstall in case they are already installed, since GitHub Actions runners
6+
# will already have their own version and we want the homebrew core version.
7+
# We do || true so it doesn't fail if the packages don't exist. We have to do
8+
# it one by one because brew will not process the rest if one doesn't exist.
9+
packages.each do |pkg|
10+
plat.provision_with "brew uninstall #{pkg} 2>/dev/null || true && brew install #{pkg}"
11+
end
612

713
plat.output_dir File.join('apple', '15', 'PC1', 'arm64')
814
end

configs/platforms/osx-15-x86_64.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
plat.inherit_from_default
33

44
packages = %w[cmake pkg-config]
5-
plat.provision_with "sudo su test -c '/usr/local/bin/brew install #{packages.join(' ')}'"
5+
plat.provision_with "brew install #{packages.join(' ')}"
66

77
plat.output_dir File.join('apple', '15', 'PC1', 'x86_64')
88
end

configs/projects/agent-runtime-main.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
project 'agent-runtime-main' do |proj|
2-
2+
proj.version '9999-99-99-1'
33
# Set preferred component versions if they differ from defaults:
44
proj.setting :ruby_version, '3.2' # Leave the .Z out for Ruby 3.2
55
proj.setting :rubygem_highline_version, '3.0.1'

tasks/build.rake

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ namespace :vox do
1212
platform = args[:platform]
1313
os, _ver, arch = platform.match(/^(\w+)-(\w+)-(\w+)$/).captures
1414
if os == 'osx'
15-
abort "You must run this build from a #{arch} machine or shell. To do this on the current host, run 'arch -#{arch} /bin/bash'" if `uname -m`.chomp != arch
16-
abort "You must run this build with a #{arch} Ruby version. To do this on the current host, install Ruby from an #{arch} shell via 'arch -#{arch} /bin/bash'." if `ruby -v`.chomp =~ /#{arch}/
15+
shell = `uname -m`.chomp
16+
ruby = `ruby -v`.chomp
17+
abort "Detected shell arch: #{shell}. You must run this build from a #{arch} machine or shell. To do this on the current host, run 'arch -#{arch} /bin/bash'" if shell != arch
18+
abort "Detected ruby: #{ruby}. You must run this build with a #{arch} Ruby version. To do this on the current host, install Ruby from an #{arch} shell via 'arch -#{arch} /bin/bash'." unless ruby =~ /#{arch}/
1719
end
1820

1921
engine = platform =~ /^(osx|windows)-/ ? 'local' : 'docker'
20-
cmd = "bundle exec vanagon build #{project} #{platform} --engine #{engine}"
22+
cmd = "bundle exec build #{project} #{platform} --engine #{engine}"
2123

2224
FileUtils.rm_rf('C:/ProgramFiles64Folder/') if platform =~ /^windows-/
2325

0 commit comments

Comments
 (0)