Skip to content

Commit 808dee6

Browse files
authored
Merge pull request #16 from EasyPost/cleanup
chore: cleanup docs and CI
2 parents 4edff18 + 0e59edb commit 808dee6

File tree

11 files changed

+416
-326
lines changed

11 files changed

+416
-326
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,40 @@ name: 'CI'
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [master]
66
pull_request:
77

88
jobs:
99
flake8:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v2
12+
- uses: actions/checkout@v3
1313
- name: set up python
14-
uses: actions/setup-python@v2
14+
uses: actions/setup-python@v4
1515
with:
16-
python-version: 3.9
16+
python-version: '3.12'
1717
- name: install dependencies
18-
run: python -m pip install flake8
18+
run: make install
1919
- name: lint with flake8
20-
run: flake8 --statistics shentry.py
20+
run: make lint
2121
run-tests:
2222
runs-on: ubuntu-latest
2323
strategy:
2424
matrix:
25-
pythonversion: ['2.7', '3.5', '3.6', '3.7', '3.8', '3.9']
25+
pythonversion: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
2626
steps:
27-
- uses: actions/checkout@v2
27+
- uses: actions/checkout@v3
2828
- name: set up python
29-
uses: actions/setup-python@v2
29+
uses: actions/setup-python@v4
3030
with:
3131
python-version: ${{ matrix.pythonversion }}
3232
- name: install dependencies
33-
run: "python -m pip install -r requirements-tests.txt -e ."
33+
run: make install
3434
- name: test with pytest
35-
run: py.test --cov-fail-under=50 --cov=shentry --cov-report=term-missing tests/
35+
run: make coverage
36+
- name: Coveralls
37+
if: github.ref == 'refs/heads/master'
38+
uses: coverallsapp/github-action@master
39+
with:
40+
github-token: ${{ secrets.GITHUB_TOKEN }}
41+
path-to-lcov: './coverage.lcov'

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ test-*.xml
88
venv/
99
env/
1010
.coverage
11+
__pycache__
12+
*.lcov

.travis.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

CHANGES.md renamed to CHANGELOG.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
1-
0.4.0
2-
-----
1+
# CHANGELOG
2+
3+
## v1.0.0 FUTURE
4+
5+
- Drops support for Python earlier than 3.7
6+
- Adds support for Python 3.10-3.12
7+
- Overhauls dev tooling
8+
9+
## v0.4.0
10+
311
- pass through SIGTERM, SIGQUIT, and SIGINT to the child process
412
- do not send empty tags to Sentry
513
- (internal) switch tests from circleci to travisci
614

7-
0.3.2
8-
-----
15+
## v0.3.2
16+
917
- Move `level`, `server_name` and `sdk` from `tags` to top-level
1018
- Add Python 3.6 to tox tests
1119

12-
0.3.1
13-
-----
20+
## v0.3.1
21+
1422
- Fix bug with loading large command outputs
1523
- Add more tests
1624

17-
0.3.0
18-
-----
25+
## v0.3.0
26+
1927
- Add support for using `requests` if it's importable
2028
- Add support for outbound proxies via `$SHELL_SENTRY_PROXY` or `/etc/shentry_proxy`

