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

Update MacOS runner to Ventura, add MacOS Sonoma (M1) runner #4393

Merged
merged 5 commits into from
Feb 29, 2024
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
61 changes: 53 additions & 8 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ concurrency:
jobs:
# Build with gcc and test p4c on Ubuntu 22.04.
test-ubuntu22:
strategy:
fail-fast: false
runs-on: ubuntu-22.04
env:
CTEST_PARALLEL_LEVEL: 4
Expand Down Expand Up @@ -79,8 +77,6 @@ jobs:

# Build and test p4c on Fedora.
test-fedora-linux:
strategy:
fail-fast: false
# This job runs in Fedora container that runs in Ubuntu VM.
runs-on: ubuntu-latest
container:
Expand Down Expand Up @@ -116,11 +112,51 @@ jobs:
run: sudo -E ctest --output-on-failure --schedule-random
working-directory: ./build

# Build and test p4c on MacOS 12
# Build and test p4c on MacOS for M1 Macs.
test-mac-os-m1:
runs-on: macos-14
env:
CTEST_PARALLEL_LEVEL: 4
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: test-${{ runner.os }}
max-size: 1000M

- name: Cache Homebrew Packages
id: cache-homebrew-packages
uses: actions/cache@v4
env:
cache-name: homebrew-packages
with:
path: $(brew --prefix)
key: ${{ runner.os }}-${{ hashFiles('tools/install_mac_deps.sh') }}

- name: Install dependencies (MacOS)
fruffy marked this conversation as resolved.
Show resolved Hide resolved
run: |
tools/install_mac_deps.sh

- name: Build (MacOS)
run: |
source ~/.bash_profile
./bootstrap.sh -DENABLE_GC=ON -DCMAKE_BUILD_TYPE=RELEASE \
-DCMAKE_UNITY_BUILD=ON
make -Cbuild -j$((`nproc`+1))

- name: Run tests (MacOS)
run: |
source ~/.bash_profile
ctest --output-on-failure --schedule-random -LE "bpf|ubpf"
working-directory: ./build

# Build and test p4c on MacOS 13 on x86.
test-mac-os:
strategy:
fail-fast: false
runs-on: macos-12
runs-on: macos-13
env:
CTEST_PARALLEL_LEVEL: 4
steps:
Expand All @@ -134,6 +170,15 @@ jobs:
key: test-${{ runner.os }}
max-size: 1000M

- name: Cache Homebrew Packages
id: cache-homebrew-packages
uses: actions/cache@v4
env:
cache-name: homebrew-packages
with:
path: $(brew --prefix)
key: ${{ runner.os }}-${{ hashFiles('tools/install_mac_deps.sh') }}

- name: Install dependencies (MacOS)
run: |
tools/install_mac_deps.sh
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ clang-format==15.0.6
black==22.3.0
isort==5.10.0
protobuf==3.20.2; python_version > '3.6'
grpcio==1.51.1; python_version > '3.6'
grpcio==1.59.3; python_version > '3.6'
googleapis-common-protos==1.53.0; python_version > '3.6'
# Ubuntu 18.04 uses Python 3.6, which is not supported by recent versions of Protobuf.
protobuf==3.19.2; python_version <= '3.6'
Expand Down
77 changes: 53 additions & 24 deletions tools/install_mac_deps.sh
Original file line number Diff line number Diff line change
@@ -1,34 +1,63 @@
#! /bin/bash

# Script for building P4C on MacOS.
# Script to install P4C dependencies on MacOS.

set -e # Exit on error.
set -x # Make command execution verbose

# Install some custom requirements on OS X using brew
BREW=/usr/local/bin/brew
if [[ ! -x $BREW ]]; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Installation helper.
brew_install() {
echo "\nInstalling $1"
if brew list $1 &>/dev/null; then
echo "${1} is already installed"
else
brew install $1 && echo "$1 is installed"
fi
}

# Check if brew shellenv command is already in zprofile.
if ! grep -q 'brew shellenv' ~/.zprofile; then
# Set up Homebrew differently for arm64.
if [[ $(uname -m) == 'arm64' ]]; then
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
else
(echo; echo 'eval "$(/usr/local/bin/brew shellenv)"') >> ~/.zprofile
eval "$(/usr/local/bin/brew shellenv)"
fi
fi
# Source zprofile.
source ~/.zprofile

BOOST_LIB="boost@1.76"

$BREW install autoconf automake bdw-gc ccache cmake \
libtool openssl pkg-config python coreutils
# Check if Homebrew is already installed.
if ! which brew > /dev/null 2>&1; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
HOMEBREW_PREFIX=$(brew --prefix)


BOOST_LIB="boost@1.84"
REQUIRED_PACKAGES=(
autoconf automake bdw-gc ccache cmake libtool
openssl pkg-config coreutils bison grep
${BOOST_LIB}
)
for package in "${REQUIRED_PACKAGES[@]}"; do
brew_install ${package}
done

# Check if linking is needed.
if ! brew ls --linked --formula ${BOOST_LIB} > /dev/null 2>&1; then
brew link ${BOOST_LIB}
fi

# We need to link boost.
$BREW install ${BOOST_LIB}
$BREW link ${BOOST_LIB}
# Prefer Homebrew's bison and grep over the macOS-provided version
$BREW install bison
echo 'export PATH="/usr/local/opt/bison/bin:$PATH"' >> ~/.bash_profile
$BREW install grep
echo 'export PATH="/usr/local/opt/grep/libexec/gnubin:$PATH"' >> ~/.bash_profile
# Check if PATH modification is needed.
if ! grep -q "$(brew --prefix bison)/bin" ~/.bash_profile; then
echo 'export PATH="$(brew --prefix bison)/bin:$PATH"' >> ~/.bash_profile
fi
if ! grep -q "$HOMEBREW_PREFIX/opt/grep/libexec/gnubin" ~/.bash_profile; then
echo 'export PATH="$HOMEBREW_PREFIX/opt/grep/libexec/gnubin:$PATH"' >> ~/.bash_profile
fi
source ~/.bash_profile


# install pip and required pip packages
# curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
# python get-pip.py --user
# use scapy 2.4.5, which is the version on which ptf depends
pip3 install --user scapy==2.4.5 ply==3.8
# Install required pip packages
pip3 install --user -r requirements.txt
Loading