Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,27 @@ To make use of the linters used by Open XDMoD on your local system, perform the
1. To install npm dependencies, run `npm install` in the repo's base directory. The programs npm downloads will then be available in `[xdmod-qa]/node_modules/.bin`.
1. Install the style linter config files to a parent directory of your Open XDMoD repos. Run `[xdmod-qa]/style/install.sh [parent-dir]` to do this easily.

### [Travis CI](https://travis-ci.org)
### [Shippable](https://www.shippable.com)

Create a `.travis.yml` file in the root of your module's repository. You can copy the template at path [`travis/template.yml`](travis/template.yml) to get started.
Create a `shippable.yml` file in the root of your module's repository. You can copy / use the template at path [`scripts/template.yml`](scripts/template.yml) to get started.

In `.travis.yml`, set the following environment variables to values applicable to your module:
In `shippable.yml` make sure the following environment variables are set with values applicable to your module:

- `XDMOD_MODULE_DIR`: The name of the module's subdirectory inside of Open XDMoD directory `open_xdmod/modules`. (e.g. `appkernels`)
- `XDMOD_MODULE_NAME`: The reader-friendly name for your module. (e.g. Application Kernels)
- `XDMOD_REALMS`: a comma delimited list of the XDMoD realms your module requires and or provides.
- `XDMOD_SOURCE_DIR`: The directory that the XDMoD source code will be checked out to.
- `XDMOD_INSTALL_DIR`: The directory that the qa scripts will attempt to perform a source install of XDMoD to.
- `XDMOD_MODULE_DIR`: The directory that contains the XDMoD module source code.
- `XDMOD_MODULE_NAME`: The name of the XDMoD module that is being tested.

Optionally you can set the following (`qa-test-setup.sh` is a helper script that resides in the base XDMoD repo that takes care of checking out & running the qa scripts ):
- `QA_BRANCH`: The branch of the qa repo that will be checked out by `qa-test-setup.sh`.
- `QA_GIT_URL`: The git repo that will be cloned / used by `qa-test-setup.sh`

#### Custom Test Hooks

If your module needs to perform custom tests or tasks not run by this repo's scripts, you can create custom scripts in your repo with the following paths and they will be run for you at the specified times. (Remember to make your script files executable!)

- `/.travis/post-install-test.sh`: This will be run after Travis has built and installed Open XDMoD and your module. It will not run if building or installing failed. The script's exit code will be used to determine if post-install tests succeeded or failed.
- `scripts/post-install-test.sh`: This will be run after Shippable has built and installed Open XDMoD and your module. It will not run if building or installing failed. The script's exit code will be used to determine if post-install tests succeeded or failed.

## Versioning

Expand Down
28 changes: 18 additions & 10 deletions travis/build.sh → scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@ new_bin_paths="$new_bin_paths:$qa_dir/vendor/bin:$qa_dir/node_modules/.bin"
PATH="$new_bin_paths:$PATH"
export PATH

if [ -n "$NODE_VERSION" ]; then
source ~/.nvm/nvm.sh
nvm use "$NODE_VERSION"
echo
fi

# Fix for Travis not specifying a range if testing the first commit of
# a new branch on push
if [ -z "$TRAVIS_COMMIT_RANGE" ]; then
Expand Down Expand Up @@ -251,8 +245,14 @@ for file in "${php_files_changed[@]}" "${php_files_added[@]}"; do
syntax_exit_value=2
fi
done

eslint_args=""
if [ -n "$SHIPPABLE_BUILD_DIR" ]; then
eslint_args="-o ./shipppable/testresults/xdmod-eslint-$(basename "$file").xml -f junit"
fi

for file in "${js_files_changed[@]}" "${js_files_added[@]}"; do
eslint "$file"
eslint "$file" "$eslint_args"
if [ $? != 0 ]; then
syntax_exit_value=2
fi
Expand Down Expand Up @@ -377,11 +377,19 @@ echo "Running unit tests..."

unit_exit_value=0
php_unit_test_path="tests/unit/runtests.sh"
php_unit_test_args=""

