-
Notifications
You must be signed in to change notification settings - Fork 11
Initial Implementation #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
engines: | ||
duplication: | ||
enabled: true | ||
config: | ||
languages: | ||
- python | ||
exclude_paths: | ||
# duplicate structures in dictionary | ||
- reporter/components/ci.py | ||
fixme: | ||
enabled: true | ||
pep8: | ||
enabled: true | ||
radon: | ||
enabled: true | ||
exclude_fingerprints: | ||
# complexity in PayloadValidator#validate | ||
- f57544b97810662ecf17d3c4be4974bc | ||
# complexity in Runner#run | ||
- f8db204cc016d9d612e462dc9ff6fcfb | ||
ratings: | ||
paths: | ||
- "**.inc" | ||
- "**.module" | ||
- "**.py" | ||
exclude_paths: | ||
- dist/ | ||
- reporter/tests/ | ||
- build/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
**/*.pyc | ||
.git | ||
.coverage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# 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/ | ||
|
||
# dotenv | ||
.env |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[distutils] | ||
index-servers = | ||
pypi | ||
pypitest | ||
|
||
[pypi] | ||
repository=https://pypi.python.org/pypi | ||
username= | ||
password= | ||
|
||
[pypitest] | ||
repository=https://testpypi.python.org/pypi | ||
username= | ||
password= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM python:3.5.1-alpine | ||
|
||
WORKDIR /usr/src/app | ||
|
||
RUN apk --update add git | ||
|
||
COPY requirements.txt /usr/src/app/ | ||
RUN pip install --upgrade pip && \ | ||
pip install -r requirements.txt | ||
|
||
COPY . /usr/src/app | ||
|
||
RUN python setup.py install | ||
|
||
RUN adduser -u 9000 -D app | ||
RUN chown -R app:app /usr/src/app | ||
USER app | ||
|
||
ENTRYPOINT ["codeclimate-test-reporter"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
.PHONY: all citest image run test release test-release | ||
|
||
IMAGE_NAME ?= codeclimate/python-test-reporter | ||
|
||
all: image | ||
|
||
citest: | ||
docker run \ | ||
--rm \ | ||
--env CIRCLECI \ | ||
--env CIRCLE_BRANCH \ | ||
--env CIRCLE_SHA1 \ | ||
--env CODECLIMATE_REPO_TOKEN \ | ||
--entrypoint=/bin/sh \ | ||
$(IMAGE_NAME) -c 'python setup.py test && codeclimate-test-reporter' | ||
|
||
image: | ||
docker build --tag $(IMAGE_NAME) . | ||
|
||
run: image | ||
docker run --rm $(IMAGE_NAME) | ||
|
||
test: image | ||
docker run \ | ||
-it \ | ||
--rm \ | ||
--entrypoint=/bin/sh \ | ||
$(IMAGE_NAME) -c 'python setup.py test' | ||
|
||
release: image | ||
docker run \ | ||
--rm \ | ||
--volume ~/.pypirc:/home/app/.pypirc \ | ||
--entrypoint=/bin/sh \ | ||
$(IMAGE_NAME) -c 'bin/release' | ||
|
||
test-release: image | ||
docker run \ | ||
--rm \ | ||
--volume ~/.pypirc:/home/app/.pypirc \ | ||
--entrypoint=/bin/sh \ | ||
$(IMAGE_NAME) -c 'bin/test-release' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/sh | ||
# | ||
# Open a PR for releasing a new version of this repository. | ||
# | ||
# Usage: bin/prep-release VERSION | ||
# | ||
### | ||
set -e | ||
|
||
if [ -z "$1" ]; then | ||
echo "usage: bin/prep-release VERSION" >&2 | ||
exit 64 | ||
fi | ||
|
||
version=$1 | ||
old_version=$(< VERSION) | ||
branch="release-$version" | ||
|
||
if ! python setup.py test then | ||
echo "test failure, not releasing" >&2 | ||
exit 1 | ||
fi | ||
|
||
printf "RELEASE %s => %s\n" "$old_version" "$version" | ||
git checkout master | ||
git pull | ||
|
||
git checkout -b "$branch" | ||
|
||
printf "%s\n" "$version" > VERSION | ||
git add VERSION | ||
git commit -m "Release v$version" | ||
git push origin "$branch" | ||
|
||
branch_head=$(git rev-parse --short $branch) | ||
if command -v hub > /dev/null 2>&1; then | ||
hub pull-request -F - <<EOF | ||
Release v$version | ||
|
||
https://github.com/codeclimate/python-test-reporter/compare/v$old_version...$branch_head | ||
EOF | ||
else | ||
echo "hub not installed? Please open the PR manually" >&2 | ||
fi | ||
|
||
echo "After merging the version-bump PR, run bin/release" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/sh | ||
# | ||
# Release a new version of this repository. | ||
# | ||
# Assumes bin/prep-release was run and the PR merged. | ||
# | ||
# Usage: bin/release | ||
# | ||
### | ||
|
||
python setup.py build | ||
python setup.py register -r pyp | ||
python setup.py sdist upload -r pypi | ||
|
||
git tag v$(cat reporter/VERSION) | ||
git push origin --tags |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
# | ||
# Test release a new version of this repository. | ||
# | ||
# Usage: bin/test-release | ||
# | ||
### | ||
|
||
python setup.py build | ||
python setup.py register -r pypitest | ||
python setup.py sdist upload -r pypitest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
machine: | ||
services: | ||
- docker | ||
|
||
dependencies: | ||
override: | ||
- make image | ||
|
||
test: | ||
override: | ||
- make citest | ||
|
||
notify: | ||
webhooks: | ||
- url: https://cc-slack-proxy.herokuapp.com/circle |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.0.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
""" | ||
codeclimate-test-reporter | ||
""" | ||
|
||
import os | ||
|
||
__author__ = "Code Climate" | ||
__version__ = open(os.path.join(os.path.dirname(__file__), "VERSION")).read().strip() | ||
__license__ = "MIT" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env python | ||
|
||
import sys | ||
|
||
from .components.runner import Runner | ||
|
||
|
||
def run(): | ||
runner = Runner() | ||
|
||
sys.exit(runner.run()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import json | ||
import os | ||
import requests | ||
|
||
|
||
class ApiClient: | ||
def __init__(self, host=None, timeout=5): | ||
self.host = host or self.__default_host() | ||
self.timeout = timeout | ||
|
||
def post(self, payload): | ||
print("Submitting payload to %s" % self.host) | ||
|
||
headers = {"Content-Type": "application/json"} | ||
response = requests.post( | ||
"%s/test_reports" % self.host, | ||
data=json.dumps(payload), | ||
headers=headers, | ||
timeout=self.timeout | ||
) | ||
|
||
return response | ||
|
||
def __default_host(self): | ||
return os.environ.get("CODECLIMATE_HOST", "https://codeclimate.com") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
""" | ||
CLI arguments definition. | ||
""" | ||
|
||
import argparse | ||
import sys | ||
|
||
|
||
class ArgumentParser(argparse.ArgumentParser): | ||
def __init__(self): | ||
argparse.ArgumentParser.__init__( | ||
self, | ||
prog="codeclimate-test-reporter", | ||
description="Report test coverage to Code Climate" | ||
) | ||
|
||
self.add_argument( | ||
"--file", | ||
help="A coverage.py coverage file to report", | ||
default="./.coverage" | ||
) | ||
|
||
self.add_argument("--token", help="Code Climate repo token") | ||
self.add_argument("--stdout", help="Output to STDOUT", action="store_true") | ||
self.add_argument("--debug", help="Enable debug mode", action="store_true") | ||
self.add_argument("--version", help="Show the version", action="store_true") |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be nice if this script created a git tag as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made that change π