Skip to content

Commit

Permalink
CI: test pytao for each bmad commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ken-lauer committed Aug 29, 2024
1 parent b7d369e commit 5a23327
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 29 deletions.
34 changes: 34 additions & 0 deletions .github/actions/conda-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: "conda setup"
description: "Prepare the pytao conda environment"
inputs:
python-version:
description: Python version
required: false
default: "3.9"
environment-file:
description: Conda environment file
required: true
default: "environment.yaml"
runs:
using: "composite"
steps:
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
activate-environment: pytao-dev
use-mamba: true
channels: conda-forge
environment-file: ${{ inputs.environment-file }}
python-version: ${{ inputs.python-version }}

- name: Show the installed packages
shell: bash -l {0}
run: |
conda list
- name: Ensure importability
shell: bash -l {0}
run: |
cd /
python -c "import pytao"
35 changes: 35 additions & 0 deletions .github/actions/setup-dependencies/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: setup-dependencies
description: "Setup system and external dependencies to build bmad"
inputs:
external-packages-version:
description: External packages version
required: false
default: "main"

runs:
using: "composite"
steps:
# Install system dependencies
- name: Install System Dependencies
shell: bash
run: |
sudo apt-get update
sudo apt-get install gfortran g++ cmake libtool-bin libreadline-dev libpango1.0-dev libssl-dev bc libopenmpi-dev openmpi-bin openmpi-common
- name: Checkout external packages
uses: actions/checkout@v4
with:
repository: "bmad-sim/bmad-external-packages"
ref: ${{ inputs.external-packages-version }}
path: "external_packages"
fetch-depth: 1

- name: Move External Packages
shell: bash
run: |
mv external_packages ~/
for dep in ~/external_packages/*; do
if [ $dep != "README.md" ]; then
cp -r $dep $GITHUB_WORKSPACE/;
fi;
done
4 changes: 3 additions & 1 deletion .github/scripts/install_bmad.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

echo "**** Setup Preferences"

echo "Number of processors: $(nproc)"

cat <<EOF >> ./util/dist_prefs
export DIST_F90_REQUEST="gfortran"
export ACC_PLOT_PACKAGE="pgplot"
Expand All @@ -21,7 +23,7 @@ export ACC_ENABLE_SHARED="$SHARED"
export ACC_ENABLE_SHARED_ONLY="$SHARED"
export ACC_ENABLE_FPIC="Y"
export ACC_ENABLE_PROFILING="N"
export ACC_SET_GMAKE_JOBS="2"
export ACC_SET_GMAKE_JOBS="$(nproc)"
EOF

echo "**** Invoking dist_source_me"
Expand Down
34 changes: 6 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ jobs:
runs-on: ${{ matrix.os }}
#
defaults:
run:
shell: bash
run:
shell: bash

strategy:
matrix:
Expand All @@ -49,37 +49,15 @@ jobs:
# Check out the code from GitHub
- uses: actions/checkout@v4

# Install system dependencies
- name: Install System Dependencies
run: |
sudo apt update
sudo apt-get install gfortran g++ cmake libtool-bin libreadline-dev libpango1.0-dev libssl-dev bc libopenmpi-dev openmpi-bin openmpi-common
- uses: ./.github/actions/setup-dependencies
with:
external-packages-version: ${{ env.EXTERNAL_PACKAGES_VERSION }}

# sudo apt install build-essential curl wget cmake gfortran automake \
# autoconf libtool m4 libgomp1 libreadline-dev libncurses-dev pkg-config \
# libcairo2-dev libpango1.0-dev libxt-dev libx11-dev -y

# In case we don't have it available, check it out
- name: Checkout External Packages
run: |
git clone --depth 1 --branch ${{ env.EXTERNAL_PACKAGES_VERSION }} https://github.com/bmad-sim/bmad-external-packages.git ~/external_packages
#
- name: Move External Packages
run: |
for dep in ~/external_packages/*; \
do if [ $dep != "README.md" ]; \
then cp -r $dep $GITHUB_WORKSPACE/; \
fi; \
done
#
- name: Build
- name: Build Bmad
env:
USE_MPI: ${{ matrix.openmp_mpi }}
SHARED: ${{ matrix.shared }}
run: .github/scripts/install_bmad.sh

#
- name: Run Tests
run: .github/scripts/run_tests.sh
54 changes: 54 additions & 0 deletions .github/workflows/pytao.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: PyTao tests

on:
push:
pull_request:
workflow_dispatch:

jobs:
build:
name: ${{ matrix.os }} Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.12"]
shared: ["Y"]
openmp_mpi: ["N"]
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/setup-dependencies
with:
external-packages-version: ${{ env.EXTERNAL_PACKAGES_VERSION }}

- name: Build Bmad
env:
USE_MPI: ${{ matrix.openmp_mpi }}
SHARED: ${{ matrix.shared }}
run: .github/scripts/install_bmad.sh

- uses: actions/checkout@v4
with:
repository: "bmad-sim/pytao"
ref: "master"
path: "pytao"

- uses: ./.github/actions/conda-setup
with:
python-version: ${{ matrix.python-version }}
environment-file: pytao/dev-environment.yml

- name: Run Tests
shell: bash -l {0}
working-directory: ./pytao
run: |
export ACC_ROOT_DIR=$GITHUB_WORKSPACE
echo -e '## Test results\n\n```' >> "$GITHUB_STEP_SUMMARY"
pytest -v --cov=pytao/ pytao/tests 2>&1 | tee -a "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"

0 comments on commit 5a23327

Please sign in to comment.