Skip to content

Commit fd41e1d

Browse files
authored
Merge pull request #1 from winem/feature/github-actions-slack-notification
Feature/GitHub actions slack notification
2 parents 632a07e + b0248cc commit fd41e1d

File tree

94 files changed

+710
-271
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+710
-271
lines changed

.circleci/config.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
# Run st2 Integration tests
4444
integration:
4545
docker:
46-
- image: circleci/python:2.7
46+
- image: circleci/python:3.6
4747
- image: mongo:4.0
4848
- image: rabbitmq:3
4949
working_directory: ~/st2
@@ -79,7 +79,7 @@ jobs:
7979
# Run st2 Lint Checks
8080
lint:
8181
docker:
82-
- image: circleci/python:2.7
82+
- image: circleci/python:3.6
8383
- image: mongo:4.0
8484
- image: rabbitmq:3
8585
working_directory: ~/st2
@@ -113,7 +113,7 @@ jobs:
113113
resource_class: large
114114
docker:
115115
# The primary container is an instance of the first list image listed. Your build commands run in this container.
116-
- image: circleci/python:2.7
116+
- image: circleci/python:3.6
117117
working_directory: ~/st2
118118
environment:
119119
- DISTROS: "xenial bionic el7 el8"
@@ -276,4 +276,4 @@ experimental:
276276

277277
notify:
278278
webhooks:
279-
- url: https://ci-webhooks.stackstorm.net/webhooks/build/events
279+
- url: https://ci-webhooks.stackstorm.com/webhooks/build/events

