Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 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
7 changes: 5 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/tests/**/* linguist-generated=true
/toolchain/mechanisms/* linguist-generated=true
*.fpp text eol=lf
*.f90 text eol=lf
*.sh text eol=lf
/tests/**/* linguist-generated=true
/toolchain/mechanisms/* linguist-generated=true
42 changes: 12 additions & 30 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,39 +48,21 @@ jobs:
- name: Clone
uses: actions/checkout@v4

- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: '3.13'

- name: Setup MacOS
if: matrix.os == 'macos'
run: |
brew update
brew upgrade
brew install coreutils python fftw hdf5 gcc@15 boost open-mpi lapack
echo "FC=gfortran-15" >> $GITHUB_ENV
echo "BOOST_INCLUDE=/opt/homebrew/include/" >> $GITHUB_ENV

- name: Setup Ubuntu
if: matrix.os == 'ubuntu' && matrix.intel == false
- name: Install Dependencies (Unified Script)
run: |
sudo apt update -y
sudo apt install -y cmake gcc g++ python3 python3-dev hdf5-tools \
libfftw3-dev libhdf5-dev openmpi-bin libopenmpi-dev \
libblas-dev liblapack-dev
chmod +x ./scripts/install_dependencies.sh
./scripts/install_dependencies.sh

- name: Setup Ubuntu (Intel)
if: matrix.os == 'ubuntu' && matrix.intel == true
- name: Verify dependency installation
run: |
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
sudo apt-get update
sudo apt-get install -y intel-oneapi-compiler-fortran intel-oneapi-mpi intel-oneapi-mpi-devel
source /opt/intel/oneapi/setvars.sh
printenv >> $GITHUB_ENV
cmake --version
gcc --version
python3 --version

- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: '3.13'

- name: Build
run: |
Expand Down Expand Up @@ -135,4 +117,4 @@ jobs:
if: matrix.lbl == 'frontier'
with:
name: logs-${{ strategy.job-index }}-${{ matrix.device }}
path: test-${{ matrix.device }}.out
path: test-${{ matrix.device }}.out
9 changes: 9 additions & 0 deletions CMakeLists.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High-level Suggestion

The dependency_check executable should be removed from the main CMakeLists.txt because it is only used for CI. Instead, the dependency verification should be handled directly within the install_dependencies.sh script. [High-level, importance: 8]

Solution Walkthrough:

Before:

# In CMakeLists.txt
# ... (main project configuration)

# Small dependency-check executable (used by CI to verify deps like Boost)
find_package(Boost REQUIRED)
add_executable(dependency_check examples/dependency_check/dependency_check.cpp)
target_include_directories(dependency_check PRIVATE ${Boost_INCLUDE_DIRS})

# No check inside install_dependencies.sh

After:

# In CMakeLists.txt
# ... (main project configuration)
# The dependency_check executable and related find_package(Boost) are removed.

# In scripts/install_dependencies.sh
# ... (after installing dependencies)
echo "Verifying Boost dependency by compiling a test file..."
cat <<EOF > /tmp/boost_check.cpp
#include <boost/version.hpp>
#include <iostream>
int main() { std::cout << "Boost version: " << BOOST_LIB_VERSION << std::endl; return 0; }
EOF
g++ /tmp/boost_check.cpp -o /tmp/boost_check $(pkg-config --cflags --libs boost || echo "-I${Boost_INCLUDE_DIRS}")
/tmp/boost_check

Original file line number Diff line number Diff line change
Expand Up @@ -715,3 +715,12 @@ site_name(SITE_NAME)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/toolchain/cmake/configuration.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/configuration.txt")

# -------------------------
# Small dependency-check executable (used by CI to verify deps like Boost)
find_package(Boost REQUIRED)
add_executable(dependency_check examples/dependency_check/dependency_check.cpp)
# make sure compiler sees Boost headers
target_include_directories(dependency_check PRIVATE ${Boost_INCLUDE_DIRS})
# don't force any link libraries: we use Boost header macros only
# -------------------------
153 changes: 153 additions & 0 deletions scripts/install_dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
#!/bin/bash
# A solution for consolidating dependency installation commands for different operating systems (for macOS, Debian/Ubuntu, RedHat/CentOS)
# Allows minimal repetition in command installations in multiple CI workflow files.
# CI logs on which commands are being run.

# Instructions:
# 1. Run this command: chmod +x ./scripts/install_dependencies.sh
# 2. Run the installer: ./scripts/install_dependencies.sh

set -euo pipefail
set -x
export DEBIAN_FRONTEND=noninteractive

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

if command -v sudo >/dev/null 2>&1; then
SUDO="sudo"
else
SUDO=""
fi

# macOS
# if [[ "$OSTYPE" == "darwin"* ]]; then
# # Use Homebrew for macOS package management
# echo "Detected macOS."
# export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:$PATH"
# brew update

# # Packages to install
# declare -A packages
# packages=(
# ["cmake"]="cmake"
# ["gcc"]="gcc"
# ["python3"]="[email protected]"
# ["boost"]="boost"
# ["protobuf"]="protobuf"
# )

# # Install missing packages
# for exe in "${!packages[@]}"; do
# formula="${packages[$exe]}"
# if ! command -v "$exe" >/dev/null 2>&1; then
# echo "Installing $formula..."
# brew install --verbose "$formula"
# else
# echo "$exe already installed"
# fi
# done

# # Verification
# echo "Verifying installations..."
# which cmake; cmake --version
# which gcc; gcc --version
# which python3; python3 --version
# brew list boost || echo "boost not found"
# brew list protobuf || echo "protobuf not found"

# echo "macOS dependencies installed successfully."
# macOS
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "Detected macOS."
export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:$PATH"
brew update
brew upgrade || true

# Install required packages (mirrors workflow setup)
pkgs=(coreutils python fftw hdf5 gcc@15 boost open-mpi lapack cmake protobuf)

for pkg in "${pkgs[@]}"; do
if ! brew list "$pkg" >/dev/null 2>&1; then
echo "Installing $pkg..."
brew install "$pkg" || brew reinstall "$pkg"
else
echo "$pkg already installed."
fi
done

# Fix potential linking issues for Homebrew-installed libraries
brew link --overwrite python || true
brew link --overwrite boost || true
brew link --overwrite hdf5 || true
brew link --overwrite cmake || true
brew link --overwrite protobuf || true

# Environment setup
echo "FC=gfortran-15" >> "$GITHUB_ENV"
echo "BOOST_INCLUDE=/opt/homebrew/include/" >> "$GITHUB_ENV"

echo "macOS dependencies installed successfully."

# Debian/Ubuntu
elif [[ -f /etc/debian_version ]]; then
echo "Detected Debian/Ubuntu"

# Install all required packages (this time with openmpi and fftw)
if [[ "${CI_INTEL:-false}" == "true" ]]; then
echo "Intel OneAPI environment detected. Installing Intel compilers and MPI..."
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
$SUDO apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
Copy link
Contributor

@qodo-merge-pro qodo-merge-pro bot Oct 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Replace the deprecated apt-key command with the modern, secure method of managing APT keys. Store the GPG key in /etc/apt/keyrings and reference it from a dedicated sources list file. [security, importance: 8]

Suggested change
$SUDO apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
$SUDO install -m 0644 GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB /etc/apt/keyrings/intel-archive-keyring.gpg
echo "deb [signed-by=/etc/apt/keyrings/intel-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | $SUDO tee /etc/apt/sources.list.d/oneapi.list > /dev/null

$SUDO add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
$SUDO apt-get update
$SUDO apt-get install -y intel-oneapi-compiler-fortran intel-oneapi-mpi intel-oneapi-mpi-devel
source /opt/intel/oneapi/setvars.sh
if [[ -n "${GITHUB_ENV:-}" ]]; then
echo "source /opt/intel/oneapi/setvars.sh" >> "$GITHUB_ENV"
fi
printenv >> "$GITHUB_ENV"
Copy link
Contributor

@qodo-merge-pro qodo-merge-pro bot Oct 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Correct the method for persisting environment variables from setvars.sh in the GitHub Actions environment. Instead of dumping all variables with printenv, capture and append only the variables modified by the script to $GITHUB_ENV. [possible issue, importance: 10]

Suggested change
source /opt/intel/oneapi/setvars.sh
if [[ -n "${GITHUB_ENV:-}" ]]; then
echo "source /opt/intel/oneapi/setvars.sh" >> "$GITHUB_ENV"
fi
printenv >> "$GITHUB_ENV"
# Create a temporary file to store the environment before sourcing
env > /tmp/env_before
# Source the Intel script to set variables for the current shell
source /opt/intel/oneapi/setvars.sh
# Compare the environment before and after, and append only the new/changed variables to GITHUB_ENV
if [[ -n "${GITHUB_ENV:-}" ]]; then
diff --unchanged-line-format="" --old-line-format="" --new-line-format="%L" <(sort /tmp/env_before) <(env | sort) >> "$GITHUB_ENV"
fi
rm /tmp/env_before

echo "Intel OneAPI installation completed."
else
echo "Standard GNU environment detected. Installing open-source toolchain..."
$SUDO apt-get update -y
pkgs="tar wget make cmake gcc g++ python3 python3-dev openmpi-bin libopenmpi-dev fftw3 libfftw3-dev protobuf-compiler libboost-all-dev"
$SUDO apt-get install -y $pkgs

# Verification
echo "Verifying installations..."
cmake --version || echo "cmake not found"
gcc --version || echo "gcc not found"
python3 --version || echo "python3 not found"
mpirun --version || echo "mpirun not found"
ldconfig -p | grep -q libfftw3 || echo "FFTW library not found"

echo "Linux (GNU) dependencies installed successfully."
fi

# RedHat/CentOS
elif [[ -f /etc/redhat-release ]]; then
echo "Detected RedHat/CentOS"
$SUDO yum install -y epel-release

# Install all required packages (this time with openmpi and fftw)
pkgs="tar wget make cmake3 gcc gcc-c++ python3 openmpi fftw protobuf boost-devel"
$SUDO yum install -y $pkgs
Copy link
Contributor

@qodo-merge-pro qodo-merge-pro bot Oct 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Add missing development packages (-devel) to the yum installation list for RedHat/CentOS. The current list lacks headers and libraries for openmpi, fftw, protobuf, and python3, which are required for compilation. [possible issue, importance: 9]

Suggested change
pkgs="tar wget make cmake3 gcc gcc-c++ python3 openmpi fftw protobuf boost-devel"
$SUDO yum install -y $pkgs
pkgs="tar wget make cmake3 gcc gcc-c++ python3-devel openmpi openmpi-devel fftw fftw-devel protobuf protobuf-devel boost-devel"
$SUDO yum install -y $pkgs


# Verification
echo "Verifying installations..."
cmake3 --version || echo "cmake3 not found"
gcc --version || echo "gcc not found"
python3 --version || echo "python3 not found"
mpirun --version || echo "mpirun not found"
rpm -q fftw || echo "FFTW library not found"

echo "RedHat/CentOS dependencies installed successfully."


# If Unsupported OS
else
echo "Unsupported OS: $OSTYPE"
exit 1
fi

echo "Dependencies installed successfully."
Loading