Skip to content

Commit 56d5a2c

Browse files
authored
doc: Contributing.md (#277)
* doc: Contributing.md * fix: Revert change to scope.py * fix: Rename AWS credential envvars to avoid collisions
1 parent d25fba8 commit 56d5a2c

File tree

6 files changed

+86
-35
lines changed

6 files changed

+86
-35
lines changed

CONTRIBUTING.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# How to contribute to the Sentry Python SDK
2+
3+
`sentry-sdk` is an ordinary Python package. You can install it with `pip
4+
install -e .` into some virtualenv, edit the sourcecode and test out your
5+
changes manually.
6+
7+
## Running tests and linters
8+
9+
Make sure you have `virtualenv` installed, and the Python versions you care
10+
about. You should have at least one version of Python 2 and Python 3 installed.
11+
12+
You don't need to `workon` or `activate` anything, the `Makefile` will create
13+
one for you.
14+
15+
* Running basic tests without integrations: `make test` (Python 2.7 and 3.7)
16+
* Running all tests: `make test-all`
17+
18+
This really runs all tests, for all integrations, for all version
19+
combinations we care about. This is the closest you can get to the CI build,
20+
provided you have all relevant Python versions installed.
21+
22+
* Running linting: `make check` or `make lint`
23+
* Running autoformatting: `make format`
24+
25+
## Releasing a new version
26+
27+
We use [craft](https://github.com/getsentry/craft#python-package-index-pypi) to
28+
release new versions. You need credentials for the `getsentry` PyPI user, and
29+
must have `twine` installed globally.
30+
31+
The usual release process goes like this:
32+
33+
1. Go through git log and write new entry into `CHANGELOG.md`, commit to master
34+
2. `craft p a.b.c`
35+
3. `craft pp a.b.c`

Makefile

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,59 @@
11
SHELL = /bin/bash
22

3-
dist:
3+
VENV_PATH = .venv
4+
5+
.venv:
6+
virtualenv $(VENV_PATH)
7+
$(VENV_PATH)/bin/pip install tox
8+
9+
dist: .venv
410
rm -rf dist build
5-
python setup.py sdist bdist_wheel
11+
$(VENV_PATH)/bin/python setup.py sdist bdist_wheel
612

713
.PHONY: dist
814

9-
.venv:
10-
@virtualenv .venv
15+
format: .venv
16+
$(VENV_PATH)/bin/tox -e linters --notest
17+
.tox/linters/bin/black .
18+
.PHONY: format
1119

1220
test: .venv
13-
@pip install -r test-requirements.txt
14-
@pip install --editable .
15-
@pytest tests
21+
@$(VENV_PATH)/bin/tox -e py2.7,py3.7
1622
.PHONY: test
1723

18-
format:
19-
@black sentry_sdk tests
20-
.PHONY: format
24+
test-all: .venv
25+
@TOXPATH=$(VENV_PATH)/bin/tox sh ./scripts/runtox.sh
26+
.PHONY: test-all
27+
28+
check: lint
29+
.PHONY: check
2130

22-
tox-test:
23-
@sh ./scripts/runtox.sh
24-
.PHONY: tox-test
31+
lint: .venv
32+
@set -e && $(VENV_PATH)/bin/tox -e linters || ( \
33+
echo "================================"; \
34+
echo "Bad formatting? Run: make format"; \
35+
echo "================================"; \
36+
false)
2537

26-
lint:
27-
@tox -e linters
2838
.PHONY: lint
2939

30-
apidocs:
31-
@pip install pdoc==0.3.2 pygments
32-
@pdoc --overwrite --html --html-dir build/apidocs sentry_sdk
40+
apidocs: .venv
41+
@$(VENV_PATH)/bin/pip install --editable .
42+
@$(VENV_PATH)/bin/pip install pdoc==0.3.2 pygments
43+
@$(VENV_PATH)/bin/pdoc --overwrite --html --html-dir build/apidocs sentry_sdk
3344
.PHONY: apidocs
3445

3546
install-zeus-cli:
3647
npm install -g @zeus-ci/cli
3748
.PHONY: install-zeus-cli
3849

39-
travis-upload-docs:
40-
@pip install --editable .
41-
$(MAKE) apidocs
50+
travis-upload-docs: apidocs install-zeus-cli
4251
cd build/apidocs && zip -r gh-pages ./sentry_sdk
43-
$(MAKE) install-zeus-cli
4452
zeus upload -t "application/zip+docs" build/apidocs/gh-pages.zip \
4553
|| [[ ! "$(TRAVIS_BRANCH)" =~ ^release/ ]]
4654
.PHONY: travis-upload-docs
4755

48-
travis-upload-dist: dist
49-
$(MAKE) install-zeus-cli
56+
travis-upload-dist: dist install-zeus-cli
5057
zeus upload -t "application/zip+wheel" dist/* \
5158
|| [[ ! "$(TRAVIS_BRANCH)" =~ ^release/ ]]
5259
.PHONY: travis-upload-dist

scripts/aws-cleanup.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#!/bin/sh
22
# Delete all AWS Lambda functions
3-
for func in $(aws lambda list-functions | jq .Functions[].FunctionName); do
3+
4+
export AWS_ACCESS_KEY_ID="$SENTRY_PYTHON_TEST_AWS_ACCESS_KEY_ID"
5+
export AWS_SECRET_ACCESS_KEY="$SENTRY_PYTHON_TEST_AWS_SECRET_ACCESS_KEY"
6+
export AWS_IAM_ROLE="$SENTRY_PYTHON_TEST_AWS_IAM_ROLE"
7+
8+
for func in $(aws lambda list-functions | jq -r .Functions[].FunctionName); do
49
echo "Deleting $func"
510
aws lambda delete-function --function-name $func
611
done

scripts/runtox.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
#!/bin/bash
2-
set -xe
2+
set -e
3+
4+
if [ -z "$TOXPATH" ]; then
5+
TOXPATH=tox
6+
fi
37

48
# Usage: sh scripts/runtox.sh py3.7 <pytest-args>
59
# Runs all environments with substring py3.7 and the given arguments for pytest
610

7-
if [ -z "$1" ]; then
11+
if [ -z "$1" ] && [ -n "$TRAVIS_PYTHON_VERSION" ]; then
812
searchstring="$(echo py$TRAVIS_PYTHON_VERSION | sed -e 's/pypypy/pypy/g' -e 's/-dev//g')"
913
else
1014
searchstring="$1"
1115
fi
1216

13-
exec tox -p auto -e $(tox -l | grep $searchstring | tr '\n' ',') -- "${@:2}"
17+
exec $TOXPATH -p auto -e $(tox -l | grep "$searchstring" | tr '\n' ',') -- "${@:2}"

tests/integrations/aws_lambda/test_aws.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ def init_sdk(**extra_init_args):
4747

4848
@pytest.fixture
4949
def lambda_client():
50-
if "AWS_ACCESS_KEY_ID" not in os.environ:
50+
if "SENTRY_PYTHON_TEST_AWS_ACCESS_KEY_ID" not in os.environ:
5151
pytest.skip("AWS environ vars not set")
5252

5353
return boto3.client(
5454
"lambda",
55-
aws_access_key_id=os.environ["AWS_ACCESS_KEY_ID"],
56-
aws_secret_access_key=os.environ["AWS_SECRET_ACCESS_KEY"],
55+
aws_access_key_id=os.environ["SENTRY_PYTHON_TEST_AWS_ACCESS_KEY_ID"],
56+
aws_secret_access_key=os.environ["SENTRY_PYTHON_TEST_AWS_SECRET_ACCESS_KEY"],
5757
region_name="us-east-1",
5858
)
5959

@@ -84,7 +84,7 @@ def inner(code, payload):
8484
lambda_client.create_function(
8585
FunctionName=fn_name,
8686
Runtime=runtime,
87-
Role=os.environ["AWS_IAM_ROLE"],
87+
Role=os.environ["SENTRY_PYTHON_TEST_AWS_IAM_ROLE"],
8888
Handler="test_lambda.test_handler",
8989
Code={"ZipFile": tmpdir.join("ball.zip").read(mode="rb")},
9090
Description="Created as part of testsuite for getsentry/sentry-python",

tox.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ setenv =
122122

123123
COVERAGE_FILE=.coverage-{envname}
124124
passenv =
125-
AWS_ACCESS_KEY_ID
126-
AWS_SECRET_ACCESS_KEY
127-
AWS_IAM_ROLE
125+
SENTRY_PYTHON_TEST_AWS_ACCESS_KEY_ID
126+
SENTRY_PYTHON_TEST_AWS_SECRET_ACCESS_KEY
127+
SENTRY_PYTHON_TEST_AWS_IAM_ROLE
128128
usedevelop = True
129129
extras =
130130
flask: flask

0 commit comments

Comments
 (0)