Skip to content

spack

spack #38

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
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-install:
name: Test Installation & Execution
# Only run on pull requests or manual workflow dispatch to save CI time
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
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 System Dependencies
run: |
sudo apt-get update
sudo apt-get install -y gfortran cmake libopenblas-dev libfftw3-dev libhdf5-dev
- 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
# Add binary cache mirror for pre-built packages
spack mirror add binary_mirror https://binaries.spack.io/v0.23.1
spack buildcache keys --install --trust
# Mark system packages as external to avoid building
spack external find --not-buildable cmake python perl gfortran gcc
spack config add "packages:all:target:[x86_64]"
- name: Cache Spack Dependencies
id: spack-cache
uses: actions/cache@v4
with:
path: |
spack/opt/spack
spack/var/spack/cache
key: spack-deps-${{ runner.os }}-${{ hashFiles('packaging/spack/package.py') }}
restore-keys: |
spack-deps-${{ runner.os }}-
- name: Check Cache Status
run: |
if [ "${{ steps.spack-cache.outputs.cache-hit }}" == "true" ]; then
echo "✓ Cache hit! Dependencies already built."
. spack/share/spack/setup-env.sh
spack find
else
echo "⚠ Cache miss. Will build dependencies from source (~30-40 min)."
fi
- 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
- name: Install MFC Dependencies
run: |
. spack/share/spack/setup-env.sh
# Install just the dependencies first (these are cached)
spack install --show-log-on-error --only dependencies mfc@master~mpi~post_process
- name: Install MFC via Spack
run: |
. spack/share/spack/setup-env.sh
# Install MFC itself (dependencies are already installed/cached)
spack install --show-log-on-error mfc@master~mpi~post_process
- name: Test MFC Execution
run: |
. spack/share/spack/setup-env.sh
spack load mfc
# Verify binaries are available
which pre_process
which simulation
echo "✓ Binaries found"
# Create test directory
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"
# Run simulation (just 1 step to verify it works)
simulation
echo "✓ Simulation completed"