Skip to content

Commit

Permalink
Merge pull request #1 from winem/feature/github-actions-slack-notific…
Browse files Browse the repository at this point in the history
…ation

Feature/GitHub actions slack notification
  • Loading branch information
winem authored Jan 4, 2021
2 parents 632a07e + b0248cc commit fd41e1d
Show file tree
Hide file tree
Showing 94 changed files with 710 additions and 271 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
# Run st2 Integration tests
integration:
docker:
- image: circleci/python:2.7
- image: circleci/python:3.6
- image: mongo:4.0
- image: rabbitmq:3
working_directory: ~/st2
Expand Down Expand Up @@ -79,7 +79,7 @@ jobs:
# Run st2 Lint Checks
lint:
docker:
- image: circleci/python:2.7
- image: circleci/python:3.6
- image: mongo:4.0
- image: rabbitmq:3
working_directory: ~/st2
Expand Down Expand Up @@ -113,7 +113,7 @@ jobs:
resource_class: large
docker:
# The primary container is an instance of the first list image listed. Your build commands run in this container.
- image: circleci/python:2.7
- image: circleci/python:3.6
working_directory: ~/st2
environment:
- DISTROS: "xenial bionic el7 el8"
Expand Down Expand Up @@ -276,4 +276,4 @@ experimental:

notify:
webhooks:
- url: https://ci-webhooks.stackstorm.net/webhooks/build/events
- url: https://ci-webhooks.stackstorm.com/webhooks/build/events
204 changes: 204 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
name: ci

on:
push:
branches: ['*']
pull_request:
type: [opened, reopened, edited]
schedule:
# run every night at midnight
- cron: '0 0 * * *'

jobs:
ci:
name: '${{ matrix.name }} - python (${{ matrix.python-version }})'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: 'Lint Checks'
task: 'ci-checks'
python-version: '3.6'
- name: 'Compile'
task: 'ci-compile'
python-version: '3.6'
- name: 'Pack Tests'
task: 'ci-packs-tests'
python-version: '3.6'
- name: 'Unit Tests'
task: 'ci-unit'
python-version: '3.6'
# Integration tests are not working yet, still done in Travis
# - name: 'Integration Tests'
# task: 'ci-integration'
services:
mongo:
image: mongo:4.0
ports:
- 27017:27017
# Can't use RabbitMQ here for Integrations because we rely on custom config
# and SSL certs that are in the repo. In GHA, these services are started first
# before the code is checked out, so this is a non-starter, we need to do it
# manually below (TODO)
rabbitmq:
# use the -management version so it has the management tools installed
image: rabbitmq:3.8-management
ports:
# SSL port
- 5671:5671
# standard port
- 5672:5672
# management port
- 15672:15672
env:
TASK: '${{ matrix.task }}'

# We need to explicitly specify terminal width otherwise some CLI tests fail on container
# environments where small terminal size is used.
COLUMNS: '120'
PYLINT_CONCURRENCY: '2'

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

# Tell StackStorm that we are indeed in CI mode, previously we hard coded a Travis specific
# environment variable in our test code, making it a PITA when we switch CI providers.
# Now, we simply set this environment varible here in the CI portion of our testing and
# it avoids any CI provider type lock-in.
ST2_CI: 'true'

