Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7e0aaf1
Add job to run the st2-self-check in GHA to the ci.yaml
winem Mar 19, 2022
1711e6d
Handle executions in the Github Actions environment by st2ctl
winem Mar 19, 2022
7b198a9
Update the st2-self-check script to work in Github Actions and return…
winem Mar 19, 2022
e69120c
Merge branch 'master' into 5496-self-check-in-gh-actions
winem Apr 9, 2022
4ee5cd8
Use stanley as user for ssh actions
winem May 3, 2022
bf422b8
Merge branch '5496-self-check-in-gh-actions' of pgithub.com:StackStor…
winem May 3, 2022
4ec6061
Merge branch 'master' into 5496-self-check-in-gh-actions
winem Aug 21, 2022
290ac38
Use the private key instead of the authorized keys file
winem Aug 21, 2022
f37c55e
Run the self-check on python3.8.13
winem Aug 21, 2022
277c0f4
Add option to skip tests in the context of GHA
winem Aug 21, 2022
e286b49
Fix github actions env definition
winem Aug 21, 2022
16c71b0
Switch to a space separated list and improve wording and handling of …
winem Sep 10, 2022
fab8a87
Merge branch 'master' into 5496-self-check-in-gh-actions
winem Sep 11, 2022
e10b1a8
Merge branch 'master' into 5496-self-check-in-gh-actions
winem Sep 12, 2022
2666ef7
Merge branch 'master' into 5496-self-check-in-gh-actions
winem Oct 3, 2022
d80b73d
Add changelog entry for the self-check in Github Actions
winem Oct 3, 2022
ac5b2d9
Move the changelog entry from added to changed
winem Oct 3, 2022
56a8086
Run the st2-self-check on py3.8.14
winem Oct 3, 2022
79d44eb
Add note regarding the ToDo for py3.6
winem Oct 3, 2022
3fad2ac
Merge branch 'master' into 5496-self-check-in-gh-actions
cognifloyd Nov 29, 2022
03525ff
Merge branch 'master' into 5496-self-check-in-gh-actions
winem Oct 13, 2023
8f60d19
Introduce TESTS_TO_SKIP environment variable support in st2-self-check
winem Oct 13, 2023
5378725
Run the st2-self-check on github actions on ubuntu 20.04
winem Oct 14, 2023
2a78286
Cleanup of changelog entries for this PR and mention it just in the A…
winem Oct 17, 2023
9c58714
Make the TESTS_TO_SKIP variable useful in any context and not just in…
winem Oct 17, 2023
7bd8de2
Run the st2-self-check as part of the Github Action for any branch & PR
winem Oct 17, 2023
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
154 changes: 154 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,160 @@ jobs:
run: |
./scripts/ci/run-nightly-make-task-if-exists.sh "${TASK}"

self-check:
needs: pre_job
name: '${{ matrix.name }} - Python ${{ matrix.python-version-short }}'
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
include:
# TODO: Check if we want to fix the errors on Py 3.6 to have it tested as well
#- name: 'Self-check on Python 3.6'
# python-version-short: '3.6'
# python-version: '3.6.13'
- name: 'Self-check on Python 3.8'
python-version-short: '3.8'
python-version: '3.8.14'
services:
mongo:
image: mongo:4.4
ports:
- 27017:27017

rabbitmq:
image: rabbitmq:3.8-management
options: >-
--name rabbitmq
ports:
- 5671:5671/tcp # AMQP SSL port
- 5672:5672/tcp # AMQP standard port
- 15672:15672/tcp # Management: HTTP, CLI

env:
# CI st2.conf (with ST2_CI_USER user instead of stanley)
ST2_CONF: 'conf/st2.ci.conf'

# Name of the user who is running the CI (on GitHub Actions this is 'runner')
ST2_CI_USER: 'runner'

# GitHub is juggling how to set vars for multiple shells. Protect our PATH assumptions.
PATH: /home/runner/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

