Skip to content

Commit

Permalink
Dynatrace CLI v0.0.0-alpha
Browse files Browse the repository at this point in the history
The first OpenSource release of Dyntrace CLI, a tool that allows
working with Dynatrace through command line interface.

This intial commit squashes all internal development done before
opensourcing Dynatrace CLI.

As such it collects a team effort of core contributors, as well as
many others that helped develop, test and use the tool interally.

Co-authored-by: wbachnik <[email protected]>
Co-authored-by: vduseev <[email protected]>
  • Loading branch information
vduseev and wbachnik committed Apr 17, 2021
0 parents commit 99254e9
Show file tree
Hide file tree
Showing 21 changed files with 3,144 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[bumpversion]
current_version = 0.0.0-alpha
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(-(?P<release>.*))?
serialize =
{major}.{minor}.{patch}-{release}
tag_name = v{new_major}.{new_minor}.{new_patch}-{new_release}
commit = True
tag = True

[bumpversion:part:release]
values =
alpha
beta
rc

[bumpversion:file:pyproject.toml]

[bumpversion:file:dtcli/__init__.py]
23 changes: 23 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[run]
branch = True

source =
dtcli

omit =
# Omit test files
dtcli/tests/*
dtcli/console/*

[report]
exclude_lines =
pragma: no cover
def __repr__
if self.debug:
if settings.DEBUG
raise AssertionError
raise NotImplementedError
if 0:
if __name__ == .__main__.:

fail_under = 0
220 changes: 220 additions & 0 deletions .github/workflows/built-test-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
name: Build Test Release
on:
# Pull request trigger works only for PRs into main branch
pull_request:
branches:
- main
# Push works for pushes into every branch of the repo
push:

jobs:
build-dev-docker-image:
name: Build development docker image
#
# Builds development docker image and tags it with Commit SHA.
# Pushes the image to GitHub image registry.
#
# This docker image is essential for all other steps. It is used
# for testing, building, publishing, etc.
#
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Authenticate in GitHub docker registry
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u $GITHUB_ACTOR --password-stdin
- name: Pull latest cached docker image
run: |
docker pull docker.pkg.github.com/$GITHUB_REPOSITORY/dtcli-dev:latest || true
- name: Build docker image
run: |
docker build \
--tag docker.pkg.github.com/$GITHUB_REPOSITORY/dtcli-dev:${GITHUB_SHA:0:6} \
--cache-from docker.pkg.github.com/$GITHUB_REPOSITORY/dtcli-dev:latest \
.
- name: Push image to GitHub docker registry
run: |
docker push docker.pkg.github.com/$GITHUB_REPOSITORY/dtcli-dev:${GITHUB_SHA:0:6}
release-dev-docker-image:
name: Release development docker image
#
# Releases development image as official development image by tagging
# it as "latest".
#
# Only happens when PR is merged into main or when something is pushed
# into main branch.
#
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: build-dev-docker-image
steps:
- uses: actions/checkout@v2

- name: Authenticate in GitHub docker registry
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u $GITHUB_ACTOR --password-stdin
- name: Pull latest cached docker image
run: |
docker pull docker.pkg.github.com/$GITHUB_REPOSITORY/dtcli-dev:${GITHUB_SHA:0:6}
- name: Tag image with release tag
run: |
docker tag \
docker.pkg.github.com/$GITHUB_REPOSITORY/dtcli-dev:${GITHUB_SHA:0:6} \
docker.pkg.github.com/$GITHUB_REPOSITORY/dtcli-dev:latest
- name: Push release tag to GitHub registry
run: |
docker push docker.pkg.github.com/$GITHUB_REPOSITORY/dtcli-dev:latest
run-tests:
name: Run tests
#
# Runs all tests using development image.
# - pytest: tests
# - mypy: typing
# - flake8: linter
# - coverage: test coverage %
#
runs-on: ubuntu-latest
needs: build-dev-docker-image
steps:
- name: Authenticate in GitHub docker registry
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u $GITHUB_ACTOR --password-stdin
- name: Pull latest cached docker image
run: |
docker pull docker.pkg.github.com/$GITHUB_REPOSITORY/dtcli-dev:${GITHUB_SHA:0:6}
- name: Run pytest tests
run: |
docker run \
docker.pkg.github.com/$GITHUB_REPOSITORY/dtcli-dev:${GITHUB_SHA:0:6} \
poetry run pytest
- name: Run mypy tests
run: |
docker run \
docker.pkg.github.com/$GITHUB_REPOSITORY/dtcli-dev:${GITHUB_SHA:0:6} \
poetry run pytest --mypy dtcli --strict || true
- name: Run flake8 lint checker
run: |
docker run \
docker.pkg.github.com/$GITHUB_REPOSITORY/dtcli-dev:${GITHUB_SHA:0:6} \
poetry run flake8 || true
- name: Run test coverage report
run: |
docker run \
docker.pkg.github.com/$GITHUB_REPOSITORY/dtcli-dev:${GITHUB_SHA:0:6} \
poetry run pytest --cov . --cov-report html || true
build-package:
name: Build package
#
# Builds python package using poetry.
#
runs-on: ubuntu-latest
needs: run-tests
steps:
- uses: actions/checkout@v2

- name: Authenticate in GitHub docker registry
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u $GITHUB_ACTOR --password-stdin
- name: Pull latest cached docker image
run: |
docker pull docker.pkg.github.com/$GITHUB_REPOSITORY/dtcli-dev:${GITHUB_SHA:0:6}
- name: Build package
run: |
docker run \
-v "$(pwd):/app" \
docker.pkg.github.com/$GITHUB_REPOSITORY/dtcli-dev:${GITHUB_SHA:0:6} \
poetry build
- name: Cache built package artifacts
uses: actions/upload-artifact@v2
with:
name: package
path: |
dist/*
build-linux-binary:
name: Build linux binary
#
# Builds linux binary using pyinstaller.
#
runs-on: ubuntu-16.04
needs: run-tests
steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
with:
python-version: "3.9"
architecture: "x64"

- name: Install poetry
run: |
pip install poetry
- name: Install virtual environment
run: |
poetry install
- name: Build binary distribution
run: |
poetry run pyinstaller \
dtcli/scripts/dt.py \
--name dt \
--clean \
-p "$(poetry env info -p)/lib/python3.9/site-packages" \
--onefile
- name: Cache built linux binary artifact
uses: actions/upload-artifact@v2
with:
name: linux-binary
path: |
dist/dt
github-release:
name: Create GitHub release
#
# Creates GitHub release with binaries and packages.
#
# Only happens for tags.
#
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs:
- build-package
- build-linux-binary
steps:
- name: Download cached build artifacts
uses: actions/download-artifact@v2

- name: Show all artifacts
run: |
ls -R
- name: Create GitHub release
uses: softprops/action-gh-release@v1
with:
files: |
dist/*
LICENSE
body: |
Test release.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# IDE
.vscode/

# Virtual environment
env/
venv/
.venv/

# Builds
dist/
build/
__pycache__
*.spec

# Tests
.pytest_cache
.mypy_cache
htmlcov/
.coverage

# Integration tests
extension/
*.zip
*.sig
*.key
*.crt

# Git
.gitconfig
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.9.2
17 changes: 17 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

version: 2

sphinx:
configuration: docs/conf.py

python:
version: 3.9
install:
- requirements: docs/requirements.txt
- method: pip
path: .
extra_requirements:
- console
76 changes: 76 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Contributor covenant code of conduct

## Our pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This code of conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project email
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [email protected]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce this code of conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This code of conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
Loading

0 comments on commit 99254e9

Please sign in to comment.