Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI maintenance scripts #19

Merged
merged 15 commits into from
May 7, 2024
9 changes: 9 additions & 0 deletions .maint/ci/activate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
if [ -e virtenv/bin/activate ]; then
tsalo marked this conversation as resolved.
Show resolved Hide resolved
source virtenv/bin/activate
elif [ -e virtenv/Scripts/activate ]; then
source virtenv/Scripts/activate
else
echo Cannot activate virtual environment
ls -R virtenv
false
fi
34 changes: 34 additions & 0 deletions .maint/ci/build_archive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

echo "Building archive"

source .maint/ci/activate.sh

set -eu

# Required dependencies
echo "INSTALL_TYPE = $INSTALL_TYPE"

set -x

if [ "$INSTALL_TYPE" = "sdist" -o "$INSTALL_TYPE" = "wheel" ]; then
python -m build
elif [ "$INSTALL_TYPE" = "archive" ]; then
ARCHIVE="/tmp/package.tar.gz"
git archive -o $ARCHIVE HEAD
fi

if [ "$INSTALL_TYPE" = "sdist" ]; then
ARCHIVE=$( ls $PWD/dist/*.tar.gz )
elif [ "$INSTALL_TYPE" = "wheel" ]; then
ARCHIVE=$( ls $PWD/dist/*.whl )
elif [ "$INSTALL_TYPE" = "pip" ]; then
ARCHIVE="$PWD"
fi

if [ "$INSTALL_TYPE" = "sdist" -o "$INSTALL_TYPE" = "wheel" ]; then
python -m pip install twine
python -m twine check $ARCHIVE
fi

set +eux
26 changes: 26 additions & 0 deletions .maint/ci/check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

echo Running tests

source .maint/ci/activate.sh

set -eu

# Required variables
echo CHECK_TYPE = $CHECK_TYPE

set -x

if [ "${CHECK_TYPE}" == "doc" ]; then
cd doc
make html && make doctest
elif [ "${CHECK_TYPE}" == "tests" ]; then
pytest --doctest-modules --cov fmripost_aroma --cov-report xml \
--junitxml=test-results.xml -v fmripost_aroma
else
false
fi

set +eux

echo Done running tests
24 changes: 24 additions & 0 deletions .maint/ci/create_venv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

echo Creating isolated virtual environment

source .maint/ci/env.sh

set -eu

# Required variables
echo SETUP_REQUIRES = $SETUP_REQUIRES

set -x

python -m pip install --upgrade pip virtualenv
virtualenv --python=python virtenv
source .maint/ci/activate.sh
python --version
python -m pip install -U $SETUP_REQUIRES
which python
which pip

set +eux

echo Done creating isolated virtual environment
6 changes: 6 additions & 0 deletions .maint/ci/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SETUP_REQUIRES="pip build"

# Numpy and scipy upload nightly/weekly/intermittent wheels
NIGHTLY_WHEELS="https://pypi.anaconda.org/scipy-wheels-nightly/simple"
STAGING_WHEELS="https://pypi.anaconda.org/multibuild-wheels-staging/simple"
PRE_PIP_FLAGS="--pre --extra-index-url $NIGHTLY_WHEELS --extra-index-url $STAGING_WHEELS --prefer-binary"
34 changes: 34 additions & 0 deletions .maint/ci/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

echo Installing fmripost_aroma

source .maint/ci/activate.sh
source .maint/ci/env.sh

set -eu

# Required variables
echo INSTALL_TYPE = $INSTALL_TYPE
echo CHECK_TYPE = $CHECK_TYPE
echo EXTRA_PIP_FLAGS = $EXTRA_PIP_FLAGS

set -x

if [ -n "$EXTRA_PIP_FLAGS" ]; then
EXTRA_PIP_FLAGS=${!EXTRA_PIP_FLAGS}
fi

pip install $EXTRA_PIP_FLAGS $ARCHIVE

# Basic import check
python -c 'import fmripost_aroma; print(fmripost_aroma.__version__)'

if [ "$CHECK_TYPE" == "skiptests" ]; then
exit 0
fi

pip install $EXTRA_PIP_FLAGS "fmripost_aroma[$CHECK_TYPE]"

set +eux

echo Done installing fmripost_aroma
21 changes: 21 additions & 0 deletions .maint/ci/install_dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

echo "Installing dependencies"

set -eu

# Required variables
echo OS_TYPE = $OS_TYPE

if [ "$OS_TYPE" = "ubuntu-latest" ]; then
sudo apt update
sudo apt install -y graphviz
elif [ "$OS_TYPE" = "macos-latest" ]; then
brew install graphviz
else
echo "Unknown OS_TYPE: $OS_TYPE"
fi

set +eux

echo Done installing dependencies
24 changes: 24 additions & 0 deletions .maint/ci/install_extras.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

echo Installing dependencies

source .maint/ci/activate.sh
source .maint/ci/env.sh

set -eu

# Required variables
echo EXTRA_PIP_FLAGS = $EXTRA_PIP_FLAGS
echo CHECK_TYPE = $CHECK_TYPE

set -x

if [ -n "$EXTRA_PIP_FLAGS" ]; then
EXTRA_PIP_FLAGS=${!EXTRA_PIP_FLAGS}
fi

pip install $EXTRA_PIP_FLAGS "fmripost_aroma[$CHECK_TYPE]"

set +eux

echo Done installing dependencies
Loading
Loading