# Space separated list of tests to be skipped if the self-check is running in GitHub Actions
TESTS_TO_SKIP: "tests.test_quickstart_rules tests.test_run_pack_tests_tool"
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Custom Environment Setup
run: |
./scripts/github/setup-environment.sh
- name: 'Set up Python (${{ matrix.python-version }})'
uses: actions/setup-python@v2
with:
python-version: '${{ matrix.python-version }}'
- name: Cache Python Dependencies
uses: actions/cache@v2
with:
path: |
~/.cache/pip
virtualenv
~/virtualenv
# TODO: maybe make the virtualenv a partial cache to exclude st2*?
# !virtualenv/lib/python*/site-packages/st2*
# !virtualenv/bin/st2*
key: ${{ runner.os }}-v3-python-${{ matrix.python-version }}-${{ hashFiles('requirements.txt', 'test-requirements.txt') }}
restore-keys: |
${{ runner.os }}-python-${{ matrix.python }}-
- name: Cache APT Dependencies
id: cache-apt-deps
uses: actions/cache@v2
with:
path: |
~/apt_cache
key: ${{ runner.os }}-apt-v5-${{ hashFiles('scripts/github/apt-packages.txt') }}
restore-keys: |
${{ runner.os }}-apt-v5-
- name: Install APT Depedencies
env:
CACHE_HIT: ${{steps.cache-apt-deps.outputs.cache-hit}}
run: |
cat /etc/environment
# install dev dependencies for Python YAML and LDAP packages
# https://github.com/StackStorm/st2-auth-ldap
./scripts/github/install-apt-packages-use-cache.sh
- name: Install virtualenv
run: |
./scripts/github/install-virtualenv.sh
- name: Install requirements
run: |
./scripts/ci/install-requirements.sh
- name: Run Redis Service Container
timeout-minutes: 2
run: |
docker run --rm --detach -p 127.0.0.1:6379:6379/tcp --name redis redis:latest
until [ "$(docker inspect -f {{.State.Running}} redis)" == "true" ]; do sleep 0.1; done
- name: Setup Tests
run: |
# prep a ci-specific dev conf file that uses runner instead of stanley
# this user is the username of the user in GitHub actions, used for SSH, etc during
# integration tests (important)
cp conf/st2.dev.conf "${ST2_CONF}"
sed -i -e "s,/home/vagrant/.ssh/stanley_rsa,/home/stanley/.ssh/stanley_rsa," "${ST2_CONF}"