# Name of the user who is running the CI (on GitHub Actions this is 'runner')
ST2_CI_USER: 'runner'
steps:
- name: Custom Environment Setup
# built-in GitHub Actions environment variables
# https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables
#
# setting environment variables, so we can use shell logic
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
run: |
IS_NIGHTLY_BUILD=$([ "${GITHUB_EVENT_NAME}" = "schedule" ] && echo "yes" || echo "no")
echo "IS_NIGHTLY_BUILD=${IS_NIGHTLY_BUILD}" >> $GITHUB_ENV
# NOTE: We only enable coverage for master builds and not pull requests
# since it has huge performance overhead (tests are 50% or so slower)
ENABLE_COVERAGE=$([ "${GITHUB_EVENT_NAME}" != "pull_request" ] && [ "${IS_NIGHTLY_BUILD}" = "no" ] && echo "yes" || echo "no")
echo "ENABLE_COVERAGE=${ENABLE_COVERAGE}" >> $GITHUB_ENV
# We only run tests with "--with-timer" flag on master and not for PRs since it adds 1-2
# minutes of overhead to each build.
NOSE_TIME=$([ "${GITHUB_EVENT_NAME}" != "pull_request" ] && [ "${IS_NIGHTLY_BUILD}" = "no" ] && echo "yes" || echo "no")
echo "NOSE_TIME=${NOSE_TIME}" >> $GITHUB_ENV
# Setup the path to the st2 repo in the CI build system
echo "ST2_CI_REPO_PATH=${GITHUB_WORKSPACE}" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v2
- name: 'Set up Python (${{ matrix.python-version }})'
uses: actions/setup-python@v2
with:
python-version: '${{ matrix.python-version }}'
- uses: actions/cache@v2
with:
path: |
.cache/pip
virtualenv
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('requirements.txt', 'test-requirements.txt') }}
restore-keys: |
${{ runner.os }}-${{ matrix.python }}-
- name: Install apt depedencies
run: |
# install dev dependencies for Python LDAP module
# https://github.com/StackStorm/st2-auth-ldap
sudo apt-get -y update
sudo apt-get -f -y install libldap2-dev libsasl2-dev libssl-dev ldap-utils
- name: Install virtualenv
run: |
# Note: Use the verison of virtualenv pinned in fixed-requirements.txt so we
# only have to update it one place when we change the version
pip install --upgrade --force-reinstall $(grep "^virtualenv" fixed-requirements.txt)
- name: Install requirements
run: |
./scripts/travis/install-requirements.sh
- name: Setup integration 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/stanley/${ST2_CI_USER}/" "${ST2_CONF}"
scripts/travis/add-itest-user-key.sh
sudo .circle/add-itest-user.sh
- name: Permissions Workaround
if: "${{ env.TASK == 'ci-packs-tests' || env.TASK == 'ci-integration' }}"
run: |
echo "$ST2_CI_REPO_PATH"
sudo ST2_CI_REPO_PATH="${ST2_CI_REPO_PATH}" scripts/travis/permissions-workaround.sh
- name: Setup RabbitMQ (NOT WORKING YET)
if: "${{ env.TASK == 'ci-integration' }}"
run: |
# Use custom RabbitMQ config which enables SSL / TLS listener on port 5671 with test certs
sudo cp scripts/travis/rabbitmq.config /etc/rabbitmq/rabbitmq.config
# Install rabbitmq_management RabbitMQ plugin
sudo service rabbitmq-server restart
sleep 5
sudo rabbitmq-plugins enable rabbitmq_management
sudo wget http://guest:guest@localhost:15672/cli/rabbitmqadmin -O /usr/local/bin/rabbitmqadmin
sudo chmod +x /usr/local/bin/rabbitmqadmin
sudo service rabbitmq-server restart
# chmod to make glob work (*.log to avoid log dir)
sudo chmod a+rx /var/log/rabbitmq
sudo tail -n 30 /var/log/rabbitmq/*.log
- name: Print versions
run: |
# Print various binary versions
git --version
pip --version
pip list
# Print out various environment variables info
make play
- name: make
# use: script -e -c to print colors
run: |
script -e -c "make ${TASK}"
- name: Nightly
# Run any additional nightly checks only as part of a nightly (cron) build
if: "${{ env.IS_NIGHTLY_BUILD == 'yes' }}"
run: |
./scripts/travis/run-nightly-make-task-if-exists.sh "${TASK}"
- name: Codecov
# NOTE: We only generate and submit coverage report for master and version branches and only when the build succeeds (default on GitHub Actions, this was not the case on Travis so we had to explicitly check success)
if: "${{ success() && ((env.TASK == 'ci-unit') || (env.TASK == 'ci-integration')) && (env.ENABLE_COVERAGE == 'yes') }}"
run: |
./scripts/travis/submit-codecov-coverage.sh
slack-notification:
name: Slack notification for failed master builds
if: always()
needs: ci
runs-on: ubuntu-latest
steps:
- name: Workflow conclusion
# this step creates an environment variable WORKFLOW_CONCLUSION and is the most reliable way to check the status of previous jobs
uses: technote-space/workflow-conclusion-action@v2
- name: CI Run Failure Slack Notification
if: ${{ env.WORKFLOW_CONCLUSION == 'failure' && github.ref == 'refs/heads/master' }}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
uses: voxmedia/github-action-slack-notify-build@v1
with:
channel: ghci-integration
status: FAILED
color: danger

# HELPER FOR FUTURE DEVELOPERS:
# If your GitHub Actions job is failing and you need to debug it, by default there is
# no way to SSH into the container.
# The step below can be uncommeted and will stop here and allow you to SSH in.
# When this step is reached, simply refresh the GitHub Actions output for this build
# and this SSH command will be printed every 5 seconds to the output.
# Once you are done debugging in your SSH session, simply: touch /continue
# and this will continue the build.
#
# - name: Setup tmate session for debugging failed jobs (allows SSH into the container)
# uses: mxschmitt/action-tmate@v3
# if: "${{ failure() }}"
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ virtualenv-components
virtualenv-components-osx
.venv-st2devbox

# generated travis conf
conf/st2.travis.conf
# generated GitHub Actions conf
conf/st2.githubactions.conf

# Installer logs
pip-log.txt
Expand Down
44 changes: 24 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ branches:
- master
- /^v[0-9]+\.[0-9]+$/

python:
- "3.6"
# - "3.7"
# - "3.8"
# - "3.9"

env:
global:
- IS_NIGHTLY_BUILD=$([ "${TRAVIS_EVENT_TYPE}" = "cron" ] && echo "yes" || echo "no")
Expand All @@ -22,8 +28,10 @@ env:
- NOSE_TIME=$([ "${TRAVIS_PULL_REQUEST}" = "false" ] && [ "${IS_NIGHTLY_BUILD}" = "no" ] && echo "yes" || echo "no")
# Travis-specific st2.conf (with travis user instead of stanley)
- ST2_CONF=conf/st2.travis.conf
jobs:
include:
# Tell StackStorm that we are indeed in CI mode
- ST2_CI='true'
- ST2_CI_REPO_PATH="${TRAVIS_BUILD_DIR}"
jobs:
# NOTE: We combine builds because Travis offers a maximum of 5 concurrent
# builds and having 6 tasks / builds means 1 tasks will need to wait for one
# of the other 5 tasks to finish before it can start
Expand All @@ -36,25 +44,21 @@ jobs:
# If you rename or reorder make targets in TASK, you may need to adjust:
# scripts/travis/install-requirements.sh
# scripts/travis/run-nightly-make-task-if-exists.sh
- name: "Unit Tests (Python 2.7 MongoDB 4.0)"
python: 2.7
env: TASK=ci-unit CACHE_NAME=py2 PYTHON_VERSION=python2.7 COMMAND_THRESHOLD=700

- name: "Integration Tests (Python 2.7)"
python: 2.7
env: TASK=ci-integration CACHE_NAME=py2 PYTHON_VERSION=python2.7 COMMAND_THRESHOLD=700

- name: "Lint Checks, Packs Tests (Python 3.6)"
python: 3.6
env: TASK="ci-checks ci-packs-tests" CACHE_NAME=py3 PYTHON_VERSION=python3.6 COMMAND_THRESHOLD=430
#
# The follow builds are now done in GitHub Actions
# - TASK=ci-checks COMMAND_THRESHOLD=300
# - TASK=compilepy3 COMMAND_THRESHOLD=300
# - TASK=ci-packs-tests COMMAND_THRESHOLD=300
# - TASK=ci-unit COMMAND_THRESHOLD=300

- name: "Unit Tests, Pack Tests (Python 3.6)"
python: 3.6
env: TASK="compilepy3 ci-py3-unit ci-py3-packs-tests" CACHE_NAME=py3 PYTHON_VERSION=python3.6 COMMAND_THRESHOLD=750
- TASK=ci-integration COMMAND_THRESHOLD=300

- name: "Integration Tests (Python 3.6)"
python: 3.6
env: TASK="ci-py3-integration" CACHE_NAME=py3 PYTHON_VERSION=python3.6 COMMAND_THRESHOLD=770
# jobs:
# fast_finish: true
# allow_failures:
# - python: "3.7"
# - python: "3.8"
# - python: "3.9"

addons:
apt:
Expand Down Expand Up @@ -83,7 +87,7 @@ install:
- ./scripts/travis/install-requirements.sh
# prep a travis-specific dev conf file that uses travis instead of stanley
- cp conf/st2.dev.conf "${ST2_CONF}" ; sed -i -e "s/stanley/travis/" "${ST2_CONF}"
- sudo scripts/travis/add-itest-user-key.sh
- scripts/travis/add-itest-user-key.sh
- sudo .circle/add-itest-user.sh
- if [[ "${TASK}" = *'-packs-tests'* ]] || [[ "${TASK}" = *'-integration'* ]]; then sudo scripts/travis/permissions-workaround.sh; fi

Expand Down
2 changes: 1 addition & 1 deletion ADOPTERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This is an alphabetical list of known [StackStorm](https://stackstorm.com/) adop
* [DMM.com](https://dmm-corp.com/en/) - Large content provider in Japan. StackStorm is used in Operations helping to maintain online services and development at scale. [[ Case study ](https://stackstorm.com/case-study-dmm/)]
* [Dimension Data](https://www.dimensiondata.com/en/about-us) - Global systems integrator and IT services provider, using StackStorm for Datacenter Orchestration as well as Infrastructure, Networking, Security Automation for their large clients and government projects. [[ Case study ](https://stackstorm.com/case-study-dimension-data/)]
* [Encore](https://www.encore.tech/) - Data Center, Cloud Computing, IT solutions company ​leverages StackStorm in enterprise scale IT infrastructure for VM & server provisioning, automation, network diagnosis, configuration and orchestration​ on customers' public and private clouds. [[ Blog ](https://encoretechnologies.github.io/blog/2018/03/stackstorm-changed-our-lives/)] [[ Case study ](https://stackstorm.com/case-study-encore/)]
* [Fastly](https://www.fastly.com) - Edge Cloud Platform, implemented StackStorm as part of a bigger global network automation architecture aimed at providing an interface to network operations and traffic engineering changes triggered both manually or in response to events on hundreds of devices spread across dozens of sites.
* [Fastly](https://www.fastly.com) - Edge Cloud Platform, implemented StackStorm as part of a bigger global network automation architecture aimed at providing an interface to network operations and traffic engineering changes triggered both manually or in response to events on hundreds of devices spread across dozens of sites. [[ Blog ](https://www.fastly.com/blog/network-automation-helps-support-worlds-biggest-live-streaming-moments)]
* [Hewlett Packard Enterprise](https://www.hpe.com/) - Enterprise IT company that integrated StackStorm into its Composable Fabric Manager software. StackStorm is used for driving fabric and application automation based on integrations with VMware vSphere/NSX, HPE OneView/SimpliVity, Nutanix, Kubernetes, and OpenShift. [[ Blog ](https://developer.hpe.com/blog/master-the-automation-universe-the-easy-way-part-1-introduction-to-stack)]
* [NL-ix](https://www.nl-ix.net/about/company/) - One of the top five internet exchange in the world where StackStorm is used as Automation Orchestrator, event-driven engine for route server configuration. [[ Case study ](https://stackstorm.com/case-study-nlix/)]
* [Netflix](https://media.netflix.com/en/about-netflix) - Worldwide media services provider relies on Event-Driven Automation when remediation tasks and runbooks executed in response to alerts. Custom solution built on top StackStorm helped to self-heal NFLX infra at a big scale, saving SRE's sleep. [[ Slides ](https://www.slideshare.net/InfoQ/winston-helping-netflix-engineers-sleep-at-night)] [[ Blog ](https://medium.com/netflix-techblog/introducing-winston-event-driven-diagnostic-and-remediation-platform-46ce39aa81cc)] [[ Case study ](https://stackstorm.com/case-study-netflix/)]
Expand Down
Loading

0 comments on commit fd41e1d

Please sign in to comment.