Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflows #218

Merged
merged 80 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
b76ec28
initial commit build-and-test.yml
justinlaughlin Mar 26, 2024
ac953d6
update action versions
justinlaughlin Mar 26, 2024
682a301
move PATH/PYTHONPATH to separate action and export via GITHUB_ENV and…
justinlaughlin Mar 27, 2024
002c726
lots of changes to build-and-test.yml
justinlaughlin Apr 4, 2024
406912e
attempting to test; adding workflow_dispatch to 'on'
justinlaughlin Apr 5, 2024
a935d14
remove conditional for trigger
justinlaughlin Apr 5, 2024
fa2eb0b
remove matrix options for testing, setting fail fast to true, fixing …
justinlaughlin Apr 5, 2024
adc2636
GITHUB_ENV cant be accessed until next step
justinlaughlin Apr 5, 2024
7e9041c
fix bools
justinlaughlin Apr 5, 2024
f48877e
removing unnecessary dependencies?
justinlaughlin Apr 6, 2024
c523745
removing trailing whitespace
justinlaughlin Apr 8, 2024
4394196
remove numba_scipy dependency from ex25 and ex25p
justinlaughlin Apr 8, 2024
3c4d14a
add numba to requirements.txt and removed from CI
justinlaughlin Apr 8, 2024
6984965
remove swig install from CI becuase it is in requirements.txt
justinlaughlin Apr 8, 2024
b7ab2eb
clean up CI script
justinlaughlin Apr 8, 2024
d37646f
trying to add numba-scipy to requirements
justinlaughlin Apr 8, 2024
bb8025b
typo
justinlaughlin Apr 8, 2024
7c3e0ca
comment out print for now
justinlaughlin Apr 8, 2024
3db7c84
remove env.SANDBOX
justinlaughlin Apr 8, 2024
bf14b27
hopefully fixed python package print out
justinlaughlin Apr 8, 2024
9eae6ea
remove numba-scipy
justinlaughlin Apr 8, 2024
71329ea
pip list
justinlaughlin Apr 9, 2024
dba224a
cleanup
justinlaughlin Apr 9, 2024
fc441ea
little bit more cleanup and re-add numba-scipy (even though it is not…
justinlaughlin Apr 9, 2024
5b738f1
remove sandbox
justinlaughlin Apr 9, 2024
0bd3beb
more cleanup
justinlaughlin Apr 9, 2024
3978301
trying flag for phased build
justinlaughlin Apr 10, 2024
11c0a24
Adding in rest of flags (WIP)
justinlaughlin Apr 10, 2024
8667ef5
change matrix so that 'phases' build is only tested once
justinlaughlin Apr 10, 2024
1313526
fix job name, exclude macos+cuda, add cuda run file
justinlaughlin Apr 10, 2024
20123cf
fix typo
justinlaughlin Apr 10, 2024
84befb8
fix formatting
justinlaughlin Apr 10, 2024
8a8ce35
vscode linter doesn't like it, but is it the right syntax?
justinlaughlin Apr 10, 2024
926d52c
trying gh action format() instead (I don't think nested variables works)
justinlaughlin Apr 10, 2024
81734d5
another formatting attempt
justinlaughlin Apr 10, 2024
9c3f999
another formatting attempt
justinlaughlin Apr 10, 2024
e411cd4
another formatting attempt
justinlaughlin Apr 10, 2024
f7fba22
another formatting attempt
justinlaughlin Apr 10, 2024
467ea00
another formatting attempt
justinlaughlin Apr 10, 2024
c345200
another formatting attempt; os needed to be in 'include'
justinlaughlin Apr 10, 2024
0424edb
use yaml > syntax
justinlaughlin Apr 11, 2024
1764cca
update name
justinlaughlin Apr 11, 2024
7dbb88f
change cuda install to sudo and update name/flag formatting
justinlaughlin Apr 11, 2024
a19a326
update cuda install
justinlaughlin Apr 11, 2024
234a33e
update cuda install
justinlaughlin Apr 11, 2024
8d00a87
need to escape single quote for mfem-branch flag
justinlaughlin Apr 11, 2024
69397bd
remove CUDA env var
justinlaughlin Apr 11, 2024
0096669
change run to source for cuda
justinlaughlin Apr 15, 2024
ddfa4b5
use sudo sh for cuda run script
justinlaughlin Apr 15, 2024
022c7f3
debugging
justinlaughlin Apr 15, 2024
80983ed
trying apt
justinlaughlin Apr 15, 2024
db1fdce
add update
justinlaughlin Apr 15, 2024
6637625
break up build into phases. test cuda and non-cuda
justinlaughlin Apr 15, 2024
4a631a3
toolkit flag
justinlaughlin Apr 16, 2024
b6610d0
test only cuda
justinlaughlin Apr 16, 2024
f01f7ad
use cuda script
justinlaughlin Apr 16, 2024
07ea801
typo
justinlaughlin Apr 16, 2024
d3c33fb
compare with run file
justinlaughlin Apr 16, 2024
d80b4d6
remove driver flag
justinlaughlin Apr 16, 2024
6b45cdb
cleanup
justinlaughlin Apr 16, 2024
28ae5a7
a lot more cleanup and testing actions/cache@v4 with CUDA since it is…
justinlaughlin Apr 16, 2024
c6f251e
syntax fix
justinlaughlin Apr 16, 2024
3be2363
another attempt at syntax fix
justinlaughlin Apr 16, 2024
0f320b8
debugging cache
justinlaughlin Apr 16, 2024
db228b5
more debugging cache
justinlaughlin Apr 16, 2024
8ac4efd
debug cache
justinlaughlin Apr 16, 2024
61a1f6f
testing cuda ache
justinlaughlin Apr 16, 2024
6b8fa84
rerun and see if cache works
justinlaughlin Apr 16, 2024
1b3aaa4
cleanup; run matrix
justinlaughlin Apr 16, 2024
5eba2cb
python versions must be strings because of 3.10
justinlaughlin Apr 16, 2024
110a0da
add more to matrix, turn off fail fast, update requirements
justinlaughlin Apr 16, 2024
a8166ab
add back in a single case where build is run all at once
justinlaughlin Apr 19, 2024
8b2b103
change python versions to 3.7-3.11 (3.12 is not supported by librarie…
justinlaughlin Apr 19, 2024
02fc931
cleanup and add comments
justinlaughlin Apr 19, 2024
c27e9df
flag for setup.py should be --vv, not --verbose
justinlaughlin Apr 19, 2024
dbc524e
move cuda-version to env and change to dict
justinlaughlin Apr 19, 2024
ea0f04f
fix env var
justinlaughlin Apr 19, 2024
bdf20c4
remove swig clean line
justinlaughlin Apr 19, 2024
838e8ff
fixed indentation
justinlaughlin Apr 19, 2024
4876868
hopefully this fixes the yaml error
justinlaughlin Apr 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 178 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
# build-and-test.yml
#
# - Builds PyMFEM in three stages:
# - MFEM dependencies + MFEM
# - SWIG bindings
# - PyMFEM
# - Runs tests under `run_examples.py`
# - If there is a failure, uploads test outputs as an artifact

name: Build and Test

on:
workflow_dispatch:
pull_request:
# TODO: setup a trigger to run on MFEM releases

jobs:
build-and-test:
strategy:
fail-fast: false
matrix:
# ---------- Main ----------
os: [ubuntu-latest, macos-latest]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] # 3.12 is not supported by scipy
# NOTE: If setup.py could accept a commit hash as an argument, that could give us more flexibility here
mfem-branch: [master, default] # 'default' uses a specific commit hash defined in setup.py:repos_sha
parallel: [false, true]

# ---------- Dependencies ----------
cuda: [true]
libceed: [false]
gslib: [true]

# ---------- Build process ----------
# When phases==true, run each individual build step explicitly: mfem -> swig -> pymfem
phases: [true]

exclude:
# CUDA does not support MacOS
- os: macos-latest
cuda: true

include:
# Include a single example where the build is executed all at once
- os: ubuntu-latest
python-version: 3.9
mfem-branch: default
parallel: false
cuda: false
libceed: false
gslib: true
phases: false

runs-on: ${{ matrix.os }}

# Reference for $${{ x && y || z }} syntax: 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-toolkit-version: '12.4.1'
cuda-driver-version: '550.54.15'
# These are all passed to setup.py as one concatenated string
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)) || '' }}