Makefile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
PYTHON_BINARY := python3
2+
VIRTUAL_ENV := venv
3+
VIRTUAL_BIN := $(VIRTUAL_ENV)/bin
4+
PROJECT_NAME := shentry
5+
TEST_DIR := tests
6+
7+
## help - Display help about make targets for this Makefile
8+
help:
9+
@cat Makefile | grep '^## ' --color=never | cut -c4- | sed -e "`printf 's/ - /\t- /;'`" | column -s "`printf '\t'`" -t
10+
11+
## clean - Clean the project
12+
clean:
13+
rm -rf $(VIRTUAL_ENV) dist/ *.egg-info/ .*cache htmlcov *.lcov .coverage
14+
find . -name '*.pyc' -delete
15+
16+
## coverage - Test the project and generate an HTML coverage report
17+
coverage:
18+
$(VIRTUAL_BIN)/pytest --cov=$(PROJECT_NAME) --cov-branch --cov-report=html --cov-report=lcov --cov-report=term-missing --cov-fail-under=50
19+
20+
## flake8 - Lint the project with flake8
21+
flake8:
22+
$(VIRTUAL_BIN)/flake8 $(PROJECT_NAME).py $(TEST_DIR)/
23+
24+
## install - Install the project locally
25+
install:
26+
$(PYTHON_BINARY) -m venv $(VIRTUAL_ENV)
27+
$(VIRTUAL_BIN)/pip install -r requirements-tests.txt -e .
28+
29+
## lint - Run linters on the project
30+
lint: flake8
31+
32+
## publish - Publish the project to PyPI
33+
publish:
34+
$(VIRTUAL_BIN)/twine upload dist/*
35+
36+
## test - Test the project
37+
test:
38+
$(VIRTUAL_BIN)/pytest
39+
40+
.PHONY: help clean coverage flake8 install lint publish test

README.md

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,16 @@
1+
# Shentry
2+
3+
[![Build Status](https://travis-ci.com/EasyPost/shentry.svg?branch=master)](https://travis-ci.com/EasyPost/shentry)
4+
[![Coverage Status](https://coveralls.io/repos/github/EasyPost/shentry/badge.svg)](https://coveralls.io/github/EasyPost/shentry)
5+
[![Version](https://img.shields.io/github/v/tag/EasyPost/shentry)](https://github.com/EasyPost/shentry/releases)
6+
17
**Shentry** is a single-file Python script which will run the wrapped
28
command and, if it fails, post an event to Sentry. By default, if the
39
wrapped script succeeds (exists with code 0), stdout/stderr are squashed,
410
similarly to [shuck](https://github.com/thwarted/shuck) or
511
[chronic](https://joeyh.name/code/moreutils/). It also always exits with
612
status 0 if events are able to be sent to Sentry.
713

8-
It reads its configuration from the environment variable `$SHELL_SENTRY_DSN`
9-
and, if such a variable is found, removes it from the environment before
10-
calling the wrapped program. If that environment variable is not present, shentry will look
11-
for `$SENTRY_DSN` (and similarly remove it from the environment).
12-
If you need to use SENTRY_DSN inside your project code, make sure to set both.
13-
You may also in that case want to put a top-level try/except around your whole
14-
program to prevent uncaught exceptions from trigging both your in-process sentry sdk
15-
and also your extra-process shentry, since you very likely only want one or the other.
16-
If neither of the environment variables are present or both
17-
are empty, shentry will try to read a DSN from `/etc/shentry_dsn`. If no DSN
18-
can be found, the wrapped will have normal behavior (stdout/stderr will go
19-
to their normal file descriptors, exit code will be passed through, etc).
20-
21-
This software should be compatible with Python 2.6, 2.7, and 3.5+;
22-
that is to say, you should be able to run it just about anywhere.
23-
24-
[![Build Status](https://travis-ci.com/EasyPost/shentry.svg?branch=master)](https://travis-ci.com/EasyPost/shentry)
25-
26-
2714
## Installation
2815

2916
Put the file [`shentry.py`](shentry.py) anywhere in your `$PATH` under the
@@ -34,27 +21,46 @@ If the `requests` library is available, it will be used; otherwise, the standard
3421
either `$SHELL_SENTRY_PROXY` or the contents of `/etc/shentry_proxy` can be
3522
used to configure an outbound proxy.
3623

37-
The `setup.py` in this directory only exists for `tox` to work (and run unit
38-
tests). Don't bother using it; just copy `shentry.py` wherever you want it.
24+
The `setup.py` in this directory only exists for this project's dev tooling. To get
25+
Shentry working on your machine, simply copy `shentry.py` wherever you need it.
3926

4027
## Usage
4128

4229
You might want a crontab that looks something like the following:
4330

44-
SHELL_SENTRY_DSN=https://pub:priv@app.getsentry.com/id
31+
```sh
32+
SHELL_SENTRY_DSN=https://pub:priv@app.getsentry.com/id
4533

46-
15 * * * * /usr/local/bin/shentry /usr/local/bin/run-periodic-scripts
34+
15 * * * * /usr/local/bin/shentry /usr/local/bin/run-periodic-scripts
35+
```
4736

4837
You can also make shentry your `$SHELL` and wrap all commands in it:
4938

50-
SHELL_SENTRY_DSN=https://pub:priv@app.getsentry.com/id
51-
SHELL=/usr/local/bin/shentry
39+
```sh
40+
SHELL_SENTRY_DSN=https://pub:priv@app.getsentry.com/id
41+
SHELL=/usr/local/bin/shentry
5242

53-
15 * * * * /usr/local/bin/run-periodic-scripts
54-
7 1 * * * /usr/local/bin/run-daily-scripts
43+
15 * * * * /usr/local/bin/run-periodic-scripts
44+
7 1 * * * /usr/local/bin/run-daily-scripts
45+
```
5546

5647
In this case, it will run the wrapped commands through `/bin/sh` (otherwise, it will honor `$SHELL`).
5748

49+
### Environment Variables
50+
51+
Shentry reads its configuration from the environment variable `$SHELL_SENTRY_DSN`
52+
and, if such a variable is found, removes it from the environment before
53+
calling the wrapped program. If that environment variable is not present, shentry will look
54+
for `$SENTRY_DSN` (and similarly remove it from the environment).
55+
If you need to use `SENTRY_DSN` inside your project code, make sure to set both.
56+
You may also in that case want to put a top-level try/except around your whole
57+
program to prevent uncaught exceptions from trigging both your in-process sentry sdk
58+
and also your extra-process shentry, since you very likely only want one or the other.
59+
If neither of the environment variables are present or both
60+
are empty, shentry will try to read a DSN from `/etc/shentry_dsn`. If no DSN
61+
can be found, the wrapped will have normal behavior (stdout/stderr will go
62+
to their normal file descriptors, exit code will be passed through, etc).
63+
5864
## License
5965

6066
This software is licensed under the ISC License, the full text of which can be found at [LICENSE.txt](LICENSE.txt).

requirements-tests.txt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# pytest can't go above 3.2 because we need python 2.6 compat
2-
pytest==3.2.*
3-
# pytest 2.6 also breaks python 2.6 compatibility
4-
pytest-cov==2.5.*
5-
mock==2.0.0
6-
pytest-mock==1.*
7-
flake8==3.*
1+
flake8==5.* # TODO: flake8 v6 requires Python 3.8.1+
2+
pytest-cov==4.*
3+
pytest-mock==3.*
4+
pytest==7.*

setup.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,30 @@
22

33
from setuptools import setup
44

5-
65
setup(
76
name="shentry",
8-
version="0.4.0",
7+
version="1.0.0",
98
author="EasyPost",
109
author_email="oss@easypost.com",
1110
url="https://github.com/easypost/shentry",
1211
license="ISC",
1312
packages=[],
14-
scripts=['shentry.py'],
13+
scripts=["shentry.py"],
1514
keywords=["logging"],
1615
description="Wrap a program in sentry!",
17-
python_requires='>=2.6, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4',
16+
python_requires=">=3.7, <4",
1817
classifiers=[
1918
"Development Status :: 3 - Alpha",
2019
"Environment :: Console",
2120
"Programming Language :: Python",
22-
"Programming Language :: Python :: 2.6",
23-
"Programming Language :: Python :: 2.7",
24-
"Programming Language :: Python :: 3.5",
25-
"Programming Language :: Python :: 3.6",
2621
"Programming Language :: Python :: 3.7",
2722
"Programming Language :: Python :: 3.8",
23+
"Programming Language :: Python :: 3.9",
24+
"Programming Language :: Python :: 3.10",
25+
"Programming Language :: Python :: 3.11",
26+
"Programming Language :: Python :: 3.12",
2827
"Operating System :: POSIX",
2928
"Intended Audience :: Developers",
3029
"License :: OSI Approved :: ISC License (ISCL)",
31-
]
30+
],
3231
)

0 commit comments

Comments
 (0)