From c76af535dfba33763e61071bbe74414f3e5d8324 Mon Sep 17 00:00:00 2001 From: Senichenkov Date: Sat, 11 Jan 2025 22:38:38 +0300 Subject: [PATCH] Use function to determine short OS name in CI --- .../install-dependencies/action.yml | 33 +++++++++++++------ .github/workflows/bindings-tests.yml | 10 +++--- .github/workflows/core-tests.yml | 22 ++++++------- 3 files changed, 39 insertions(+), 26 deletions(-) diff --git a/.github/composite-actions/install-dependencies/action.yml b/.github/composite-actions/install-dependencies/action.yml index 201191f74..adaa877d9 100644 --- a/.github/composite-actions/install-dependencies/action.yml +++ b/.github/composite-actions/install-dependencies/action.yml @@ -12,11 +12,8 @@ inputs: default: true os: - type: choice + type: string required: true - options: - ubuntu - macos toolset: type: choice @@ -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: | @@ -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 @@ -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 @@ -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 diff --git a/.github/workflows/bindings-tests.yml b/.github/workflows/bindings-tests.yml index 774955b4f..ce85a3119 100644 --- a/.github/workflows/bindings-tests.yml +++ b/.github/workflows/bindings-tests.yml @@ -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 diff --git a/.github/workflows/core-tests.yml b/.github/workflows/core-tests.yml index 406307653..1651b7109 100644 --- a/.github/workflows/core-tests.yml +++ b/.github/workflows/core-tests.yml @@ -31,8 +31,8 @@ jobs: strategy: matrix: os: - - ubuntu - - macos + - ubuntu-latest + - macos-latest compiler: - gcc - llvm-clang @@ -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 @@ -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 @@ -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