# -------------------------------------------------------------------------------------------------
# Begin workflow
# -------------------------------------------------------------------------------------------------
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 }}

# -------------------------------------------------------------------------------------------------
# Download/install dependencies
# -------------------------------------------------------------------------------------------------
- name: Install core dependencies via requirements.txt
run: pip install -r requirements.txt --verbose

- name: Install MPI
if: matrix.parallel
run: |
sudo apt-get install mpich libmpich-dev
pip install mpi4py

- name: Cache CUDA
if: matrix.cuda
id: cache-cuda
uses: actions/cache@v4
with:
path: ~/cache
key: cuda-installer-${{ env.cuda-toolkit-version }}-${{ env.cuda-driver-version }}

- name: Download CUDA
if: matrix.cuda && steps.cache-cuda.outputs.cache-hit == false
run: |
CUDA_URL="https://developer.download.nvidia.com/compute/cuda/${{ env.cuda-toolkit-version }}/local_installers/cuda_${{ env.cuda-toolkit-version }}_${{ env.cuda-driver-version }}_linux.run"
curl -o ~/cache/cuda.run --create-dirs $CUDA_URL

- name: Install CUDA
if: matrix.cuda
run: |
# The --silent flag is necessary to bypass user-input, e.g. accepting the EULA
sudo sh ~/cache/cuda.run --silent --toolkit
echo "/usr/local/cuda/bin" >> $GITHUB_PATH

