|
| 1 | +name: 'Spack Package' |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths: |
| 6 | + - 'packaging/spack/**' |
| 7 | + - '.github/workflows/spack.yml' |
| 8 | + pull_request: |
| 9 | + paths: |
| 10 | + - 'packaging/spack/**' |
| 11 | + - '.github/workflows/spack.yml' |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +jobs: |
| 15 | + lint: |
| 16 | + name: Spack Lint & Audit |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - name: Checkout MFC |
| 20 | + uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + path: mfc-source |
| 23 | + |
| 24 | + - name: Setup Python |
| 25 | + uses: actions/setup-python@v5 |
| 26 | + with: |
| 27 | + python-version: '3.11' |
| 28 | + |
| 29 | + - name: Install Spack |
| 30 | + run: | |
| 31 | + git clone --depth=1 https://github.com/spack/spack.git |
| 32 | + echo "${GITHUB_WORKSPACE}/spack/bin" >> $GITHUB_PATH |
| 33 | +
|
| 34 | + - name: Setup Spack |
| 35 | + run: | |
| 36 | + . spack/share/spack/setup-env.sh |
| 37 | + spack compiler find |
| 38 | +
|
| 39 | + - name: Create Spack Repository |
| 40 | + run: | |
| 41 | + . spack/share/spack/setup-env.sh |
| 42 | + spack repo create mfc-repo |
| 43 | + mkdir -p mfc-repo/packages/mfc |
| 44 | + cp mfc-source/packaging/spack/package.py mfc-repo/packages/mfc/ |
| 45 | + spack repo add mfc-repo |
| 46 | +
|
| 47 | + - name: Run Spack Style Check |
| 48 | + run: | |
| 49 | + . spack/share/spack/setup-env.sh |
| 50 | + spack style --fix mfc-repo/packages/mfc/package.py |
| 51 | + # Check if style made any changes |
| 52 | + if ! git -C mfc-repo diff --quiet; then |
| 53 | + echo "::warning::Style issues found - run 'spack style --fix' on package.py" |
| 54 | + git -C mfc-repo diff |
| 55 | + fi |
| 56 | +
|
| 57 | + - name: Run Spack Audit |
| 58 | + run: | |
| 59 | + . spack/share/spack/setup-env.sh |
| 60 | + spack audit packages mfc |
| 61 | +
|
| 62 | + - name: Verify Package Info |
| 63 | + run: | |
| 64 | + . spack/share/spack/setup-env.sh |
| 65 | + spack info mfc |
| 66 | +
|
| 67 | + test-concretize: |
| 68 | + name: Test Concretization |
| 69 | + runs-on: ubuntu-latest |
| 70 | + strategy: |
| 71 | + matrix: |
| 72 | + spec: |
| 73 | + - 'mfc' # Default configuration |
| 74 | + - 'mfc~mpi' # No MPI |
| 75 | + - 'mfc~post_process' # No post-processing |
| 76 | + - 'mfc precision=single' # Single precision |
| 77 | + - 'mfc+mpi+post_process precision=double' # Full build |
| 78 | + - 'mfc %gcc@11' # Specific compiler |
| 79 | + fail-fast: false |
| 80 | + |
| 81 | + steps: |
| 82 | + - name: Checkout MFC |
| 83 | + uses: actions/checkout@v4 |
| 84 | + with: |
| 85 | + path: mfc-source |
| 86 | + |
| 87 | + - name: Setup Python |
| 88 | + uses: actions/setup-python@v5 |
| 89 | + with: |
| 90 | + python-version: '3.11' |
| 91 | + |
| 92 | + - name: Install Spack |
| 93 | + run: | |
| 94 | + git clone --depth=1 https://github.com/spack/spack.git |
| 95 | + echo "${GITHUB_WORKSPACE}/spack/bin" >> $GITHUB_PATH |
| 96 | +
|
| 97 | + - name: Setup Spack |
| 98 | + run: | |
| 99 | + . spack/share/spack/setup-env.sh |
| 100 | + spack compiler find |
| 101 | +
|
| 102 | + - name: Create Spack Repository |
| 103 | + run: | |
| 104 | + . spack/share/spack/setup-env.sh |
| 105 | + spack repo create mfc-repo |
| 106 | + mkdir -p mfc-repo/packages/mfc |
| 107 | + cp mfc-source/packaging/spack/package.py mfc-repo/packages/mfc/ |
| 108 | + spack repo add mfc-repo |
| 109 | +
|
| 110 | + - name: Test Spec Concretization |
| 111 | + run: | |
| 112 | + . spack/share/spack/setup-env.sh |
| 113 | + spack spec ${{ matrix.spec }} |
| 114 | +
|
| 115 | + test-install: |
| 116 | + name: Test Installation |
| 117 | + runs-on: ubuntu-latest |
| 118 | + strategy: |
| 119 | + matrix: |
| 120 | + config: |
| 121 | + - spec: 'mfc~mpi~post_process' |
| 122 | + desc: 'Minimal build' |
| 123 | + - spec: 'mfc+mpi~post_process' |
| 124 | + desc: 'MPI without post-processing' |
| 125 | + fail-fast: false |
| 126 | + |
| 127 | + steps: |
| 128 | + - name: Checkout MFC |
| 129 | + uses: actions/checkout@v4 |
| 130 | + with: |
| 131 | + path: mfc-source |
| 132 | + |
| 133 | + - name: Setup Python |
| 134 | + uses: actions/setup-python@v5 |
| 135 | + with: |
| 136 | + python-version: '3.11' |
| 137 | + |
| 138 | + - name: Install System Dependencies |
| 139 | + run: | |
| 140 | + sudo apt-get update |
| 141 | + sudo apt-get install -y \ |
| 142 | + build-essential \ |
| 143 | + gfortran \ |
| 144 | + cmake \ |
| 145 | + libopenmpi-dev \ |
| 146 | + openmpi-bin |
| 147 | +
|
| 148 | + - name: Install Spack |
| 149 | + run: | |
| 150 | + git clone --depth=1 https://github.com/spack/spack.git |
| 151 | + echo "${GITHUB_WORKSPACE}/spack/bin" >> $GITHUB_PATH |
| 152 | +
|
| 153 | + - name: Setup Spack |
| 154 | + run: | |
| 155 | + . spack/share/spack/setup-env.sh |
| 156 | + spack compiler find |
| 157 | + # Use system packages to speed up build |
| 158 | + spack external find --not-buildable cmake |
| 159 | + spack external find python |
| 160 | +
|
| 161 | + - name: Create Spack Repository |
| 162 | + run: | |
| 163 | + . spack/share/spack/setup-env.sh |
| 164 | + spack repo create mfc-repo |
| 165 | + mkdir -p mfc-repo/packages/mfc |
| 166 | + cp mfc-source/packaging/spack/package.py mfc-repo/packages/mfc/ |
| 167 | + spack repo add mfc-repo |
| 168 | +
|
| 169 | + - name: Install MFC (${{ matrix.config.desc }}) |
| 170 | + run: | |
| 171 | + . spack/share/spack/setup-env.sh |
| 172 | + spack install --show-log-on-error ${{ matrix.config.spec }} |
| 173 | + timeout-minutes: 60 |
| 174 | + |
| 175 | + - name: Load and Test MFC |
| 176 | + run: | |
| 177 | + . spack/share/spack/setup-env.sh |
| 178 | + spack load mfc |
| 179 | + # Verify binaries are available |
| 180 | + which pre_process |
| 181 | + which simulation |
| 182 | + pre_process --help || true |
| 183 | + simulation --help || true |
| 184 | +
|
| 185 | + - name: Test Uninstall |
| 186 | + run: | |
| 187 | + . spack/share/spack/setup-env.sh |
| 188 | + spack uninstall -y mfc |
| 189 | +
|
| 190 | + test-conflicts: |
| 191 | + name: Test Conflict Detection |
| 192 | + runs-on: ubuntu-latest |
| 193 | + strategy: |
| 194 | + matrix: |
| 195 | + invalid-spec: |
| 196 | + - spec: 'mfc+openacc+openmp' |
| 197 | + reason: 'OpenACC and OpenMP are mutually exclusive' |
| 198 | + - spec: 'mfc+openacc %gcc' |
| 199 | + reason: 'OpenACC requires NVHPC or Cray compiler' |
| 200 | + fail-fast: false |
| 201 | + |
| 202 | + steps: |
| 203 | + - name: Checkout MFC |
| 204 | + uses: actions/checkout@v4 |
| 205 | + with: |
| 206 | + path: mfc-source |
| 207 | + |
| 208 | + - name: Setup Python |
| 209 | + uses: actions/setup-python@v5 |
| 210 | + with: |
| 211 | + python-version: '3.11' |
| 212 | + |
| 213 | + - name: Install Spack |
| 214 | + run: | |
| 215 | + git clone --depth=1 https://github.com/spack/spack.git |
| 216 | + echo "${GITHUB_WORKSPACE}/spack/bin" >> $GITHUB_PATH |
| 217 | +
|
| 218 | + - name: Setup Spack |
| 219 | + run: | |
| 220 | + . spack/share/spack/setup-env.sh |
| 221 | + spack compiler find |
| 222 | +
|
| 223 | + - name: Create Spack Repository |
| 224 | + run: | |
| 225 | + . spack/share/spack/setup-env.sh |
| 226 | + spack repo create mfc-repo |
| 227 | + mkdir -p mfc-repo/packages/mfc |
| 228 | + cp mfc-source/packaging/spack/package.py mfc-repo/packages/mfc/ |
| 229 | + spack repo add mfc-repo |
| 230 | +
|
| 231 | + - name: Test Invalid Spec (${{ matrix.invalid-spec.reason }}) |
| 232 | + run: | |
| 233 | + . spack/share/spack/setup-env.sh |
| 234 | + # This should fail |
| 235 | + if spack spec ${{ matrix.invalid-spec.spec }} 2>&1; then |
| 236 | + echo "::error::Expected spec to fail but it succeeded: ${{ matrix.invalid-spec.spec }}" |
| 237 | + exit 1 |
| 238 | + else |
| 239 | + echo "✓ Correctly detected conflict: ${{ matrix.invalid-spec.reason }}" |
| 240 | + fi |
0 commit comments