Skip to content

Commit

Permalink
Add github action to run unit tests (#349)
Browse files Browse the repository at this point in the history
* Add github workflow to run unit tests:

  - For python 3.5, 3.6, 3.7, and 3.8 pull the appropriate cmbenv:toast-deps
    container.

  - Install toast into a temporary container based on one of these upstream
    images.

  - Run the serial and MPI tests in this temporary container, and also test
    that the documentation builds with sphinx.

This also removes the entire directory of travis support scripts, which
are no longer needed.  An additional workflow can be added later for deploying
to pip wheels.

* Use package version for sphinx build
  • Loading branch information
tskisner authored May 18, 2020
1 parent 0de59f0 commit f1c9908
Show file tree
Hide file tree
Showing 12 changed files with 121 additions and 634 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Use pre-built docker containers to run our unit tests on different python versions.

name: Run Test Suite

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
py35:
name: Python 3.5
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Pull Dependency Image
run: docker pull hpc4cmb/toast-deps-py35:latest
- name: Compile
run: docker run -v "$(pwd)":/home/toast --name="test_py35" hpc4cmb/toast-deps-py35:latest /home/toast/platforms/install_test_runner.sh && docker commit -m "test runner" test_py35 test_runner:py35
- name: Test Documentation Build
run: docker run -v "$(pwd)":/home/toast test_runner:py35 /home/toast/docs/build_docs.sh
- name: Run Serial Tests
run: docker run test_runner:py35 python -c 'import toast.tests; toast.tests.run()'
- name: Run MPI Tests
run: docker run test_runner:py35 mpirun -np 2 python -c 'import toast.tests; toast.tests.run()'
py36:
name: Python 3.6
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Pull Dependency Image
run: docker pull hpc4cmb/toast-deps-py36:latest
- name: Compile
run: docker run -v "$(pwd)":/home/toast --name="test_py36" hpc4cmb/toast-deps-py36:latest /home/toast/platforms/install_test_runner.sh && docker commit -m "test runner" test_py36 test_runner:py36
- name: Test Documentation Build
run: docker run -v "$(pwd)":/home/toast test_runner:py36 /home/toast/docs/build_docs.sh
- name: Run Serial Tests
run: docker run test_runner:py36 python -c 'import toast.tests; toast.tests.run()'
- name: Run MPI Tests
run: docker run test_runner:py36 mpirun -np 2 python -c 'import toast.tests; toast.tests.run()'
py37:
name: Python 3.7
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Pull Dependency Image
run: docker pull hpc4cmb/toast-deps-py37:latest
- name: Compile
run: docker run -v "$(pwd)":/home/toast --name="test_py37" hpc4cmb/toast-deps-py37:latest /home/toast/platforms/install_test_runner.sh && docker commit -m "test runner" test_py37 test_runner:py37
- name: Test Documentation Build
run: docker run -v "$(pwd)":/home/toast test_runner:py37 /home/toast/docs/build_docs.sh
- name: Run Serial Tests
run: docker run test_runner:py37 python -c 'import toast.tests; toast.tests.run()'
- name: Run MPI Tests
run: docker run test_runner:py37 mpirun -np 2 python -c 'import toast.tests; toast.tests.run()'
py38:
name: Python 3.8
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Pull Dependency Image
run: docker pull hpc4cmb/toast-deps-py38:latest
- name: Compile
run: docker run -v "$(pwd)":/home/toast --name="test_py38" hpc4cmb/toast-deps-py38:latest /home/toast/platforms/install_test_runner.sh && docker commit -m "test runner" test_py38 test_runner:py38
- name: Test Documentation Build
run: docker run -v "$(pwd)":/home/toast test_runner:py38 /home/toast/docs/build_docs.sh
- name: Run Serial Tests
run: docker run test_runner:py38 python -c 'import toast.tests; toast.tests.run()'
- name: Run MPI Tests
run: docker run test_runner:py38 mpirun -np 2 python -c 'import toast.tests; toast.tests.run()'
244 changes: 0 additions & 244 deletions .travis.yml

This file was deleted.

15 changes: 15 additions & 0 deletions docs/build_docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# Copy the docs directory to the local working directory and build it with sphinx

set -e

# Get the absolute path to the docs folder
pushd $(dirname $0) > /dev/null
docdir=$(pwd -P)
popd > /dev/null

cp -a "${docdir}" ./docs
pushd ./docs > /dev/null
make html
popd > /dev/null
12 changes: 1 addition & 11 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,8 @@
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# Parse the formal "RELEASE" file in the top-level directory. This should
# reflect the current tag or in-development version.
#
fvparts = None
with open("../RELEASE", "r") as rel:
line = rel.readline().rstrip()
fvparts = line.split(".")

# The short X.Y version.
# version = "{}.{}".format(fvparts[0], fvparts[1])
# The full version, including alpha/beta/rc tags.
release = ".".join(fvparts)
release = toast.__version__
# Use the full version
version = release

Expand Down
30 changes: 30 additions & 0 deletions platforms/install_test_runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# This script is for a complete build and install to /usr/local inside a
# docker container. It is used when running CI unit tests.

set -e

# Get the absolute path to the source tree
pushd $(dirname $(dirname $0)) > /dev/null
toastdir=$(pwd -P)
popd > /dev/null

mkdir build
pushd build

cmake \
-DCMAKE_C_COMPILER="gcc" \
-DCMAKE_CXX_COMPILER="g++" \
-DMPI_C_COMPILER="mpicc" \
-DMPI_CXX_COMPILER="mpicxx" \
-DCMAKE_C_FLAGS="-O3 -g -fPIC -pthread" \
-DCMAKE_CXX_FLAGS="-O3 -g -fPIC -pthread -std=c++11" \
-DPYTHON_EXECUTABLE:FILEPATH=$(which python3) \
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
-DCMAKE_INSTALL_PREFIX=/usr/local \
"${toastdir}"

make -j 2 install

popd > /dev/null
Loading

0 comments on commit f1c9908

Please sign in to comment.