.github/workflows/ci.yaml

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches: ['*']
6+
pull_request:
7+
type: [opened, reopened, edited]
8+
schedule:
9+
# run every night at midnight
10+
- cron: '0 0 * * *'
11+
12+
jobs:
13+
ci:
14+
name: '${{ matrix.name }} - python (${{ matrix.python-version }})'
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
include:
20+
- name: 'Lint Checks'
21+
task: 'ci-checks'
22+
python-version: '3.6'
23+
- name: 'Compile'
24+
task: 'ci-compile'
25+
python-version: '3.6'
26+
- name: 'Pack Tests'
27+
task: 'ci-packs-tests'
28+
python-version: '3.6'
29+
- name: 'Unit Tests'
30+
task: 'ci-unit'
31+
python-version: '3.6'
32+
# Integration tests are not working yet, still done in Travis
33+
# - name: 'Integration Tests'
34+
# task: 'ci-integration'
35+
services:
36+
mongo:
37+
image: mongo:4.0
38+
ports:
39+
- 27017:27017
40+
# Can't use RabbitMQ here for Integrations because we rely on custom config
41+
# and SSL certs that are in the repo. In GHA, these services are started first
42+
# before the code is checked out, so this is a non-starter, we need to do it
43+
# manually below (TODO)
44+
rabbitmq:
45+
# use the -management version so it has the management tools installed
46+
image: rabbitmq:3.8-management
47+
ports:
48+
# SSL port
49+
- 5671:5671
50+
# standard port
51+
- 5672:5672
52+
# management port
53+
- 15672:15672
54+
env:
55+
TASK: '${{ matrix.task }}'
56+
57+
# We need to explicitly specify terminal width otherwise some CLI tests fail on container
58+
# environments where small terminal size is used.
59+
COLUMNS: '120'
60+
PYLINT_CONCURRENCY: '2'
61+
62+
# CI st2.conf (with ST2_CI_USER user instead of stanley)
63+
ST2_CONF: 'conf/st2.ci.conf'
64+
65+
# Tell StackStorm that we are indeed in CI mode, previously we hard coded a Travis specific
66+
# environment variable in our test code, making it a PITA when we switch CI providers.
67+
# Now, we simply set this environment varible here in the CI portion of our testing and
68+
# it avoids any CI provider type lock-in.
69+
ST2_CI: 'true'
70+
71+
# Name of the user who is running the CI (on GitHub Actions this is 'runner')
72+
ST2_CI_USER: 'runner'
73+
steps:
74+
- name: Custom Environment Setup
75+
# built-in GitHub Actions environment variables
76+
# https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables
77+
#
78+
# setting environment variables, so we can use shell logic
79+
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
80+
run: |
81+
IS_NIGHTLY_BUILD=$([ "${GITHUB_EVENT_NAME}" = "schedule" ] && echo "yes" || echo "no")
82+
echo "IS_NIGHTLY_BUILD=${IS_NIGHTLY_BUILD}" >> $GITHUB_ENV
83+
84+
# NOTE: We only enable coverage for master builds and not pull requests
85+
# since it has huge performance overhead (tests are 50% or so slower)
86+
ENABLE_COVERAGE=$([ "${GITHUB_EVENT_NAME}" != "pull_request" ] && [ "${IS_NIGHTLY_BUILD}" = "no" ] && echo "yes" || echo "no")
87+
echo "ENABLE_COVERAGE=${ENABLE_COVERAGE}" >> $GITHUB_ENV
88+
89+
# We only run tests with "--with-timer" flag on master and not for PRs since it adds 1-2
90+
# minutes of overhead to each build.
91+
NOSE_TIME=$([ "${GITHUB_EVENT_NAME}" != "pull_request" ] && [ "${IS_NIGHTLY_BUILD}" = "no" ] && echo "yes" || echo "no")
92+
echo "NOSE_TIME=${NOSE_TIME}" >> $GITHUB_ENV
93+
94+
# Setup the path to the st2 repo in the CI build system
95+
echo "ST2_CI_REPO_PATH=${GITHUB_WORKSPACE}" >> $GITHUB_ENV
96+
- name: Checkout repository
97+
uses: actions/checkout@v2
98+
- name: 'Set up Python (${{ matrix.python-version }})'
99+
uses: actions/setup-python@v2
100+
with:
101+
python-version: '${{ matrix.python-version }}'
102+
- uses: actions/cache@v2
103+
with:
104+
path: |
105+
.cache/pip
106+
virtualenv
107+
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('requirements.txt', 'test-requirements.txt') }}
108+
restore-keys: |
109+
${{ runner.os }}-${{ matrix.python }}-
110+
- name: Install apt depedencies
111+
run: |
112+
# install dev dependencies for Python LDAP module
113+
# https://github.com/StackStorm/st2-auth-ldap
114+
sudo apt-get -y update
115+
sudo apt-get -f -y install libldap2-dev libsasl2-dev libssl-dev ldap-utils
116+
- name: Install virtualenv
117+
run: |
118+
# Note: Use the verison of virtualenv pinned in fixed-requirements.txt so we
119+
# only have to update it one place when we change the version
120+
pip install --upgrade --force-reinstall $(grep "^virtualenv" fixed-requirements.txt)
121+
- name: Install requirements
122+
run: |
123+
./scripts/travis/install-requirements.sh
124+
- name: Setup integration tests
125+
run: |
126+
# prep a ci-specific dev conf file that uses runner instead of stanley
127+
# this user is the username of the user in GitHub actions, used for SSH, etc during
128+
# integration tests (important)
129+
cp conf/st2.dev.conf "${ST2_CONF}" ; sed -i -e "s/stanley/${ST2_CI_USER}/" "${ST2_CONF}"
130+
scripts/travis/add-itest-user-key.sh
131+
sudo .circle/add-itest-user.sh
132+
- name: Permissions Workaround
133+
if: "${{ env.TASK == 'ci-packs-tests' || env.TASK == 'ci-integration' }}"
134+
run: |
135+
echo "$ST2_CI_REPO_PATH"
136+
sudo ST2_CI_REPO_PATH="${ST2_CI_REPO_PATH}" scripts/travis/permissions-workaround.sh
137+
- name: Setup RabbitMQ (NOT WORKING YET)
138+
if: "${{ env.TASK == 'ci-integration' }}"
139+
run: |
140+
# Use custom RabbitMQ config which enables SSL / TLS listener on port 5671 with test certs
141+
sudo cp scripts/travis/rabbitmq.config /etc/rabbitmq/rabbitmq.config
142+
# Install rabbitmq_management RabbitMQ plugin
143+
sudo service rabbitmq-server restart
144+
sleep 5
145+
sudo rabbitmq-plugins enable rabbitmq_management
146+
sudo wget http://guest:guest@localhost:15672/cli/rabbitmqadmin -O /usr/local/bin/rabbitmqadmin
147+
sudo chmod +x /usr/local/bin/rabbitmqadmin
148+
sudo service rabbitmq-server restart
149+
# chmod to make glob work (*.log to avoid log dir)
150+
sudo chmod a+rx /var/log/rabbitmq
151+
sudo tail -n 30 /var/log/rabbitmq/*.log
152+
- name: Print versions
153+
run: |
154+
# Print various binary versions
155+
git --version
156+
pip --version
157+
pip list
158+
# Print out various environment variables info
159+
make play
160+
- name: make
161+
# use: script -e -c to print colors
162+
run: |
163+
script -e -c "make ${TASK}"
164+
- name: Nightly
165+
# Run any additional nightly checks only as part of a nightly (cron) build
166+
if: "${{ env.IS_NIGHTLY_BUILD == 'yes' }}"
167+
run: |
168+
./scripts/travis/run-nightly-make-task-if-exists.sh "${TASK}"
169+
- name: Codecov
170+
# 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)
171+
if: "${{ success() && ((env.TASK == 'ci-unit') || (env.TASK == 'ci-integration')) && (env.ENABLE_COVERAGE == 'yes') }}"
172+
run: |
173+
./scripts/travis/submit-codecov-coverage.sh
174+
slack-notification:
175+
name: Slack notification for failed master builds
176+
if: always()
177+
needs: ci
178+
runs-on: ubuntu-latest
179+
steps:
180+
- name: Workflow conclusion
181+
# this step creates an environment variable WORKFLOW_CONCLUSION and is the most reliable way to check the status of previous jobs
182+
uses: technote-space/workflow-conclusion-action@v2
183+
- name: CI Run Failure Slack Notification
184+
if: ${{ env.WORKFLOW_CONCLUSION == 'failure' && github.ref == 'refs/heads/master' }}
185+
env:
186+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
187+
uses: voxmedia/github-action-slack-notify-build@v1
188+
with:
189+
channel: ghci-integration
190+
status: FAILED
191+
color: danger
192+
193+
# HELPER FOR FUTURE DEVELOPERS:
194+
# If your GitHub Actions job is failing and you need to debug it, by default there is
195+
# no way to SSH into the container.
196+
# The step below can be uncommeted and will stop here and allow you to SSH in.
197+
# When this step is reached, simply refresh the GitHub Actions output for this build
198+
# and this SSH command will be printed every 5 seconds to the output.
199+
# Once you are done debugging in your SSH session, simply: touch /continue
200+
# and this will continue the build.
201+
#
202+
# - name: Setup tmate session for debugging failed jobs (allows SSH into the container)
203+
# uses: mxschmitt/action-tmate@v3
204+
# if: "${{ failure() }}"

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ virtualenv-components
3030
virtualenv-components-osx
3131
.venv-st2devbox
3232

33-
# generated travis conf
34-
conf/st2.travis.conf
33+
# generated GitHub Actions conf
34+
conf/st2.githubactions.conf
3535

3636
# Installer logs
3737
pip-log.txt

.travis.yml

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ branches:
77
- master
88
- /^v[0-9]+\.[0-9]+$/
99

10+
python:
11+
- "3.6"
12+
# - "3.7"
13+
# - "3.8"
14+
# - "3.9"
15+
1016
env:
1117
global:
1218
- IS_NIGHTLY_BUILD=$([ "${TRAVIS_EVENT_TYPE}" = "cron" ] && echo "yes" || echo "no")
@@ -22,8 +28,10 @@ env:
2228
- NOSE_TIME=$([ "${TRAVIS_PULL_REQUEST}" = "false" ] && [ "${IS_NIGHTLY_BUILD}" = "no" ] && echo "yes" || echo "no")
2329
# Travis-specific st2.conf (with travis user instead of stanley)
2430
- ST2_CONF=conf/st2.travis.conf
25-
jobs:
26-
include:
31+
# Tell StackStorm that we are indeed in CI mode
32+
- ST2_CI='true'
33+
- ST2_CI_REPO_PATH="${TRAVIS_BUILD_DIR}"
34+
jobs:
2735
# NOTE: We combine builds because Travis offers a maximum of 5 concurrent
2836
# builds and having 6 tasks / builds means 1 tasks will need to wait for one
2937
# of the other 5 tasks to finish before it can start
@@ -36,25 +44,21 @@ jobs:
3644
# If you rename or reorder make targets in TASK, you may need to adjust:
3745
# scripts/travis/install-requirements.sh
3846
# scripts/travis/run-nightly-make-task-if-exists.sh
39-
- name: "Unit Tests (Python 2.7 MongoDB 4.0)"
40-
python: 2.7
41-
env: TASK=ci-unit CACHE_NAME=py2 PYTHON_VERSION=python2.7 COMMAND_THRESHOLD=700
42-
43-
- name: "Integration Tests (Python 2.7)"
44-
python: 2.7
45-
env: TASK=ci-integration CACHE_NAME=py2 PYTHON_VERSION=python2.7 COMMAND_THRESHOLD=700
46-
47-
- name: "Lint Checks, Packs Tests (Python 3.6)"
48-
python: 3.6
49-
env: TASK="ci-checks ci-packs-tests" CACHE_NAME=py3 PYTHON_VERSION=python3.6 COMMAND_THRESHOLD=430
47+
#
48+
# The follow builds are now done in GitHub Actions
49+
# - TASK=ci-checks COMMAND_THRESHOLD=300
50+
# - TASK=compilepy3 COMMAND_THRESHOLD=300
51+
# - TASK=ci-packs-tests COMMAND_THRESHOLD=300
52+
# - TASK=ci-unit COMMAND_THRESHOLD=300
5053

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

55-
- name: "Integration Tests (Python 3.6)"
56-
python: 3.6
57-
env: TASK="ci-py3-integration" CACHE_NAME=py3 PYTHON_VERSION=python3.6 COMMAND_THRESHOLD=770
56+
# jobs:
57+
# fast_finish: true
58+
# allow_failures:
59+
# - python: "3.7"
60+
# - python: "3.8"
61+
# - python: "3.9"
5862

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

ADOPTERS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This is an alphabetical list of known [StackStorm](https://stackstorm.com/) adop
77
* [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/)]
88
* [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/)]
99
* [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/)]
10-
* [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.
10+
* [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)]
1111
* [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)]
1212
* [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/)]
1313
* [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/)]

0 commit comments

Comments
 (0)