.github/workflows/main.yml: add proper escape sequences to environmen… #679
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
name: Python CI | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
# Run on the 1st and 15th of each month, at 4:47AM UTC, to check for breakages due to e.g., sympy-dev. | |
schedule: | |
- cron: '47 4 1,15 * *' | |
jobs: | |
static-analysis: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: ['ubuntu-20.04', 'ubuntu-22.04'] | |
python-version: ['3.6.7', '3.7.13', '3.8.18', '3.9.19', '3.x'] | |
exclude: | |
- os: 'ubuntu-22.04' | |
python-version: '3.6.7' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Display Python version | |
run: python --version | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -U -r requirements.txt | |
if [[ "${{ matrix.python-version }}" != "3.6.7" && "${{ matrix.python-version }}" != "3.7.13" ]]; then | |
pip install -U -r requirements-dev.txt | |
else | |
# Install packages from requirements-dev.txt except those with a fixed version. | |
cat requirements-dev.txt | grep -v '==' | xargs pip install -U | |
pip install -U clang-format | |
fi | |
# FIXME: until NRPyLaTeX is updated in pypi. | |
pip install -U git+https://github.com/nrpy/nrpylatex.git | |
pip install -U ipython setuptools | |
sudo apt-get -y install libgsl-dev | |
- name: Install sympy or DEVELOPMENT sympy based on Python version | |
run: | | |
if [[ "${{ matrix.python-version }}" != "3.6.7" && "${{ matrix.python-version }}" != "3.7.13" ]]; then | |
pip install git+https://github.com/sympy/sympy.git | |
else | |
pip install sympy | |
fi | |
- name: Display sympy and clang-format versions | |
run: | | |
echo "Running CI tests with SymPy version = $(isympy --version)" | |
echo "Running CI tests with clang-format version = $(clang-format --version)" | |
- name: Check mypy and black versions when Python != 3.6.7 and != 3.7.13 chosen (they are too broken in those Python versions). | |
if: matrix.python-version != '3.6.7' && matrix.python-version != '3.7.13' | |
run: | | |
mypy --version | |
black --version | |
- name: Run doctests, black, mypy, pylint, pydocstyle, and darglint on each file. | |
run: | | |
failed_tests=() | |
# Use find to locate python files based on pattern or directory structure. | |
# Don't analyze Python scripts in tests/ (though they should pass!) | |
python_files=$(find . -name '*.py' -not -name '__init__.py' -not -path './project/*' -not -path '*/tests/*' -not -path './nrpy/examples/visualization_scripts/*') | |
for python_file in $python_files; do | |
echo "" | |
echo "-={ $python_file }=-" | |
# Initialize step counter | |
step_counter=1 | |
if [[ ! $python_file =~ nrpy/examples/.* ]]; then | |
echo "-={ Step $step_counter: Doctests/run Python module }=-" | |
DOCTEST_MODE=1 PYTHONPATH=.:$PYTHONPATH python $python_file || { failed_tests+=("doctest in $python_file"); break; } | |
((step_counter++)) | |
fi | |
# Turns out that black in Python 3.6 & 3.7 has a heart attack when parsing equations/general_relativity/BSSN_quantities.py: | |
# INTERNAL ERROR: Black produced code that is not equivalent to the source. Please report a bug on .... | |
if [[ "${{ matrix.python-version }}" != "3.6.7" && "${{ matrix.python-version }}" != "3.7.13" && "${{ matrix.python-version }}" != "3.8.18" ]]; then | |
echo "-={ Step $step_counter: black }=-" | |
black --check $python_file || { failed_tests+=("black in $python_file"); break; } | |
((step_counter++)) | |
echo "-={ Step $step_counter: isort }=-" | |
isort --check-only $python_file || { failed_tests+=("isort in $python_file"); break; } | |
((step_counter++)) | |
echo "-={ Step $step_counter: mypy }=-" | |
PYTHONPATH=.:$PYTHONPATH mypy --strict --pretty --allow-untyped-calls $python_file || { failed_tests+=("mypy in $python_file"); break; } | |
((step_counter++)) | |
fi | |
echo "-={ Step $step_counter: pylint }=-" | |
pylint_score="0" | |
if [[ "${{ matrix.python-version }}" == "3.6.7" || "${{ matrix.python-version }}" == "3.7.13" ]]; then | |
pylint_score=$(PYTHONPATH=.:$PYTHONPATH pylint --rcfile=.pylintrc_python36 $python_file | tail -2 | grep -Eo '[0-9\.]+' | head -1 || echo "0") | |
else | |
pylint_score=$(PYTHONPATH=.:$PYTHONPATH pylint --rcfile=.pylintrc $python_file | tail -2 | grep -Eo '[0-9\.]+' | head -1 || echo "0") | |
fi | |
echo "Pylint score is $pylint_score" | |
if (( $(echo "$pylint_score < 9.5" | bc -l) )); then | |
PYTHONPATH=.:$PYTHONPATH pylint --rcfile=.pylintrc $python_file || true | |
echo "Pylint score is below 9.5, failing..." | |
failed_tests+=("pylint in $python_file") | |
break | |
fi | |
((step_counter++)) | |
echo "-={ Step $step_counter: pydocstyle }=-" | |
pydocstyle $python_file || { failed_tests+=("pydocstyle in $python_file"); break; } | |
((step_counter++)) | |
echo "-={ Step $step_counter: darglint }=-" | |
darglint -v 2 $python_file || { failed_tests+=("darglint in $python_file"); break; } | |
((step_counter++)) | |
done | |
if [ ${#failed_tests[@]} -ne 0 ]; then | |
echo "The following tests failed: ${failed_tests[*]}" | |
exit 1 | |
fi | |
einsteintoolkit-validation: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- uses: eWaterCycle/setup-apptainer@v2 | |
with: | |
apptainer-version: 1.3.2 | |
- name: Download Apptainer image | |
run: wget -q https://github.com/nrpy/einsteintoolkit_ci_images/releases/download/v1.0.3/custom_ubuntu.sif | |
- name: Build Apptainer sandbox | |
run: apptainer build --sandbox custom_ubuntu_sandbox custom_ubuntu.sif | |
- name: Run Apptainer container | |
run: | | |
apptainer exec --writable custom_ubuntu_sandbox bash -c " | |
set -e | |
rm -f /opt/FAILED.txt | |
source /opt/jup312/bin/activate | |
export PYTHONPATH=.:\$PYTHONPATH | |
python3 --version && isympy --version | |
cd /opt/jup312/nrpy | |
git pull | |
git log | head | |
python3 -u nrpy/examples/carpet_wavetoy_thorns.py | |
python3 -u nrpy/examples/carpet_baikal_thorns.py | |
cd /opt/ET_2024_06_beta/arrangements/WVUThorns/ | |
rm Baikal* | |
ln -s /opt/jup312/nrpy/project/et_baikal/Baikal* . | |
ln -s /opt/jup312/nrpy/project/et_wavetoy/* . | |
ln -s /opt/jup312/nrpy/nrpy/examples/et_WaveToyfiles/test WaveToyNRPy/ | |
cp -r /opt/ET_2024_06_beta/repos/wvuthorns/Baikal/tes* Baikal/ | |
cp -r /opt/ET_2024_06_beta/repos/wvuthorns/BaikalVacuum/tes* BaikalVacuum/ | |
cd /opt/ET_2024_06_beta/ | |
./make_config-runmefirst-gcc | |
make | |
export CCTK_TESTSUITE_RUN_TESTS='Baikal BaikalVacuum WaveToyNRPy' | |
export PROMPT=no | |
make etilgrmhdgcc-testsuite | |
awk '/Number failed/ { if (\$NF != 0) system(\"touch /opt/FAILED.txt\") }' /opt/ET_2024_06_beta/TEST/etilgrmhdgcc/summary.log | |
if [ -f /opt/FAILED.txt ]; then | |
echo AT LEAST ONE ET TEST FAILED | |
exit 1 | |
else | |
echo ET TESTS SUCCEEDED | |
fi | |
" | |
charmpp-validation: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- uses: eWaterCycle/setup-apptainer@v2 | |
with: | |
apptainer-version: 1.3.2 | |
- name: Download Apptainer image | |
run: wget -q https://github.com/nrpy/charmpp_barebones_ci_images/releases/download/v1.0.0/custom_ubuntu_charmpp.sif | |
- name: Build Apptainer sandbox | |
run: apptainer build --sandbox custom_ubuntu_charmpp_sandbox custom_ubuntu_charmpp.sif | |
- name: Run Apptainer container | |
run: | | |
apptainer exec --writable custom_ubuntu_charmpp_sandbox bash -c " | |
set -e | |
source /opt/jup312/bin/activate | |
export PYTHONPATH=.:\$PYTHONPATH | |
export PATH=/opt/charm-8.0.0/bin:\$PATH | |
export LD_LIBRARY_PATH=/opt/charm-8.0.0/lib:\$LD_LIBRARY_PATH | |
export C_INCLUDE_PATH=/opt/charm-8.0.0/include:\$C_INCLUDE_PATH | |
export CPLUS_INCLUDE_PATH=/opt/charm-8.0.0/include:\$CPLUS_INCLUDE_PATH | |
python3 --version && isympy --version | |
cd /opt/jup312/nrpy | |
git pull | |
git log | head | |
python3 -u nrpy/examples/superB_two_blackholes_collide.py | |
python3 -u nrpy/examples/superB_blackhole_spectroscopy.py | |
cd project/superB_two_blackholes_collide/ | |
make -j2 | |
charmrun +p2 ./superB_two_blackholes_collide | |
cd ../../ | |
cd project/superB_blackhole_spectroscopy/ | |
make -j2 | |
" | |
codegen-ubuntu: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: ['ubuntu-20.04', 'ubuntu-22.04'] | |
python-version: ['3.6.7', '3.7.13', '3.x'] | |
exclude: | |
- os: 'ubuntu-22.04' | |
python-version: '3.6.7' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Display Python version | |
run: python --version | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
if [[ "${{ matrix.python-version }}" != "3.6.7" && "${{ matrix.python-version }}" != "3.7.13" ]]; then pip install -U mypy==1.8.0 black==24.1.1; fi | |
pip install -U pylint clang-format ipython setuptools | |
sudo apt-get -y install libgsl-dev | |
- name: Check that pip installed nrpy creates valid, compilable C example projects | |
run: | | |
pwd && | |
pip install . && | |
mkdir tmp && | |
cd tmp && | |
python -m nrpy.examples.wave_equation_cartesian && (cd project/wavetoy && make && make clean) && | |
python -m nrpy.examples.wave_equation_curvilinear && (cd project/curviwavetoy && make && make clean) && | |
python -m nrpy.examples.nrpyelliptic_conformally_flat && (cd project/nrpyelliptic_conformally_flat && make && make clean) && | |
python -m nrpy.examples.two_blackholes_collide && (cd project/two_blackholes_collide && make && make clean) && | |
python -m nrpy.examples.blackhole_spectroscopy && (cd project/blackhole_spectroscopy && make && make clean) && | |
python -m nrpy.examples.spinning_blackhole && (cd project/spinning_blackhole && make && make clean) && | |
python -m nrpy.examples.nrpypn_quasicircular_momenta && (cd project/nrpypn_quasicircular_momenta && make && make clean) && | |
python -m nrpy.examples.wave_equation_multicoord_wavetoy && (cd project/multicoords_curviwavetoy && make && make clean) && | |
python -m nrpy.examples.seobnrv5_aligned_spin_inspiral && (cd project/seobnrv5_aligned_spin_inspiral && make && make clean) | |
codegen-mac: | |
runs-on: macos-13 | |
strategy: | |
matrix: | |
python-version: [ '3.6.7', '3.7.13', '3.x' ] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Display Python version | |
run: python --version | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
if [[ "${{ matrix.python-version }}" != "3.6.7" && "${{ matrix.python-version }}" != "3.7.13" ]]; then pip install -U mypy==1.8.0 black==24.1.1; fi | |
pip install -U pylint clang-format ipython setuptools | |
brew install gsl | |
- name: Check that pip installed nrpy creates valid, compilable C example projects | |
run: | | |
pwd && | |
pip install . && | |
mkdir tmp && | |
cd tmp && | |
python -m nrpy.examples.wave_equation_cartesian && (cd project/wavetoy && make && make clean) && | |
python -m nrpy.examples.wave_equation_curvilinear && (cd project/curviwavetoy && make && make clean) && | |
python -m nrpy.examples.nrpyelliptic_conformally_flat && (cd project/nrpyelliptic_conformally_flat && make && make clean) && | |
python -m nrpy.examples.two_blackholes_collide && (cd project/two_blackholes_collide && make && make clean) && | |
python -m nrpy.examples.blackhole_spectroscopy && (cd project/blackhole_spectroscopy && make && make clean) && | |
python -m nrpy.examples.spinning_blackhole && (cd project/spinning_blackhole && make && make clean) && | |
python -m nrpy.examples.nrpypn_quasicircular_momenta && (cd project/nrpypn_quasicircular_momenta && make && make clean) && | |
python -m nrpy.examples.wave_equation_multicoord_wavetoy && (cd project/multicoords_curviwavetoy && make && make clean) && | |
python -m nrpy.examples.seobnrv5_aligned_spin_inspiral && (cd project/seobnrv5_aligned_spin_inspiral && make && make clean) |