if [ "$repo_type" != "core" ]; then
php_unit_test_path="tests/unit_tests/runtests.sh"
fi

if [ -n "$SHIPPABLE_BUILD_DIR" ]; then
php_unit_test_path="$SHIPPABLE_BUILD_DIR/tests/unit/runtests.sh"
php_unit_test_args="--junit-output-dir $SHIPPABLE_BUILD_DIR/shippable/testresults"
fi

if [ -e "$php_unit_test_path" ]; then
"$php_unit_test_path"
$php_unit_test_path "$php_unit_test_args"
if [ $? != 0 ]; then
unit_exit_value=2
fi
Expand Down Expand Up @@ -415,7 +423,7 @@ fi

if [ "$repo_type" == "module" ]; then
echo "Building $XDMOD_MODULE_NAME module..."
"$build_package_path" --module "$XDMOD_MODULE_DIR"
"$build_package_path" --module "$XDMOD_MODULE_NAME"
if [ $? != 0 ]; then
build_exit_value=2
fi
Expand Down Expand Up @@ -454,7 +462,7 @@ fi
if [ "$repo_type" == "module" ]; then
echo "Installing $XDMOD_MODULE_NAME module..."
cd .. || exit 2
module_tar="$(find . -regex "^\./xdmod-${XDMOD_MODULE_DIR}-[0-9]+[^/]*\.tar\.gz$")"
module_tar="$(find . -regex "^\./xdmod-${XDMOD_MODULE_NAME}-[0-9]+[^/]*\.tar\.gz$")"
tar -xf "$module_tar"
cd "$(basename "$module_tar" .tar.gz)" || exit 2
./install --prefix="$XDMOD_INSTALL_DIR"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
39 changes: 0 additions & 39 deletions travis/install.sh → scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ set -e

# Initialize variables for tracking application-level package manager initialization.
composer_initialized=false
npm_initialized=false

