From fdb94668fd94544bad88aab5032f46eee3aa6859 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Mon, 25 Jan 2021 21:57:52 -0600 Subject: [PATCH 1/3] Run setup_testing_env.sh during dependencies But only if executable. Allows pack to customize testing env. --- .circle/dependencies | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.circle/dependencies b/.circle/dependencies index 5006361a..0ec13c3b 100755 --- a/.circle/dependencies +++ b/.circle/dependencies @@ -48,6 +48,7 @@ echo "Installing StackStorm runners and registering metrics drivers" if [[ -n "${ROOT_DIR}" ]]; then PACK_REQUIREMENTS_FILE="${ROOT_DIR}/requirements.txt" PACK_TESTS_REQUIREMENTS_FILE="${ROOT_DIR}/requirements-tests.txt" + PACK_SETUP_TESTING_ENV="${ROOT_DIR}/tests/setup_testing_env.sh" echo "Copying Makefile to ${ROOT_DIR}" cp ~/ci/.circle/Makefile ${ROOT_DIR} @@ -55,6 +56,7 @@ if [[ -n "${ROOT_DIR}" ]]; then else PACK_REQUIREMENTS_FILE="$(pwd)/requirements.txt" PACK_TESTS_REQUIREMENTS_FILE="$(pwd)/requirements-tests.txt" + PACK_SETUP_TESTING_ENV="$(pwd)/tests/setup_testing_env.sh" echo "Copying Makefile to $(pwd)" cp ~/ci/.circle/Makefile . @@ -73,5 +75,11 @@ if [[ -f "${PACK_TESTS_REQUIREMENTS_FILE}" ]]; then ~/virtualenv/bin/pip install -r "${PACK_TESTS_REQUIREMENTS_FILE}" fi +# Install custom pack testing enviornment +if [[ -x "${PACK_SETUP_TESTING_ENV}" ]]; then + echo "Setting up custom pack testing environment with ${PACK_SETUP_TESTING_ENV}" + "${PACK_SETUP_TESTING_ENV}" +fi + echo "Installed dependencies:" pip list From 7f431a0f9a2c4cabbb1418539f6c9241f0e48a54 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Tue, 26 Jan 2021 14:36:04 -0600 Subject: [PATCH 2/3] setup_testing_env.sh.sample --- .circle/setup_testing_env.sh.sample | 15 +++++++++++++++ utils/exchange-bootstrap.sh | 5 +++++ 2 files changed, 20 insertions(+) create mode 100644 .circle/setup_testing_env.sh.sample diff --git a/.circle/setup_testing_env.sh.sample b/.circle/setup_testing_env.sh.sample new file mode 100644 index 00000000..99c67f89 --- /dev/null +++ b/.circle/setup_testing_env.sh.sample @@ -0,0 +1,15 @@ +#!/bin/bash + +# For python deps, please use requirements.txt or requirements-test.txt. +# Do not install python requirements with this script. + +# Some packs need to install and configure additional packages to properly +# run their test suite. Other packs need to clone other repositories to +# reuse standardized testing infrastructure. And other functional or end-to-end +# tests might need additional system setup to access external APIs via +# an enterprise bus or something else. +# That is the purpose of this script. Setup the testing environment +# to do mock-less regression or end-to-end testing. + +# This script is called by `deployment` housed in StackStorm-exchange/ci. +# `deployment` will only run this script if it is executable. diff --git a/utils/exchange-bootstrap.sh b/utils/exchange-bootstrap.sh index d570a926..f3e588fa 100755 --- a/utils/exchange-bootstrap.sh +++ b/utils/exchange-bootstrap.sh @@ -101,6 +101,11 @@ git add .circleci/config.yml curl -sS --fail "https://raw.githubusercontent.com/StackStorm-Exchange/ci/master/files/.gitignore.sample" > .gitignore git add .gitignore +mkdir tests +curl -sS --fail "https://raw.githubusercontent.com/StackStorm-Exchange/ci/master/.circle/setup_testing_env.sh.sample" > tests/setup_testing_env.sh +# no execute bit until pack-author enables it. +git add tests/setup_testing_env.sh + git commit -m "Bootstrap a StackStorm Exchange pack repository for pack ${PACK}." git push origin master From 1a45169490fd24bbbe2a795aa232b45a5a4b1a37 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Fri, 29 Jan 2021 14:36:15 -0600 Subject: [PATCH 3/3] Add warning about editing circleci config Instead we want people to use tests/setup_testing_env.sh if possible so that Exchange maintenance is as quick as possible. --- .circle/circle.yml.sample | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.circle/circle.yml.sample b/.circle/circle.yml.sample index 88a0ece3..a76d201c 100644 --- a/.circle/circle.yml.sample +++ b/.circle/circle.yml.sample @@ -1,3 +1,14 @@ +# WARNING: Minimize edits to this file! +# +# This file is part of the CI infrastructure for the StackStorm-Exchange. +# As such, it gets overwritten periodically in CI infrastructure updates. +# Check out `tests/setup_testing_env.sh` for how to customize the test env. +# If you need to add jobs, docker images, or other changes that do not work +# in `tests/setup_testing_env.sh`, then please add what you need and avoid +# changing the standard build_and_test and deploy jobs. +# +# Thanks for your contribution! +--- version: 2 jobs: