Skip to content

Commit

Permalink
Use "choice" instead of several flags in workflows
Browse files Browse the repository at this point in the history
Use "choice" options for build tools, toolset and boost instead of
large variety of boolean flags
  • Loading branch information
p-senichenkov committed Jan 6, 2025
1 parent abe3a3d commit eb10e2e
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 64 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'Download libraries'
description: 'Download files necessary for compilation and testing'
name: 'Install dependencies'
description: 'Download and install build system and libraries'
inputs:
download-pybind:
type: boolean
Expand All @@ -11,53 +11,67 @@ inputs:
description: 'Download googletest'
default: true

install-boost-gcc:
type: boolean
description: 'Install boost built with GCC'
default: true

install-boost-clang:
type: boolean
description: 'Install boost built with clang'
default: false
install-build-tools:
type: choice
options:
none
apt
brew
default: none

install-boost-brew-clang:
type: boolean
description: 'Install boost built with Homebrew Clang'
default: false

install-gcc:
type: boolean
description: 'Install GCC toolset (compiler and build tools)'
default: true
install-toolset:
type: choice
options:
none
gcc
clang-linux
llvm-clang-macos
default: none

install-clang:
type: boolean
description: 'Install clang toolset (compiler and build tools)'
default: false
install-boost:
type: choice
options:
none
gcc
clang-linux
llvm-clang-macos
apple-clang
default: none

runs:
using: 'composite'
steps:
- uses: actions/checkout@v3
- name: Install build tools

- name: Install build tools using apt
run: |
sudo apt-get update -y
sudo apt-get install gcc-10 g++-10 cmake build-essential -y
sudo apt-get install cmake build-essential -y
shell: bash
if: inputs.install-gcc != 'false'
if: inputs.install-build-tools == apt
- name: Install build tools using brew
run: brew install make cmake
shell: bash
if: inputs.install-build-tools == brew

- name: Install clang
# llvm.sh installs all needed libraries, no need in build-essential
- name: Install GCC toolset
run: |
sudo apt-get install gcc-10 g++-10 -y
shell: bash
if: inputs.install-toolset == gcc
- name: Install Clang toolset (on Linux)
# "all" option is needed to install libc++ and libc++abi
# apt is hardcoded in llvm.sh, so we can't use it everywhere
run: |
sudo apt-get update -y
sudo apt-get install cmake make -y
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 17 all
shell: bash
if: inputs.install-clang != 'false'
if: inputs.install-toolset == clang-linux
- names: Install LLVM Clang toolset (on macOS)
run: brew install llvm@17
shell: bash
if: inputs.install-toolset == llvm-clang-macos

- name: Make lib directory
run: |
Expand Down Expand Up @@ -111,17 +125,17 @@ runs:
./bootstrap.sh --prefix=/usr
sudo ./b2 install --prefix=/usr
shell: bash
if: inputs.install-boost-gcc != 'false'
- name: Install Boost built with clang
if: inputs.install-boost == gcc
- name: Install Boost built with Clang (on Linux)
run: |
cd lib/boost
./bootstrap.sh --prefix=/usr --with-toolset=clang
./b2 clean
./b2 toolset=clang cxxflags="-stdlib=libc++" linkflags="-stdlib=libc++"
sudo ./b2 install --prefix=/usr
shell: bash
if: inputs.install-boost-clang != 'false'
- name: Install Boost built with Homebrew Clang
if: inputs.install-boost == clang-linux
- name: Install Boost built with LLVM Clang (on macOS)
# b2 doesn't recognize custom compilers, so some trick is needed:
# Also, /usr is read-only, so install into /usr/local
run: |
Expand All @@ -132,7 +146,12 @@ runs:
./b2 toolset=clang cxxflags="-std=c++11 -stdlib=libc++" linkflags="-stdlib=libc++"
sudo ./b2 install --prefix=/usr/local
shell: bash
if: inputs.install-boost-brew-clang != 'false'
if: inputs.install-boost == llvm-clang-macos
- name: Install Boost built with Apple Clang
run: brew install boost
shell: bash
if: inputs.install-boost == apple-clang

- name: Download frozen
uses: ./.github/composite-actions/download-library
with:
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/bindings-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download libraries
uses: ./.github/composite-actions/download-libraries
- name: Install dependencies
uses: ./.github/composite-actions/install-dependencies
with:
# FIXME(senichenkiov): Do we need build-tools, gcc and boost here?
install-build-tools: apt
install-toolset: gcc
install-boost: gcc
download-pybind: true
download-googletest: false
- name: Build pip package
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/check-codestyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download libraries
uses: ./.github/composite-actions/download-libraries
- name: Install dependencies
uses: ./.github/composite-actions/install-dependencies
with:
# FIXME(senichenkov): do we need gcc and boost here, or build-tools will be enough?
install-build-tools: apt
install-toolset: gcc
install-boost: gcc
download-pybind: true
- name: Generate compile_commands.json
run: |
Expand Down
44 changes: 24 additions & 20 deletions .github/workflows/core-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@ jobs:
- { BUILD_TYPE: Debug, SANITIZER : UB }
steps:
- uses: actions/checkout@v3
- name: Download libraries
uses: ./.github/composite-actions/download-libraries
- name: Install dependencies
uses: ./.github/composite-actions/install-dependencies
with:
# TODO(senichenkov): now, we must use matrix here
install-build-tools: apt
install-toolset: gcc
install-boost: gcc
- name: Download datasets
uses: ./.github/composite-actions/download-datasets
- name: Build
Expand All @@ -66,13 +71,12 @@ jobs:
- { BUILD_TYPE: Debug, SANITIZER : UB }
steps:
- uses: actions/checkout@v3
- name: Download libraries
uses: ./.github/composite-actions/download-libraries
- name: Install dependencies
uses: ./.github/composite-actions/install-dependencies
with:
install-gcc: false
install-clang: true
install-boost-gcc: false
install-boost-clang: true
install-build-tools: apt
install-toolset: clang-linux
install-boost: clang-linux
- name: Download datasets
uses: ./.github/composite-actions/download-datasets
- name: Build
Expand Down Expand Up @@ -101,17 +105,12 @@ jobs:
- { BUILD_TYPE: Debug, SANITIZER : UB }
steps:
- uses: actions/checkout@v3
- name: Download build system
run: brew install llvm@17 make
shell: bash
- name: Download libraries
uses: ./.github/composite-actions/download-libraries
- name: Install dependencies
uses: ./.github/composite-actions/install-dependencies
with:
install-gcc: false
install-clang: false
install-boost-gcc: false
install-boost-clang: false
install-boost-brew-clang: true
install-build-tools: brew
install-toolset: llvm-clang-macos
install-boost: llvm-clang-macos
- name: Download datasets
uses: ./.github/composite-actions/download-datasets
- name: Build
Expand Down Expand Up @@ -142,8 +141,13 @@ jobs:
- name: Download libraries
run: brew install make boost cmake
shell: bash
- name: Download datasets
uses: ./.github/composite-actions/download-datasets
- name: Install dependencies
uses: ./.github/composite-actions/install-dependencies
with:
install-build-tools: brew
# Apple Clang is already installed
install-toolset: none
install-boost: apple-clang
- name: Build
run: |
if [[ "${{matrix.cfg.BUILD_TYPE}}" == "Debug" ]]; then
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,14 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Download libraries
uses: ./.github/composite-actions/download-libraries
- name: Install dependencies
uses: ./.github/composite-actions/install-dependencies
with:
install-build-tools: apt
install-toolset: gcc
install-boost: none
download-pybind: true
download-googletest: false
install-boost-gcc: false

- name: Build wheels
uses: pypa/[email protected]
Expand Down

0 comments on commit eb10e2e

Please sign in to comment.