Skip to content

Commit

Permalink
Use function to determine short OS name in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
p-senichenkov committed Jan 11, 2025
1 parent a87e524 commit c76af53
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 26 deletions.
33 changes: 23 additions & 10 deletions .github/composite-actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ inputs:
default: true

os:
type: choice
type: string
required: true
options:
ubuntu
macos

toolset:
type: choice
Expand All @@ -39,16 +36,32 @@ runs:
steps:
- uses: actions/checkout@v3

- name: Get short OS name
shell: bash
run: |
function get_short_os_name() {
if [[ $1 == *"macos"* ]]; then
echo "macos"
elif [[ $1 == *"ubuntu"* ]]; then
echo "ubuntu"
else
echo "ERROR: unknown OS"
exit 1
fi
}
echo "OS=$(get_short_os_name ${{ inputs.os }})" >> $GITHUB_ENV
- name: Install build tools using apt
run: |
sudo apt-get update -y
sudo apt-get install cmake build-essential -y
shell: bash
if: inputs.os == 'ubuntu'
if: env.OS == 'ubuntu'
- name: Install build tools using brew
run: brew install make cmake
shell: bash
if: inputs.os == 'macos'
if: env.OS == 'macos'

- name: Install GCC toolset
run: |
Expand All @@ -63,11 +76,11 @@ runs:
chmod +x llvm.sh
sudo ./llvm.sh 17 all
shell: bash
if: inputs.install-toolset == 'true' && inputs.toolset == 'llvm-clang' && inputs.os == 'ubuntu'
if: inputs.install-toolset == 'true' && inputs.toolset == 'llvm-clang' && env.OS == 'ubuntu'
- name: Install LLVM Clang toolset (on macOS)
run: brew install llvm@17
shell: bash
if: inputs.install-toolset == 'true' && inputs.toolset == 'llvm-clang' && inputs.os == 'macos'
if: inputs.install-toolset == 'true' && inputs.toolset == 'llvm-clang' && env.OS == 'macos'
# Apple Clang is installed by default on macOS runner

- name: Make lib directory
Expand Down Expand Up @@ -130,7 +143,7 @@ runs:
sudo ./b2 install -a --prefix=/usr toolset=clang cxxflags="-stdlib=libc++" \
linkflags="-stdlib=libc++"
shell: bash
if: inputs.install-boost == 'true' && inputs.toolset == 'llvm-clang' && inputs.os == 'ubuntu'
if: inputs.install-boost == 'true' && inputs.toolset == 'llvm-clang' && env.OS == 'ubuntu'
- name: Install Boost built with LLVM Clang (on macOS)
run: |
cd lib/boost
Expand All @@ -140,7 +153,7 @@ runs:
cxxflags="-std=c++11 -I$(brew --prefix llvm@17)/include" \
linkflags="-L$(brew --prefix llvm@17)/lib/c++"
shell: bash
if: inputs.install-boost == 'true' && inputs.toolset == 'llvm-clang' && inputs.os == 'macos'
if: inputs.install-boost == 'true' && inputs.toolset == 'llvm-clang' && env.OS == 'macos'
- name: Install Boost built with Apple Clang
run: brew install boost
shell: bash
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/bindings-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@ jobs:
strategy:
matrix:
include:
- os: ubuntu
- os: ubuntu-latest
compiler: gcc
env: CC=gcc-10 CXX=g++-10
- os: ubuntu
- os: ubuntu-latest
compiler: llvm-clang
env: CC=clang-17 CXX=clang++-17 CXXFLAGS="-stdlib=libc++" LDFLAGS="-lc++abi"
# Uncomment this to enable macOS-llvm-clang tests:
# - os: macos
# - os: macos-latest
# compiler: llvm-clang
# env: CC=$(brew --prefix llvm@17)/bin/clang CXX=$(brew --prefix llvm@17)/bin/clang++ BOOST_ROOT=/usr/local
# runtime-env: DYLD_LIBRARY_PATH=/usr/local/lib:${DYLD_LIBRARY_PATH}
- os: macos
- os: macos-latest
compiler: apple-clang
env: CC=clang CXX=clang++ BOOST_ROOT=$(brew --prefix boost)
runs-on: ${{ matrix.os }}-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Install dependencies
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/core-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
strategy:
matrix:
os:
- ubuntu
- macos
- ubuntu-latest
- macos-latest
compiler:
- gcc
- llvm-clang
Expand All @@ -43,14 +43,14 @@ jobs:
- { BUILD_TYPE: Debug, SANITIZER : ADDRESS }
- { BUILD_TYPE: Debug, SANITIZER : UB }
exclude:
- os: ubuntu
- os: ubuntu-latest
compiler: apple-clang
- os: macos
- os: macos-latest
compiler: gcc
# Comment this to enable macOS-llvm-clang tests:
- os: macos
- os: macos-latest
compiler: llvm-clang
runs-on: ${{ matrix.os }}-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Install dependencies
Expand All @@ -64,25 +64,25 @@ jobs:
shell: bash
# Maybe separate composite action will be more readable?
run: |
if [[ ${{ matrix.os }} == 'ubuntu' && ${{ matrix.compiler }} == 'gcc' ]]; then
if [[ ${{ matrix.os }} == 'ubuntu-latest' && ${{ matrix.compiler }} == 'gcc' ]]; then
echo "Ubuntu, GCC"
export CC=gcc-10
export CXX=g++-10
elif [[ ${{ matrix.os }} == 'ubuntu' && ${{ matrix.compiler }} == 'llvm-clang' ]]; then
elif [[ ${{ matrix.os }} == 'ubuntu-latest' && ${{ matrix.compiler }} == 'llvm-clang' ]]; then
echo "Ubuntu, LLVM Clang"
export CC=clang-17
export CXX=clang++-17
export CXXFLAGS="-stdlib=libc++"
export LDFLAGS="-lc++abi"
elif [[ ${{ matrix.os }} == 'macos' && ${{ matrix.compiler }} == 'llvm-clang' ]]; then
elif [[ ${{ matrix.os }} == 'macos-latest' && ${{ matrix.compiler }} == 'llvm-clang' ]]; then
echo "macOS, LLVM Clang"
export CC=$(brew --prefix llvm@17)/bin/clang
export CXX=$(brew --prefix llvm@17)/bin/clang++
export BOOST_ROOT=/usr/local
elif [[ ${{ matrix.os }} == 'macos' && ${{ matrix.compiler }} == 'apple-clang' ]]; then
elif [[ ${{ matrix.os }} == 'macos-latest' && ${{ matrix.compiler }} == 'apple-clang' ]]; then
echo "macOS, Apple Clang"
export CC=clang
Expand All @@ -101,7 +101,7 @@ jobs:
working-directory: ${{github.workspace}}/build/target
shell: bash
run: |
if [[ ${{ matrix.os }} == 'macos' ]]; then
if [[ ${{ matrix.os }} == 'macos-latest' ]]; then
export DYLD_LIBRARY_PATH=/usr/local/lib:${DYLD_LIBRARY_PATH}
fi
Expand Down

0 comments on commit c76af53

Please sign in to comment.