Skip to content

Commit 0cd21cd

Browse files
Add dependency installation script and integrate into CI workflow
- scripts/install_dependencies.sh: installs required dependencies on CI - .github/workflows/test.yml: updated workflow to call the install_dependencies.sh script - CMakeLists.txt: added dependency check/integration for CI
1 parent da1dc11 commit 0cd21cd

File tree

3 files changed

+116
-73
lines changed

3 files changed

+116
-73
lines changed

.github/workflows/test.yml

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -48,39 +48,21 @@ jobs:
4848
- name: Clone
4949
uses: actions/checkout@v4
5050

51-
- name: Set up Python 3.13
52-
uses: actions/setup-python@v5
53-
with:
54-
python-version: '3.13'
55-
56-
- name: Setup MacOS
57-
if: matrix.os == 'macos'
58-
run: |
59-
brew update
60-
brew upgrade
61-
brew install coreutils python fftw hdf5 gcc@15 boost open-mpi lapack
62-
echo "FC=gfortran-15" >> $GITHUB_ENV
63-
echo "BOOST_INCLUDE=/opt/homebrew/include/" >> $GITHUB_ENV
64-
65-
- name: Setup Ubuntu
66-
if: matrix.os == 'ubuntu' && matrix.intel == false
51+
- name: Install Dependencies (Unified Script)
6752
run: |
68-
sudo apt update -y
69-
sudo apt install -y cmake gcc g++ python3 python3-dev hdf5-tools \
70-
libfftw3-dev libhdf5-dev openmpi-bin libopenmpi-dev \
71-
libblas-dev liblapack-dev
53+
chmod +x ./scripts/install_dependencies.sh
54+
./scripts/install_dependencies.sh
7255
73-
- name: Setup Ubuntu (Intel)
74-
if: matrix.os == 'ubuntu' && matrix.intel == true
56+
- name: Verify dependency installation
7557
run: |
76-
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
77-
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
78-
sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
79-
sudo apt-get update
80-
sudo apt-get install -y intel-oneapi-compiler-fortran intel-oneapi-mpi intel-oneapi-mpi-devel
81-
source /opt/intel/oneapi/setvars.sh
82-
printenv >> $GITHUB_ENV
58+
cmake --version
59+
gcc --version
60+
python3 --version
8361
62+
- name: Set up Python 3.13
63+
uses: actions/setup-python@v5
64+
with:
65+
python-version: '3.13'
8466

8567
- name: Build
8668
run: |
@@ -135,4 +117,4 @@ jobs:
135117
if: matrix.lbl == 'frontier'
136118
with:
137119
name: logs-${{ strategy.job-index }}-${{ matrix.device }}
138-
path: test-${{ matrix.device }}.out
120+
path: test-${{ matrix.device }}.out

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,3 +715,12 @@ site_name(SITE_NAME)
715715
configure_file(
716716
"${CMAKE_CURRENT_SOURCE_DIR}/toolchain/cmake/configuration.cmake.in"
717717
"${CMAKE_CURRENT_BINARY_DIR}/configuration.txt")
718+
719+
# -------------------------
720+
# Small dependency-check executable (used by CI to verify deps like Boost)
721+
find_package(Boost REQUIRED)
722+
add_executable(dependency_check examples/dependency_check/dependency_check.cpp)
723+
# make sure compiler sees Boost headers
724+
target_include_directories(dependency_check PRIVATE ${Boost_INCLUDE_DIRS})
725+
# don't force any link libraries: we use Boost header macros only
726+
# -------------------------

scripts/install_dependencies.sh

100644100755
Lines changed: 95 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,78 +8,130 @@
88
# 2. Run the installer: ./scripts/install_dependencies.sh
99

1010
set -euo pipefail
11-
set -x
11+
set -x
12+
export DEBIAN_FRONTEND=noninteractive
1213

1314
OS="$(uname -s)"
1415
echo "Installing dependencies for $OS OS"
1516

17+
if command -v sudo >/dev/null 2>&1; then
18+
SUDO="sudo"
19+
else
20+
SUDO=""
21+
fi
22+
23+
# macOS
24+
# if [[ "$OSTYPE" == "darwin"* ]]; then
25+
# # Use Homebrew for macOS package management
26+
# echo "Detected macOS."
27+
# export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:$PATH"
28+
# brew update
29+
30+
# # Packages to install
31+
# declare -A packages
32+
# packages=(
33+
# ["cmake"]="cmake"
34+
# ["gcc"]="gcc"
35+
# ["python3"]="[email protected]"
36+
# ["boost"]="boost"
37+
# ["protobuf"]="protobuf"
38+
# )
39+
40+
# # Install missing packages
41+
# for exe in "${!packages[@]}"; do
42+
# formula="${packages[$exe]}"
43+
# if ! command -v "$exe" >/dev/null 2>&1; then
44+
# echo "Installing $formula..."
45+
# brew install --verbose "$formula"
46+
# else
47+
# echo "$exe already installed"
48+
# fi
49+
# done
50+
51+
# # Verification
52+
# echo "Verifying installations..."
53+
# which cmake; cmake --version
54+
# which gcc; gcc --version
55+
# which python3; python3 --version
56+
# brew list boost || echo "boost not found"
57+
# brew list protobuf || echo "protobuf not found"
58+
59+
# echo "macOS dependencies installed successfully."
1660
# macOS
1761
if [[ "$OSTYPE" == "darwin"* ]]; then
18-
# Use Homebrew for macOS package management
1962
echo "Detected macOS."
2063
export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:$PATH"
2164
brew update
65+
brew upgrade || true
66+
67+
# Install required packages (mirrors workflow setup)
68+
pkgs=(coreutils python fftw hdf5 gcc@15 boost open-mpi lapack cmake protobuf)
2269