sudo -E ./scripts/ci/add-itest-user-key.sh
- name: Permissions Workaround
run: |
sudo ST2_CI_REPO_PATH="${ST2_CI_REPO_PATH}" scripts/ci/permissions-workaround.sh
- name: Reconfigure RabbitMQ
# bitnami image allows (see bitnami/rabbitmq readme):
# Here we're copying a rabbitmq.config file which won't do anything.
# We need to switch to custom.conf or advanced.config.
timeout-minutes: 2 # may die if rabbitmq fails to start
run: |
./scripts/github/configure-rabbitmq.sh
- name: Print versions
run: |
./scripts/ci/print-versions.sh
- name: make
timeout-minutes: 14 # may die if rabbitmq fails to start
# use: script -e -c to print colors
run: |
script -e -c "make .ci-prepare-integration" && exit 0
- name: Extend the path for upcoming tasks
run: |
echo ${HOME}/work/st2/st2/virtualenv/bin
echo ${HOME}/work/st2/st2/virtualenv/bin >> $GITHUB_PATH
- name: Create symlinks to find the binaries when running st2 actions
run: |
ln -s ${HOME}/work/st2/st2/virtualenv/bin/st2 /usr/local/bin/st2
ln -s ${HOME}/work/st2/st2/virtualenv/bin/st2-run-pack-tests /usr/local/bin/st2-run-pack-tests
- name: Install st2client
timeout-minutes: 5
run: |
cd ./st2client
pip3 install --upgrade pip
python3 setup.py develop
- name: Run self-verification script
env:
ST2_CONF: /home/runner/work/st2/st2/conf/st2.ci.conf
run: |
sudo -E ST2_AUTH_TOKEN=$(st2 auth testu -p 'testp' -t) PATH=${PATH} virtualenv/bin/st2-self-check
- name: Compress Service Logs Before upload
if: ${{ failure() }}
run: |
tar cvzpf logs.tar.gz logs/*
- name: Upload StackStorm services Logs
if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: logs
path: logs.tar.gz
retention-days: 7
- name: Stop Redis Service Container
if: "${{ always() }}"
run: docker rm --force redis || true

unit-tests:
needs: pre_job
# NOTE: We always want to run job on master since we run some additional checks there (code
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ Added
* Python 3.9 support. #5730
Contributed by Amanda McGuinness (@amanda11 intive)

* Run the st2 self-check in Github Actions and support the environment variable `TESTS_TO_SKIP` to skip tests when running st2-self-check. #5609

Contributed by @winem

Changed
~~~~~~~
* Remove `distutils` dependencies across the project. #5992
Expand Down
20 changes: 17 additions & 3 deletions st2common/bin/st2-self-check
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function usage() {
RUN_ORQUESTA_TESTS=true
RUN_WINDOWS_TESTS=false
ST2_TESTS_BRANCH="master"
TESTS_TO_SKIP="${TESTS_TO_SKIP:-}"

while getopts "b:wo" o
do
Expand Down Expand Up @@ -101,10 +102,15 @@ if [ ${EXIT_CODE} -ne 0 ]; then
fi

echo "Copying asserts, fixtures, tests and examples packs."
chown -R root:st2packs st2tests/packs/
chmod -R 775 st2tests/packs/*
if [ -n "${GITHUB_ACTIONS}" ]; then
cp -Rf --preserve /home/runner/work/st2/st2/contrib/examples /opt/stackstorm/packs/
else
chmod -R 775 st2tests/packs/*
cp -Rf --preserve /usr/share/doc/st2/examples /opt/stackstorm/packs/
chown -R root:st2packs st2tests/packs/
fi

cp -R --preserve st2tests/packs/* /opt/stackstorm/packs/
cp -Rf --preserve /usr/share/doc/st2/examples /opt/stackstorm/packs/

echo "Installing asserts, fixtures, tests and examples packs."
st2 run packs.setup_virtualenv packs=examples,tests,asserts,fixtures,webui
Expand Down Expand Up @@ -136,6 +142,11 @@ do
continue
fi

if [[ " ${TESTS_TO_SKIP} " =~ " ${TEST} " ]]; then
echo "Skipping ${TEST}..."
continue
fi

echo -n "Attempting Test ${TEST}..."

START_TS=$(date +%s)
Expand Down Expand Up @@ -179,6 +190,9 @@ if [ $ERRORS -ne 0 ]; then
echo "SELF CHECK FAILED!"
echo "st2-self-check failed. See above. Also check the execution list for details."
echo "st2 execution list"
if [ -n "${GITHUB_ACTIONS}" ]; then
exit 1
fi
else
echo "SELF CHECK SUCCEEDED!"
echo -e "st2-self-check succeeded."
Expand Down
6 changes: 3 additions & 3 deletions st2common/bin/st2ctl
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
# limitations under the License.

COMPONENTS="st2actionrunner st2api st2stream st2auth st2garbagecollector st2notifier st2rulesengine st2sensorcontainer st2chatops st2timersengine st2workflowengine st2scheduler"
ST2_CONF="/etc/st2/st2.conf"
ST2_CONF="${ST2_CONF:-/etc/st2/st2.conf}"
SYSTEMD_RELOADED=""

# Ensure global environment is sourced if exists
# Ensure global environment is sourced if exists and if not executed in the context of Github Actions
# Does not happen consistently with all OSes we support.
[ -r /etc/environment ] && source /etc/environment
[ -z "${GITHUB_ACTIONS}" ] && [ -r /etc/environment ] && source /etc/environment

# load in environment to allow override of COMPONENTS and ST2_CONF above
# Ubuntu/Debian
Expand Down