Skip to content

OpenMDAO Latest

OpenMDAO Latest #319

# Run OpenMDAO tests on latest/pre-release versions
name: OpenMDAO Latest
on:
# Run the workflow every Monday and Thursday at 0400 UTC
schedule:
- cron: '0 4 * * 1,4'
# Allow running the workflow manually from the Actions tab
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
permissions: {}
jobs:
tests:
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
include:
# test latest versions on ubuntu
- NAME: Ubuntu Latest
OS: ubuntu-latest
PY: 3
PETSc: 3
SNOPT: 7.7
runs-on: ${{ matrix.OS }}
name: ${{ matrix.NAME }}
defaults:
run:
shell: bash -l {0}
steps:
- name: Display run details
run: |
echo "============================================================="
echo "Run #${GITHUB_RUN_NUMBER}"
echo "Run ID: ${GITHUB_RUN_ID}"
echo "Testing: ${GITHUB_REPOSITORY}"
echo "Branch: ${GITHUB_BASE_REF}"
echo "Triggered by: ${GITHUB_EVENT_NAME}"
echo "Initiated by: ${GITHUB_ACTOR}"
echo "============================================================="
- name: Create SSH key
if: (matrix.SNOPT || matrix.BUILD_DOCS)
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSH_KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }}
run: |
mkdir -p ~/.ssh/
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
sudo chmod 600 ~/.ssh/id_rsa
echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- name: Checkout code
uses: actions/checkout@v3
- name: Setup conda
uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.PY }}
conda-version: "*"
channels: conda-forge
- name: Install latest versions of [all] openmdao dependencies
run: |
source .github/scripts/install_latest_deps.sh
- name: Install pyOptSparse
run: |
echo "============================================================="
echo "Define useful functions"
echo "============================================================="
function latest_version() {
local REPO_URL=$1/releases/latest
local LATEST_URL=`curl -fsSLI -o /dev/null -w %{url_effective} $REPO_URL`
local LATEST_VER=`echo $LATEST_URL | awk '{split($0,a,"/tag/"); print a[2]}'`
echo $LATEST_VER
}
function latest_branch() {
local LATEST_VER=$(latest_version $1)
echo git+$1@$LATEST_VER
}
echo "============================================================="
echo "Install latest pyoptsparse"
echo "============================================================="
python -m pip install git+https://github.com/OpenMDAO/build_pyoptsparse
BRANCH="-b $(latest_version https://github.com/mdolab/pyoptsparse)"
if [[ "${{ secrets.SNOPT_LOCATION_77 }}" ]]; then
echo " > Secure copying SNOPT 7.7 over SSH"
mkdir SNOPT
scp -qr ${{ secrets.SNOPT_LOCATION_77 }} SNOPT
SNOPT="-s SNOPT/src"
else
echo "SNOPT source is not available"
fi
build_pyoptsparse $BRANCH $SNOPT
- name: Install OpenMDAO
run: |
echo "============================================================="
echo "Install OpenMDAO"
echo "============================================================="
python -m pip install .
- name: Display environment info
id: env_info
if: always()
continue-on-error: true
run: |
conda info
conda list
echo "============================================================="
echo "Check installed versions of Python, Numpy and Scipy"
echo "============================================================="
echo 'errors<<EOF' >> $GITHUB_OUTPUT
FINAL_VER=`python -c "import platform; print(platform.python_version())"`
if [[ ! "$FINAL_VER" == "${{ matrix.PY }}"* ]]; then
echo "Python version was changed from ${{ matrix.PY }} to $FINAL_VER" >> $GITHUB_OUTPUT
fi
FINAL_VER=`python -c "import numpy; print(numpy.__version__)"`
if [[ ! "$FINAL_VER" == "$NUMPY_VER"* ]]; then
echo "NumPy version was changed from $NUMPY_VER to $FINAL_VER" >> $GITHUB_OUTPUT
fi
FINAL_VER=`python -c "import scipy; print(scipy.__version__)"`
if [[ ! "$FINAL_VER" == "$SCIPY_VER"* ]]; then
echo "SciPy version was changed from $SCIPY_VER to $FINAL_VER" >> $GITHUB_OUTPUT
fi
echo 'EOF' >> $GITHUB_OUTPUT
grep changed $GITHUB_OUTPUT || echo ""
# Enable tmate debugging of manually-triggered workflows if the input option was provided
#
# To access the terminal through the web-interface:
# 1. Click on the web-browser link printed out in this action from the github
# workflow terminal
# 2. Press cntrl + c in the new tab that opens up to reveal the terminal
# 3. To activate the conda environment run:
# $ source $CONDA/etc/profile.d/conda.sh
# $ conda activate test
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
- name: Run tests
id: run_tests
continue-on-error: true
run: |
echo "============================================================="
echo "Run tests (from directory other than repo root)"
echo "============================================================="
cd $HOME
RPT_FILE=`pwd`/deprecations.txt
echo "RPT_FILE=$RPT_FILE" >> $GITHUB_ENV
testflo -n 1 openmdao --timeout=240 --deprecations_report=$RPT_FILE --exclude=test_warnings_filters
- name: Build docs
id: build_docs
continue-on-error: true
run: |
export OPENMDAO_REPORTS=0
export PYDEVD_DISABLE_FILE_VALIDATION=1
cd openmdao/docs
if [[ "${{ secrets.SNOPT_LOCATION_77 }}" ]]; then
echo "============================================================="
echo "Building docs with SNOPT examples."
echo "============================================================="
else
echo "============================================================="
echo "Disabling SNOPT cells in notebooks."
echo "============================================================="
python openmdao_book/other/disable_snopt_cells.py
fi
echo "============================================================="
echo "Starting ipcluster to run MPI under notebooks"
echo "============================================================="
./ipcluster_start.sh
sleep 12
echo "============================================================="
echo "Building the docs"
echo "============================================================="
echo "building source docs..."
python build_source_docs.py
echo "building book..."
jupyter-book build -W --keep-going openmdao_book
echo "copying build artifacts..."
python copy_build_artifacts.py
- name: Display doc build reports
if: steps.build_docs.outcome == 'failure'
continue-on-error: true
run: |
for f in $(find /home/runner/work/OpenMDAO/OpenMDAO/openmdao/docs/openmdao_book/_build/html/reports -name '*.log'); do
echo "============================================================="
echo $f
echo "============================================================="
cat $f
done
- name: Deprecations Report
id: deprecations_report
continue-on-error: true
run: |
echo "============================================================="
echo "Display deprecations report"
echo "============================================================="
cat $RPT_FILE
echo 'summary<<EOF' >> $GITHUB_OUTPUT
head -n 6 $RPT_FILE | cut -d':' -f 1 >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
grep '^0 unique deprecation warnings' $RPT_FILE
- name: Slack env change
if: steps.env_info.outputs.errors != ''
uses: act10ns/slack@v2.0.0
with:
webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
status: 'warning'
message: |
Environment change detected on `Latest` build.
Python, NumPy or SciPy was not the requested version:
```${{steps.env_info.outputs.errors}}```
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Slack unit test failure
if: steps.run_tests.outcome == 'failure'
uses: act10ns/slack@v2.0.0
with:
webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
status: ${{ steps.run_tests.outcome }}
message:
Unit testing failed on `Latest` build.
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Slack doc build failure
if: steps.build_docs.outcome == 'failure'
uses: act10ns/slack@v2.0.0
with:
webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
status: ${{ steps.build_docs.outcome }}
message: |
Doc build failed on `Latest` build.
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Slack deprecation warnings
if: steps.deprecations_report.outcome == 'failure'
uses: act10ns/slack@v2.0.0
with:
webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
status: 'warning'
message: |
Deprecations were detected on `Latest` build.
```${{ steps.deprecations_report.outputs.summary }}```
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Fail the workflow if tests or doc build failed
if: steps.run_tests.outcome == 'failure' || steps.build_docs.outcome == 'failure'
uses: actions/github-script@v3
with:
script: |
let test_fail = ${{ steps.run_tests.outcome == 'failure' }};
let docs_fail = ${{ steps.build_docs.outcome == 'failure' }};
if (test_fail && docs_fail) {
core.setFailed('Tests and doc build failed.');
}
else if (test_fail) {
core.setFailed('Tests failed.');
}
else if (docs_fail) {
core.setFailed('Doc build failed.');
}