Workflows #47
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
# This is a clean-up/refactor of test_with_MFEM_release.yml | ||
name: Build and Test | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
jobs: | ||
build-and-test: | ||
# if: contains(github.event.pull_request.labels.*.name, 'in-test-with-mfem-release') | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
os: [ubuntu-latest] | ||
#, macos-latest] | ||
python-version: [3.9, 3.11] | ||
#3.7, 3.8, 3.9, 3.10, 3.11 | ||
# right now, default is a hardcoded sha defined in setup.py:repos_sha | ||
mfem-branch: [master, default] | ||
# parallel: [false, true] | ||
# cuda: [false, true] | ||
# temporary: only test cuda | ||
# mfem-branch: [default] | ||
parallel: [false] | ||
cuda: [true] | ||
libceed: [false] | ||
gslib: [true] | ||
# When phases==true, run each individual build step explicitly: mfem -> swig -> pymfem | ||
phases: [false] | ||
exclude: | ||
# CUDA does not support MacOS | ||
- os: macos-latest | ||
cuda: true | ||
# include: | ||
# # Include a single example where the build is executed in phases | ||
# - os: ubuntu-latest | ||
# python-version: 3.9 | ||
# mfem-branch: default | ||
# parallel: false | ||
# cuda: false | ||
# libceed: false | ||
# gslib: true | ||
# phases: true | ||
runs-on: ${{ matrix.os }} | ||
# https://7tonshark.com/posts/github-actions-ternary-operator/ | ||
name: >- | ||
${{ matrix.os }}, | ||
${{ matrix.python-version }}, | ||
${{ matrix.mfem-branch }}, | ||
(${{ matrix.parallel && 'parallel' || 'serial' }}${{ matrix.cuda && ' + cuda' || '' }}${{ matrix.libceed && ' + libceed' || '' }}${{ matrix.gslib && ' + gslib' || '' }}) | ||
env: | ||
cuda-installer-url: https://developer.download.nvidia.com/compute/cuda/12.4.1/local_installers/cuda_12.4.1_550.54.15_linux.run | ||
build-flags: >- | ||
${{ matrix.parallel && '--with-parallel' || '' }} | ||
${{ matrix.cuda && '--with-cuda' || '' }} | ||
${{ matrix.libceed && '--with-libceed' || '' }} | ||
${{ matrix.gslib && '--with-gslib' || '' }} | ||
${{ (!(matrix.mfem-branch == 'default') && format('--mfem-branch=''{0}''', matrix.mfem-branch)) || '' }} | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install core dependencies via requirements.txt | ||
run: pip install -r requirements.txt --verbose | ||
- name: Cache CUDA | ||
if: matrix.cuda | ||
id: cache-cuda | ||
uses: actions/cache@v4 | ||
with: | ||
path: cuda.run | ||
key: cuda-cache | ||
- name: Download CUDA | ||
if: matrix.cuda && steps.cache-cuda.outputs.cache-hit != 'true' | ||
run: wget -q -O cuda.run ${{ env.cuda-installer-url }} | ||
- name: Install CUDA | ||
if: matrix.cuda | ||
run: | | ||
# The --silent flag is necessary to bypass user-input, e.g. accepting the EULA | ||
sudo sh cuda.run --silent --toolkit | ||
echo "/usr/local/cuda/bin" >> $GITHUB_PATH | ||
nvcc --version | ||
- name: Install MPI | ||
if: matrix.parallel | ||
run: | | ||
sudo apt-get install mpich libmpich-dev | ||
pip install mpi4py | ||
- name: Print python package versions | ||
run: pip list | ||
- name: Build MFEM (step 1) | ||
if: matrix.phases | ||
run: | | ||
python setup.py clean --swig | ||
python setup.py install --ext-only --verbose ${{ env.build-flags }} | ||
- name: Build SWIG wrappers (step 2) | ||
if: matrix.phases | ||
run: python setup.py install --swig --verbose ${{ env.build-flags }} | ||
- name: Build PyMFEM (step 3) | ||
if: matrix.phases | ||
run: python setup.py install --skip-ext --skip-swig --verbose ${{ env.build-flags }} | ||
- name: Build all (steps 1-3) | ||
if: !(matrix.phases) | ||
run: python setup.py install ${{ env.build-flags }} | ||
- name: Run tests (serial) | ||
if: !(matrix.parallel) | ||
run: | | ||
cd test | ||
python run_examples.py -serial -verbose | ||
- name: Run tests (parallel) | ||
if: matrix.parallel | ||
run: | | ||
cd test | ||
python run_examples.py -parallel -verbose -np 2 | ||
- name: Generate test results artifact | ||
id: generate-artifact | ||
run: | | ||
tar -cvzf sandbox.tar.gz test/sandbox | ||
# generate a name for the artifact | ||
txt=$(python -c "import datetime;print(datetime.datetime.now().strftime('%H_%M_%S_%f'))") | ||
echo name="test_results_"${txt}"_"${{ github.run_id }}".tar.gz" >> $GITHUB_OUTPUT | ||
- name: Upload Artifact | ||
uses: actions/upload-artifact@v4 | ||
if: failure() | ||
with: | ||
name: ${{ steps.generate-artifact.outputs.name }} | ||
path: sandbox.tar.gz | ||
retention-days: 1 |