Add callable workflow for building OpenMPI from source #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Build OpenMPI from source using the latest commit on the | ||
# 'main' branch and cache the results | ||
# Triggers the workflow on a call from another workflow | ||
on: | ||
workflow_call: | ||
inputs: | ||
install_path: | ||
description: "location to install OpenMPI to or restore to from cache" | ||
required: true | ||
type: string | ||
build_mode: | ||
description: "production vs. debug build" | ||
required: true | ||
type: string | ||
permissions: | ||
contents: read | ||
jobs: | ||
ubuntu_gcc_build_and_test: | ||
name: "Build OpenMPI ${{ inputs.build_mode }} (GCC)" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install Linux Dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install build-essential libtool libtool-bin | ||
- name: Get OpenMPI Source | ||
uses: actions/[email protected] | ||
repository: 'open-mpi/ompi' | ||
path: 'ompi' | ||
submodules: recursive | ||
- name: Get OpenMPI commit hash | ||
shell: bash | ||
id: get-sha | ||
run: | | ||
cd $GITHUB_WORKSPACE/ompi | ||
export OPENMPI_SHA=$(git rev-parse HEAD) | ||
echo "OPENMPI_SHA=$OPENMPI_SHA" >> $GITHUB_ENV | ||
echo "sha=$OPENMPI_SHA" >> $GITHUB_OUTPUT | ||
# Output SHA for debugging | ||
echo "OPENMPI_SHA=$OPENMPI_SHA" | ||
- name: Cache OpenMPI (GCC) installation | ||
id: cache-openmpi-ubuntu-gcc | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ inputs.install_path }} | ||
key: ${{ runner.os }}-${{ runner.arch }}-gcc-openmpi-${{ steps.get-sha.outputs.sha }} | ||
- name: Install OpenMPI (GCC) (Production) | ||
if: ${{ steps.cache-openmpi-ubuntu-gcc.cache-hit != 'true' && (inputs.build_mode != 'debug') }} | ||
run: | | ||
cd $GITHUB_WORKSPACE/ompi | ||
./autogen.pl | ||
./configure \ | ||
CC=gcc \ | ||
--prefix=${{ inputs.install_path }} | ||
make -j2 | ||
make install | ||
- name: Install OpenMPI (GCC) (Debug) | ||
if: ${{ steps.cache-openmpi-ubuntu-gcc.cache-hit != 'true' && (inputs.build_mode == 'debug') }} | ||
run: | | ||
cd $GITHUB_WORKSPACE/ompi | ||
./autogen.pl | ||
./configure \ | ||
CC=gcc \ | ||
--prefix=${{ inputs.install_path }} \ | ||
--enable-debug | ||
make -j2 | ||
make install |