Skip to content

Spack package

Spack package #42

Workflow file for this run

name: 'Spack Package'
on:
push:
paths:
- 'packaging/spack/**'
- '.github/workflows/spack.yml'
pull_request:
paths:
- 'packaging/spack/**'
- '.github/workflows/spack.yml'
workflow_dispatch:
jobs:
lint:
name: Spack Lint & Style Check
runs-on: ubuntu-latest
steps:
- name: Checkout MFC
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Spack
run: |
git clone --depth=1 https://github.com/spack/spack.git
echo "${GITHUB_WORKSPACE}/spack/bin" >> $GITHUB_PATH
- name: Setup Spack
run: |
. spack/share/spack/setup-env.sh
spack compiler find
- name: Install Package into Spack
run: |
. spack/share/spack/setup-env.sh
# Find the actual builtin repo location
BUILTIN_REPO=$(spack repo list | grep builtin | awk '{print $NF}')
echo "Builtin repo location: $BUILTIN_REPO"
# Copy package file to the builtin repo
mkdir -p "$BUILTIN_REPO/packages/mfc"
cp packaging/spack/package.py "$BUILTIN_REPO/packages/mfc/"
# Verify package is visible
spack list mfc
# Show package info to confirm it loads
spack info mfc
- name: Run Spack Style Check
run: |
. spack/share/spack/setup-env.sh
# Skip flake8 F405 warnings which are expected for star imports in Spack packages
spack style -s flake8 packaging/spack/package.py
- name: Run Spack Audit
run: |
. spack/share/spack/setup-env.sh
spack audit packages mfc
- name: Verify Package Info
run: |
. spack/share/spack/setup-env.sh
spack info mfc
- name: Run Package Logic Tests
run: |
cd packaging/spack
python3 test-package-logic.py
test-spec:
name: Test Package Spec
runs-on: ubuntu-latest
steps:
- name: Checkout MFC
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Spack
run: |
git clone --depth=1 https://github.com/spack/spack.git
echo "${GITHUB_WORKSPACE}/spack/bin" >> $GITHUB_PATH
- name: Setup Spack
run: |
. spack/share/spack/setup-env.sh
spack compiler find
- name: Install Package into Spack
run: |
. spack/share/spack/setup-env.sh
# Find the actual builtin repo location
BUILTIN_REPO=$(spack repo list | grep builtin | awk '{print $NF}')
echo "Builtin repo location: $BUILTIN_REPO"
# Copy package file to the builtin repo
mkdir -p "$BUILTIN_REPO/packages/mfc"
cp packaging/spack/package.py "$BUILTIN_REPO/packages/mfc/"
# Verify package is visible
spack list mfc
# Show package info to confirm it loads
spack info mfc
- name: Test Default Spec
run: |
. spack/share/spack/setup-env.sh
spack spec mfc
- name: Test Minimal Spec
run: |
. spack/share/spack/setup-env.sh
spack spec mfc~mpi~post_process
test-hpc-variants:
name: Test HPC-Specific Configurations
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
# NVIDIA GPU configurations
- name: "NVIDIA V100 (Summit)"
spec: "mfc+openacc cuda_arch=70 %nvhpc"
description: "OLCF Summit configuration"
- name: "NVIDIA A100 (Perlmutter)"
spec: "mfc+openmp cuda_arch=80 %nvhpc"
description: "NERSC Perlmutter configuration"
- name: "NVIDIA H100"
spec: "mfc+openacc cuda_arch=90 %nvhpc"
description: "Latest NVIDIA GPU"
# AMD GPU configurations
- name: "AMD MI250X (Frontier)"
spec: "mfc+openacc amdgpu_target=gfx90a %cce"
description: "OLCF Frontier configuration"
- name: "AMD MI300A (El Capitan)"
spec: "mfc+openmp amdgpu_target=gfx942 %cce"
description: "LLNL El Capitan configuration"
# Precision variants
- name: "Single Precision"
spec: "mfc precision=single"
description: "Single precision build"
# Chemistry variant
- name: "Chemistry Enabled"
spec: "mfc+chemistry"
description: "With thermochemistry support"
# Minimal build
- name: "Minimal (no MPI, no post)"
spec: "mfc~mpi~post_process"
description: "Minimal configuration"
steps:
- name: Checkout MFC
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Spack
run: |
git clone --depth=1 https://github.com/spack/spack.git
echo "${GITHUB_WORKSPACE}/spack/bin" >> $GITHUB_PATH
- name: Setup Spack
run: |
. spack/share/spack/setup-env.sh
spack compiler find
- name: Install Package into Spack
run: |
. spack/share/spack/setup-env.sh
BUILTIN_REPO=$(spack repo list | grep builtin | awk '{print $NF}')
mkdir -p "$BUILTIN_REPO/packages/mfc"
cp packaging/spack/package.py "$BUILTIN_REPO/packages/mfc/"
spack list mfc
- name: Test ${{ matrix.name }}
run: |
. spack/share/spack/setup-env.sh
echo "Testing: ${{ matrix.description }}"
echo "Spec: ${{ matrix.spec }}"
# Test that spec can be concretized
if spack spec ${{ matrix.spec }}; then
echo "✓ Spec concretization successful"
else
echo "✗ Spec concretization failed"
exit 1
fi
continue-on-error: true
- name: Verify Spec Output
run: |
. spack/share/spack/setup-env.sh
echo "=== Full spec details for ${{ matrix.name }} ==="
spack spec --reuse ${{ matrix.spec }} || true
test-install-matrix:
name: Test Installation on ${{ matrix.os }} - ${{ matrix.config }}
runs-on: ${{ matrix.os }}
# Run on PR and manual dispatch for thorough testing
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
strategy:
fail-fast: false
matrix:
include:
# Ubuntu - GCC builds
- os: ubuntu-22.04
config: "Default (GCC + MPI)"
spec: "mfc@master"
compiler: "gcc"
test_mpi: true
- os: ubuntu-22.04
config: "Minimal (no MPI)"
spec: "mfc@master~mpi~post_process"
compiler: "gcc"
test_mpi: false
- os: ubuntu-22.04
config: "Single Precision"
spec: "mfc@master precision=single~post_process"
compiler: "gcc"
test_mpi: false
- os: ubuntu-22.04
config: "With Chemistry"
spec: "mfc@master+chemistry~mpi~post_process"
compiler: "gcc"
test_mpi: false
# Ubuntu 20.04 for older environment
- os: ubuntu-20.04
config: "Ubuntu 20.04 baseline"
spec: "mfc@master~mpi~post_process"
compiler: "gcc"
test_mpi: false
# macOS builds
- os: macos-13
config: "macOS Intel"
spec: "mfc@master~mpi~post_process"
compiler: "gcc"
test_mpi: false
- os: macos-14
config: "macOS ARM (M1)"
spec: "mfc@master~mpi~post_process"
compiler: "gcc"
test_mpi: false
steps:
- name: Checkout MFC
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install System Dependencies (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y gfortran cmake libopenblas-dev libfftw3-dev libhdf5-dev
if [ "${{ matrix.test_mpi }}" == "true" ]; then
sudo apt-get install -y libopenmpi-dev openmpi-bin
fi
- name: Install System Dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install gcc cmake fftw hdf5 openblas
- name: Install Spack
run: |
git clone --depth=1 https://github.com/spack/spack.git
echo "${GITHUB_WORKSPACE}/spack/bin" >> $GITHUB_PATH
- name: Setup Spack with Binary Cache
run: |
. spack/share/spack/setup-env.sh
spack compiler find
echo "Found compilers:"
spack compiler list
# Add binary cache for faster builds
spack mirror add binary_mirror https://binaries.spack.io/v0.23.1
spack buildcache keys --install --trust || true
# Mark system packages as external
spack external find --not-buildable cmake python perl || true
if [ "${{ runner.os }}" == "Linux" ]; then
spack external find --not-buildable gfortran gcc || true
fi
- name: Cache Spack Dependencies
id: spack-cache
uses: actions/cache@v4
with:
path: |
spack/opt/spack
spack/var/spack/cache
key: spack-deps-${{ matrix.os }}-${{ matrix.config }}-${{ hashFiles('packaging/spack/package.py') }}
restore-keys: |
spack-deps-${{ matrix.os }}-${{ matrix.config }}-
spack-deps-${{ matrix.os }}-
- name: Install Package into Spack
run: |
. spack/share/spack/setup-env.sh
BUILTIN_REPO=$(spack repo list | grep builtin | awk '{print $NF}')
echo "Builtin repo location: $BUILTIN_REPO"
mkdir -p "$BUILTIN_REPO/packages/mfc"
cp packaging/spack/package.py "$BUILTIN_REPO/packages/mfc/"
spack list mfc
echo "Testing spec: ${{ matrix.spec }}"
spack spec ${{ matrix.spec }}
- name: Install MFC via Spack
timeout-minutes: 90
run: |
. spack/share/spack/setup-env.sh
echo "Installing: ${{ matrix.spec }}"
spack install --show-log-on-error --verbose ${{ matrix.spec }}
- name: Verify Installation
run: |
. spack/share/spack/setup-env.sh
spack load mfc
echo "=== Installed files ==="
spack find -p mfc
echo "=== Checking binaries ==="
which pre_process || (echo "pre_process not found" && exit 1)
which simulation || (echo "simulation not found" && exit 1)
echo "=== Binary info ==="
file $(which pre_process)
file $(which simulation)
if [ "${{ matrix.test_mpi }}" == "false" ]; then
# For non-MPI builds, check that binaries are not linked to MPI
if ldd $(which simulation) 2>/dev/null | grep -i mpi; then
echo "ERROR: Non-MPI build is linked to MPI!"
exit 1
fi
echo "✓ Confirmed non-MPI build"
fi
- name: Test MFC Execution
run: |
. spack/share/spack/setup-env.sh
spack load mfc
mkdir -p test_run
cd test_run
# Copy example case
cp ../examples/1D_sodshocktube/case.py .
# Generate case configuration
python3 case.py > case.json
echo "✓ Generated case configuration"
# Run pre_process
pre_process < case.json
echo "✓ Pre-processing completed"
# Verify pre_process output
if [ ! -f "D/D.dat" ]; then
echo "ERROR: Pre-processing didn't create expected output"
ls -la
exit 1
fi
# Run simulation (verify it executes)
timeout 60 simulation || true
echo "✓ Simulation executed"
- name: Test MPI Execution (if applicable)
if: matrix.test_mpi == true
run: |
. spack/share/spack/setup-env.sh
spack load mfc
cd test_run
echo "=== Testing MPI execution with 2 processes ==="
mpirun -n 2 simulation || true
echo "✓ MPI execution completed"
- name: Upload Build Logs on Failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: build-logs-${{ matrix.os }}-${{ matrix.config }}
path: |
spack/var/spack/stage/*/spack-build-out.txt
spack/var/spack/stage/*/spack-build-env.txt
retention-days: 7