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
17 changes: 17 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
comment:
layout: "diff, flags"
behavior: default
branches: null


coverage:
range: 50..100
round: down
precision: 2

status:
project:
default:
target: 75
if_ci_failed: error
patch: off
34 changes: 34 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[run]
branch = True

disable_warnings =
module-not-measured

# All paths are relative to each tox.ini
omit =
*/test_bench.py

# These are things that are simply stored in the base package
../stackstate_checks_base/stackstate_checks/base/checks/libs/*
../stackstate_checks_base/stackstate_checks/base/checks/win/*

# We will test repo tooling eventually
../stackstate_checks_dev/stackstate_checks/dev/tooling/*

# Vendored dependencies
*/stackstate_checks/*/vendor/*

[report]
show_missing = ${STSDEV_COV_MISSING}
ignore_errors = True

exclude_lines =
no cov
no qa

# Ignore missing debug-only code
def __repr__
if self\.debug

# Ignore non-runnable code
if __name__ == .__main__.:
109 changes: 109 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# We don't want this to get too large,
# so don't put anything in here that's not either
# specific to this project or a common problem

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
venv/
embedded/
/env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
*.zip
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
.pytest_cache/
.benchmarks/

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/

#Ipython Notebook
.ipynb_checkpoints

#sdk collateral
venv/
vendor/
embedded/
.bundle/
.ropeproject/
setuptools-*.zip

tmp
# redis tmp config
*.tmp
*.tmp.conf

# OS Specific
*.DS_Store
*.fuse_hidden*

# Vi(m) stuff
*.swp
*.swo

# Rbenv stuff
.rbenv-gemsets
.ruby-version

# Common IDEs & editors
.idea/
.vscode/

# wheels
wheelhouse/
*.whl

.pytest_cache

# by default, ignore in-toto metadata from the command line
.links/
*.link
62 changes: 62 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
image: stackstate/stackstate-agent-integrations-runner:latest

stages:
- build
- test

before_script:
- source .gitlab-scripts/setup_env.sh

deps:
stage: build
cache:
key: "stackstate-agent-integrations-build-cache"
paths:
- venv
script:
- source $CI_PROJECT_DIR/.gitlab-scripts/load_deps.sh
artifacts:
paths:
- venv
expire_in: 1 week

clear-caches:
cache:
policy: push
key: "stackstate-agent-integrations-build-cache"
paths:
- venv
when: manual
stage: build
before_script: []
script:
- rm -rf venv || true

.test: &test
stage: test
script:
- stsdev test --cov ${CHECK}
- stsdev test ${CHECK} --bench || true
# [BS] we skip this until https://github.com/PyCQA/pylint/pull/2681/commits/253e5d05e3943d3bc8e4470804a138cb20049548 lands in pylint stable version
# - if [ -n "$PYTHON3" ]; then stsdev validate py3 ${CHECK}; fi

test_stackstate_checks_base:
stage: test
variables:
CHECK: "stackstate_checks_base"
PYTHON3: "true"
script:
- stsdev validate config
- stsdev validate dep
- stsdev validate manifest --include-extras
- stsdev validate metadata
- stsdev validate service-checks
- stsdev test --cov ${CHECK}
- stsdev test ${CHECK} --bench || true

test_stackstate_checks_dev:
variables:
CHECK: "stackstate_checks_dev"
PYTHON3: "true"
<<: *test

12 changes: 12 additions & 0 deletions .gitlab-scripts/image/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM python:3.6
RUN apt-get update && \
apt-get install -y virtualenv python2.7-dev apt-transport-https ca-certificates curl gnupg2 software-properties-common && \
apt-get clean

RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
RUN add-apt-repository -y "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" && \
apt-get update && \
apt-get install -y docker-ce docker-ce-cli containerd.io && \
apt-get clean

RUN curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
12 changes: 12 additions & 0 deletions .gitlab-scripts/image/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
RUNTIMETAG := $(shell date +%Y%m%d)

build:
docker build -t stackstate/stackstate-agent-integrations-runner:$(RUNTIMETAG) .
push:
docker push stackstate/stackstate-agent-integrations-runner:$(RUNTIMETAG)

tag_latest:
docker tag stackstate/stackstate-agent-integrations-runner:$(RUNTIMETAG) stackstate/stackstate-agent-integrations-runner:latest

push_latest:
docker push stackstate/stackstate-agent-integrations-runner:latest
9 changes: 9 additions & 0 deletions .gitlab-scripts/load_deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -x

pip install -U pip setuptools codecov
pip install ./stackstate_checks_dev[cli]
stsdev config set repo .

set +x
23 changes: 23 additions & 0 deletions .gitlab-scripts/setup_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

# This file is meant to be sourced
# This file will pull in deps when a test is ran without the deps job having ran first.
# This happens when using the ./run_gitlab_local.sh script

set -x

export INTEGRATIONS_DIR_TMP=${CI_PROJECT_DIR:-"."}

VENV_PATH=$INTEGRATIONS_DIR_TMP/venv

if [ ! -d $VENV_PATH ]; then
virtualenv --python=python3.6 $INTEGRATIONS_DIR_TMP/venv
source $INTEGRATIONS_DIR_TMP/venv/bin/activate
source $INTEGRATIONS_DIR_TMP/.gitlab-scripts/load_deps.sh
else
source $INTEGRATIONS_DIR_TMP/venv/bin/activate
fi

unset INTEGRATIONS_DIR_TMP

set +x
28 changes: 28 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Copyright (c) 2016, Datadog, Inc.
Copyright (c) 2019, StackState, Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of integrations-core nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# StackState Agent Integrations

This repository contains the Agent Integrations (also known as checks) that StackState
officially develops and supports. The [StackState Agent][1] packages are equipped with all the Integrations from this
repository.

# Development

## CI image
The CI image is built from .gitlab-scripts/image.

## Local setup

To work on packages in this directory you can run the following:

- source .gitlab-scripts/setup_env.sh

From this point on the stsdev script is in scope and commands can be ran.

If changes are made to the stsdev, you can use .gitlab-scripts/load_deps.sh

[1]: https://github.com/StackVista/stackstate-agent
20 changes: 20 additions & 0 deletions run_gitlab_local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

echo "Run a gitlab build step on the local machine"

if [[ $(type gitlab-runner) -eq 1 ]]; then
echo "The cmd gilab-runner looks not available, do you want to install it ?"
sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64
sudo chmod +x /usr/local/bin/gitlab-runner
fi

gitlab-runner exec docker \
--cache-type s3 \
--cache-s3-server-address s3.amazonaws.com \
--cache-s3-bucket-name ci-runner-cache-eu1 \
--cache-s3-bucket-location eu-west-1 \
--cache-s3-access-key $AWS_ACCESS_KEY \
--cache-s3-secret-key $AWS_SECRET_KEY \
--docker-volumes /var/run/docker.sock:/var/run/docker.sock \
"$@"

Loading