- name: Print dependency information
run: |
pip list
printf "\n\n---------- MPI ----------\n"
mpiexec --version || printf "MPI not installed"
printf "\n\n---------- CUDA ----------\n"
nvcc --version || printf "CUDA not installed"

# -------------------------------------------------------------------------------------------------
# Build MFEM + SWIG Bindings + PyMFEM
# -------------------------------------------------------------------------------------------------
- name: Build MFEM (step 1)
if: matrix.phases
run: python setup.py install --ext-only --vv ${{ env.build-flags }}

- name: Build SWIG wrappers (step 2)
if: matrix.phases
run: python setup.py install --swig --vv ${{ env.build-flags }}

- name: Build PyMFEM (step 3)
if: matrix.phases
run: python setup.py install --skip-ext --skip-swig --vv ${{ env.build-flags }}

- name: Build all (steps 1-3)
if: matrix.phases == false
run: python setup.py install --vv ${{ env.build-flags }}

# -------------------------------------------------------------------------------------------------
# Run tests
# -------------------------------------------------------------------------------------------------
- name: Run tests (serial)
if: matrix.parallel == false
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

# -------------------------------------------------------------------------------------------------
# Generate an artifact (output of tests) on failure
# -------------------------------------------------------------------------------------------------
- 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
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
2 changes: 0 additions & 2 deletions examples/ex25.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

'''
from numba import jit, types, carray
import numba
import numba_scipy
import os
import mfem.ser as mfem
from mfem.ser import intArray
Expand Down
2 changes: 0 additions & 2 deletions examples/ex25p.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

'''
from numba import jit, types, carray
import numba
import numba_scipy
import os
import mfem.par as mfem
from mfem.par import intArray
Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
numpy>=1.19.4; python_version<"3.7"
numpy>=1.20.0; python_version>="3.7"
numpy >= 1.20.0
numba
numba-scipy
scipy
swig >= 4.1.1
cmake

cmake
Loading