23-
# Packages to install
24-
declare -A packages
25-
packages=(
26-
["cmake"]="cmake"
27-
["gcc"]="gcc"
28-
["python3"]="[email protected]"
29-
["boost"]="boost"
30-
["protobuf"]="protobuf"
31-
)
32-
33-
# Install missing packages
34-
for exe in "${!packages[@]}"; do
35-
formula="${packages[$exe]}"
36-
if ! command -v "$exe" >/dev/null 2>&1; then
37-
echo "Installing $formula..."
38-
brew install --verbose "$formula"
70+
for pkg in "${pkgs[@]}"; do
71+
if ! brew list "$pkg" >/dev/null 2>&1; then
72+
echo "Installing $pkg..."
73+
brew install "$pkg" || brew reinstall "$pkg"
3974
else
40-
echo "$exe already installed"
75+
echo "$pkg already installed."
4176
fi
4277
done
4378

44-
# Verification
45-
echo "Verifying installations..."
46-
which cmake; cmake --version
47-
which gcc; gcc --version
48-
which python3; python3 --version
49-
brew list boost || echo "boost not found"
50-
brew list protobuf || echo "protobuf not found"
79+
# Fix potential linking issues for Homebrew-installed libraries
80+
brew link --overwrite python || true
81+
brew link --overwrite boost || true
82+
brew link --overwrite hdf5 || true
83+
brew link --overwrite cmake || true
84+
brew link --overwrite protobuf || true
5185

52-
echo "macOS dependencies installed successfully."
86+
# Environment setup
87+
echo "FC=gfortran-15" >> "$GITHUB_ENV"
88+
echo "BOOST_INCLUDE=/opt/homebrew/include/" >> "$GITHUB_ENV"
5389

90+
echo "macOS dependencies installed successfully."
5491

5592
# Debian/Ubuntu
5693
elif [[ -f /etc/debian_version ]]; then
5794
echo "Detected Debian/Ubuntu"
58-
sudo apt-get update -y
5995

6096
# Install all required packages (this time with openmpi and fftw)
61-
pkgs="tar wget make cmake gcc g++ python3 python3-dev openmpi-bin libopenmpi-dev fftw3 libfftw3-dev protobuf-compiler libboost-all-dev"
62-
sudo apt-get install -y $pkgs
63-
64-
# Verification
65-
echo "Verifying installations..."
66-
cmake --version || echo "cmake not found"
67-
gcc --version || echo "gcc not found"
68-
python3 --version || echo "python3 not found"
69-
mpirun --version || echo "mpirun not found"
70-
ldconfig -p | grep -q libfftw3 || echo "FFTW library not found"
71-
72-
echo "Linux dependencies installed successfully."
73-
97+
if [[ "${CI_INTEL:-false}" == "true" ]]; then
98+
echo "Intel OneAPI environment detected. Installing Intel compilers and MPI..."
99+
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
100+
$SUDO apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
101+
$SUDO add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
102+
$SUDO apt-get update
103+
$SUDO apt-get install -y intel-oneapi-compiler-fortran intel-oneapi-mpi intel-oneapi-mpi-devel
104+
source /opt/intel/oneapi/setvars.sh
105+
if [[ -n "${GITHUB_ENV:-}" ]]; then
106+
echo "source /opt/intel/oneapi/setvars.sh" >> "$GITHUB_ENV"
107+
fi
108+
printenv >> "$GITHUB_ENV"
109+
echo "Intel OneAPI installation completed."
110+
else
111+
echo "Standard GNU environment detected. Installing open-source toolchain..."
112+
$SUDO apt-get update -y
113+
pkgs="tar wget make cmake gcc g++ python3 python3-dev openmpi-bin libopenmpi-dev fftw3 libfftw3-dev protobuf-compiler libboost-all-dev"
114+
$SUDO apt-get install -y $pkgs
115+
116+
# Verification
117+
echo "Verifying installations..."
118+
cmake --version || echo "cmake not found"
119+
gcc --version || echo "gcc not found"
120+
python3 --version || echo "python3 not found"
121+
mpirun --version || echo "mpirun not found"
122+
ldconfig -p | grep -q libfftw3 || echo "FFTW library not found"
123+
124+
echo "Linux (GNU) dependencies installed successfully."
125+
fi
74126

75127
# RedHat/CentOS
76128
elif [[ -f /etc/redhat-release ]]; then
77129
echo "Detected RedHat/CentOS"
78-
sudo yum install -y epel-release
130+
$SUDO yum install -y epel-release
79131

80132
# Install all required packages (this time with openmpi and fftw)
81133
pkgs="tar wget make cmake3 gcc gcc-c++ python3 openmpi fftw protobuf boost-devel"
82-
sudo yum install -y $pkgs
134+
$SUDO yum install -y $pkgs
83135

84136
# Verification
85137
echo "Verifying installations..."

0 commit comments

Comments
 (0)