# Install application-level dependencies declared in the given directory.
#
Expand Down Expand Up @@ -53,21 +52,6 @@ function install_dependencies() {

# If npm dependencies are declared, install them.
if [ -e "package.json" ]; then
# If npm has not been initialized yet, do so.
if ! $npm_initialized; then
# If set, use version of Node set in environment variable.
if [ -n "$NODE_VERSION" ]; then
source ~/.nvm/nvm.sh
nvm install "$NODE_VERSION"
nvm use "$NODE_VERSION"
fi

# Update npm.
npm install npm@5.8.0 -g

npm_initialized=true
fi

# Install repo's npm dependencies.
echo "Installing npm dependencies..."
npm install
Expand All @@ -81,29 +65,6 @@ function install_dependencies() {
# Install QA dependencies.
install_dependencies "$qa_dir"

# If this repo is a module, get and set up the corresponding version of Open XDMoD.
if [ "$repo_type" == "module" ]; then
start_travis_fold open-xdmod
echo "Obtaining and integrating with Open XDMoD code..."

xdmod_branch="${XDMOD_MAIN_BRANCH:-$TRAVIS_BRANCH}"
echo "Cloning Open XDMoD branch '$xdmod_branch'"
git clone --depth=1 --branch="$xdmod_branch" https://github.com/ubccr/xdmod.git "$XDMOD_SOURCE_DIR"

pushd "$XDMOD_SOURCE_DIR" >/dev/null
echo "Retrieving Open XDMoD submodules..."
git submodule update --init --recursive
popd >/dev/null

# Create a symlink from Open XDMoD to this module.
ln -s "$(pwd)" "$XDMOD_SOURCE_DIR/open_xdmod/modules/$XDMOD_MODULE_DIR"

end_travis_fold open-xdmod
echo

# Install Open XDMoD dependencies.
install_dependencies "$XDMOD_SOURCE_DIR"
fi

# Install this repo's dependencies.
install_dependencies "$(pwd)"
86 changes: 86 additions & 0 deletions scripts/template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# we utilize `language: none` because we want to utilize our own docker image. Select the correct language for your module.
language: none
env:
global:
- COMPOSER_ALLOW_SUPERUSER=1

# Make sure to only include the realms your module requires / provides
- XDMOD_REALMS='jobs,storage,cloud'

# This is the directory that XDMoD is to be checked out to.
- XDMOD_SOURCE_DIR=$SHIPPABLE_BUILD_DIR/../xdmod

# This is the directory where XDMoD will be source installed to as part of the qa tests
- XDMOD_INSTALL_DIR=/xdmod

# This is required and is the location that your module is checked out to.
- XDMOD_MODULE_DIR=$SHIPPABLE_BUILD_DIR

# This is required and corresponds to `<xdmod install dir>/open_xdmod/modules/<module>`
# We ensure this directory is present by sym-linking the module dir to this location.
- XDMOD_MODULE_NAME=supremm
matrix:
# Having both of these entries will ensure that both the fresh install & upgrade paths are tested.
- XDMOD_TEST_MODE=fresh_install
- XDMOD_TEST_MODE=upgrade
build:
cache: true
cache_dir_list:
- /root/.composer
pre_ci:
# This is where we build our custom docker image that we'll be using. This assumes that there's a
# `Dockerfile` present in $SHIPPABLE_BUILD_DIR
- docker build -t pseudo_repo/xdmod-open-supremm:latest .
pre_ci_boot:
image_name: pseudo_repo/xdmod-open-supremm
image_tag: latest
pull: false
options: "--user root -e HOME=/root --shm-size 2g"
ci:
# We need to make sure that we have an up to date version of XDMoD checked out that we can install the module into.
- git clone --depth=1 --branch=migrate_travis https://github.com/ryanrath/xdmod.git ../xdmod

# Here we're linking the module directory into the checked out XDMoD's module directory.
- ln -s $SHIPPABLE_BUILD_DIR ../xdmod/open_xdmod/modules/$XDMOD_MODULE_NAME

# Since this is a fresh copy of the XDMoD source control we need to make sure that we install it's dependencies.
- composer install -d ../xdmod --no-progress

# Now that we have a baseline XDMoD source ready to go we can build the RPM's to be installed.
- cd ../xdmod && ~/bin/buildrpm xdmod $XDMOD_MODULE_NAME && cd $SHIPPABLE_BUILD_DIR

# To help the qa scripts determine which files have changed we add an `upstream` remote.
- git remote add upstream <git url for your modules upstream repo>

# This script will take care of installing / configuring the checked out XDMoD & your module. It's keyed
# off of the XDMOD_TEST_MODE env variable
- ./tests/integration_tests/scripts/bootstrap.sh

# This script just validates that XDMoD was installed successfully.
- ./tests/integration_tests/scripts/validate.sh

# This will ensure that phpunit and the other dev dependencies are installed.
- composer install -d ../xdmod --no-progress

# We can now run the qa scripts. Note: this is a wrapper script included in the XDMoD source code that just
# ensures that the qa tests are only run during the `upgrade` test path. Other then that this script does
# the following:
# - clone's $QA_BRANCH of $QA_GIT_URL to $HOME/.qa
# - cd's into $SHIPPABLE_BUILD_DIR ( since this is the code that we want qa to check )
# - Runs `scripts/install.sh` and `scripts/build.sh`
- ../xdmod/tests/ci/scripts/qa-test-setup.sh

# We ensure that dev dependencies are indeed in place.
- composer install -d ../xdmod --no-progress

# We re-export XDMOD_INSTALL_DIR here as the `post-install-test.sh` script expects it to point to the directory
# that XDMoD was installed to via RPM.
- export XDMOD_INSTALL_DIR=/usr/share/xdmod
- ./tests/ci/scripts/post-install-test.sh

# We then run the rest of XDMoD's automated test suites.
- ./tests/integration_tests/runtests.sh --log-junit `pwd`/shippable/testresults/results.xml
- ../xdmod/tests/ui/runtests.sh --headless --log-junit $SHIPPABLE_BUILD_DIR/shippable/testresults
- ./tests/regression_tests/runtests.sh --junit-output-dir `pwd`/shippable/testresults
on_failure:
- cat /var/log/xdmod/*
32 changes: 0 additions & 32 deletions travis/template.yml

This file was deleted.