From dc52bcd98da639119faa11da8bb1770b4636aab1 Mon Sep 17 00:00:00 2001 From: jidicula Date: Sat, 28 Nov 2020 18:38:45 -0500 Subject: [PATCH] Add GitHub Actions CI builds Resolves #180 **Why this change was necessary** Travis doesn't offer great support for macOS and is also beginning to charge for macOS build minutes. **What this change does** - Factors the Travis CI build config into a shell script - Calls that shell script in a GitHub Actions Workflow - Adds a matrix build in the GH Actions Workflow for macOS 10.15 Catalina and 11.0 Big Sur (on Apple Silicon), Windows Server 2019, and Ubuntu 18, 20, and 16 - Adds a matrix build in the GH Actions Workflow for Python 3.7 and 3.8 - Adds a build status badge to the README **Additional context/notes/links** https://blog.travis-ci.com/2020-11-02-travis-ci-new-billing --- .github/tests.yml | 49 +++++++++++++++++++++++++++++++++++++++++++++++ README.md | 2 +- ci.sh | 29 ++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 .github/tests.yml create mode 100644 ci.sh diff --git a/.github/tests.yml b/.github/tests.yml new file mode 100644 index 00000000..de493e0e --- /dev/null +++ b/.github/tests.yml @@ -0,0 +1,49 @@ +name: CI-Tests + +on: + # Triggers the workflow on push or pull request events but only for the master branch + branches: + - master + push: + pull_request: + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - 'macos-10.15' + - 'macos-11.0' + - 'windows-2019' + - 'ubuntu-18.04' + - 'ubuntu-20.04' + - 'ubuntu-16.04' + python-version: + - '3.7' + - '3.8' + + steps: + - uses: actions/checkout@v2 + + - name: Set XCode version + if: contains(matrix.os, 'macos-11.0') + run: sudo xcode-select -s "/Applications/Xcode_12.2.app" + + - name: Run CI script + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + run: ./ci.sh + # Add test coverage stats to Coveralls.io + finish: + needs: test + runs-on: ${{ matrix.os }} + steps: + - name: Coveralls Finished + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.github_token }} + parallel-finished: true diff --git a/README.md b/README.md index 1c5543bc..fd394631 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # shimming-toolbox -[![Build Status](https://travis-ci.com/shimming-toolbox/shimming-toolbox.svg?branch=master)](https://travis-ci.com/shimming-toolbox/shimming-toolbox) [![Documentation Status](https://readthedocs.org/projects/shimming-toolbox/badge/?version=latest)](https://www.shimming-toolbox.org/en/latest/?badge=latest) [![Coverage Status](https://coveralls.io/repos/github/shimming-toolbox/shimming-toolbox/badge.svg?branch=master)](https://coveralls.io/github/shimming-toolbox/shimming-toolbox?branch=master) + [![Build Status](https://github.com/shimming-toolbox/shimming-toolbox/actions?query=workflow%3A%22CI-Tests/badge.svg)](https://github.com/shimming-toolbox/shimming-toolbox/actions?query=workflow%3A%22CI-Tests) [![Build Status](https://travis-ci.com/shimming-toolbox/shimming-toolbox.svg?branch=master)](https://travis-ci.com/shimming-toolbox/shimming-toolbox) [![Documentation Status](https://readthedocs.org/projects/shimming-toolbox/badge/?version=latest)](https://www.shimming-toolbox.org/en/latest/?badge=latest) [![Coverage Status](https://coveralls.io/repos/github/shimming-toolbox/shimming-toolbox/badge.svg?branch=master)](https://coveralls.io/github/shimming-toolbox/shimming-toolbox?branch=master) Code for performing real-time shimming using external MRI shim coils diff --git a/ci.sh b/ci.sh new file mode 100644 index 00000000..586d4575 --- /dev/null +++ b/ci.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +echo "Installation of dependencies" + +# Install bleeding-edge dcm2niix +curl -JLO https://github.com/rordenlab/dcm2niix/releases/latest/download/dcm2niix_lnx.zip +unzip -o dcm2niix_lnx.zip +sudo install dcm2nii* /usr/bin/ + +echo "shimming-toolbox installation" +pip install . +pip install coveralls + +# Tests +echo "Download prelude" +st_download_data prelude +echo "Set up prelude" +prelude_path="$(pwd)"/prelude +chmod 500 "${prelude_path}"/prelude +PATH=${prelude_path}:${PATH} +export PATH +FSLOUTPUTTYPE=NIFTI_GZ +export FSLOUTPUTTYPE +echo "Launch general integrity test" +py.test . -v --cov shimmingtoolbox/ --cov-report term-missing + +# Fail if any .sh files have warnings +echo "Check Bash scripts" +if [[ -n "$(ls examples/*.sh)" ]]; then shellcheck examples/*.sh; fi