Skip to content

Commit

Permalink
feat: Implement basics of pre-commit
Browse files Browse the repository at this point in the history
- Add pre-commit framework
- Implement a number of reasonable defaults and exclusions
- Move CI generated artifacts into .artifacts/
- Run pre-commit over entirety of codebase (and apply various fixes)
- Remove dead runtests.js
  • Loading branch information
dcramer committed Jul 2, 2018
1 parent f596267 commit d348dc4
Show file tree
Hide file tree
Showing 50 changed files with 478 additions and 450 deletions.
1 change: 1 addition & 0 deletions .artifacts/README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This folder captures artifacts generated from .pre-commit, such as lint violations. It is primarily used for continuous integration services.
2 changes: 0 additions & 2 deletions .coveragerc

This file was deleted.

1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
**/tests/sentry/lang/javascript/example-project/**/*
/examples/
/scripts/
/src/debug_toolbar/static/debug_toolbar/js/toolbar.js
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ test.conf
pip-log.txt
celerybeat-schedule
sentry-package.json
/.artifacts
/coverage/
/cover
/build
Expand Down
41 changes: 41 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
exclude: >
(?x)(
LICENSE$|
\.snap$|
\.map$|
\.map\.js$|
^tests/sentry/lang/.*/fixtures/|
^tests/fixtures/|
^src/sentry/static/sentry/vendor/|
^tests/sentry/lang/javascript/example-project/|
^src/.*/locale/|
^src/sentry/data/
)
repos:
# - repo: https://github.com/ambv/black
# rev: 18.6b2
# hooks:
# - id: black
# python_version: python3.6
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v1.3.0
hooks:
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-symlinks
- id: end-of-file-fixer
exclude_types: [svg]
- id: trailing-whitespace
exclude_types: [svg]
- id: debug-statements
# - id: flake8
# log_file: '.artifacts/flake8.pycodestyle.log'
- id: requirements-txt-fixer
# - repo: git://github.com/getsentry/pre-commit-hooks
# rev: f3237d2d65af81d435c49dee3593dc8f03d23c2d
# hooks:
# - id: prettier
# - id: eslint
# args: ['--format=checkstyle']
# log_file: '.artifacts/eslint.checkstyle.xml'
20 changes: 17 additions & 3 deletions .storybook/storybook.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
html > body {
background-color: rgba(0, 0, 0, 0.05);
background-image: repeating-linear-gradient(0deg, transparent, transparent 7px, rgba(0, 0, 0, 0.1) 1px, transparent 8px), repeating-linear-gradient(90deg, transparent, transparent 7px, rgba(0, 0, 0, 0.1) 1px, transparent 8px);
background-image: repeating-linear-gradient(
0deg,
transparent,
transparent 7px,
rgba(0, 0, 0, 0.1) 1px,
transparent 8px
),
repeating-linear-gradient(
90deg,
transparent,
transparent 7px,
rgba(0, 0, 0, 0.1) 1px,
transparent 8px
);
background-size: 8px 8px;
}

Expand All @@ -9,7 +22,8 @@ html {
font-size: 14px;
}

*, *:before, *:after {
*,
*:before,
*:after {
box-sizing: inherit;
}

15 changes: 7 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,13 @@ after_failure:
- dmesg | tail -n 100

after_script:
- zeus upload -t "text/xml+xunit" junit.xml
-t "text/xml+xunit" jest.junit.xml
-t "text/xml+coverage" coverage.xml
-t "text/xml+coverage" coverage/cobertura-coverage.xml
-t "text/html+pytest" pytest.html
-t "text/plain+pycodestyle" flake8.pycodestyle.log
-t "text/xml+checkstyle" eslint.checkstyle.xml
-t "application/webpack-stats+json" webpack-stats.json
- zeus upload -t "text/xml+xunit" .artifacts/*.junit.xml
-t "text/xml+coverage" .artifacts/*.coverage.xml
-t "text/xml+coverage" .artifacts/coverage/cobertura-coverage.xml
-t "text/html+pytest" .artifacts/*.pytest.html
-t "text/plain+pycodestyle" .artifacts/*.pycodestyle.log
-t "text/xml+checkstyle" .artifacts/*.checkstyle.xml
-t "application/webpack-stats+json" .artifacts/webpack-stats.json

# each job in the matrix inherits `env/global` and uses everything above,
# but custom `services`, `before_install`, `install`, and `before_script` directives
Expand Down
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ clean:

setup-git:
@echo "--> Installing git hooks"
pip install "pre-commit>=1.10.1,<1.11.0"
pre-commit install
git config branch.autosetuprebase always
cd .git/hooks && ln -sf ../../config/hooks/* ./
@echo ""
Expand Down Expand Up @@ -106,7 +108,7 @@ test-cli:

test-js: node-version-check
@echo "--> Building static assets"
@$(WEBPACK) --profile --json > webpack-stats.json
@$(WEBPACK) --profile --json > .artifacts/webpack-stats.json
@echo "--> Running JavaScript tests"
@npm run test-ci
@echo ""
Expand All @@ -119,26 +121,26 @@ test-styleguide:

test-python: build-platform-assets
@echo "--> Running Python tests"
py.test tests/integration tests/sentry --cov . --cov-report="xml:coverage.xml" --junit-xml="junit.xml" || exit 1
py.test tests/integration tests/sentry --cov . --cov-report="xml:.artifacts/python.coverage.xml" --junit-xml=".artifacts/python.junit.xml" || exit 1
@echo ""

test-snuba:
@echo "--> Running snuba tests"
py.test tests/snuba -vv --cov . --cov-report="xml:coverage.xml" --junit-xml="junit.xml"
py.test tests/snuba -vv --cov . --cov-report="xml:.artifacts/snuba.coverage.xml" --junit-xml=".artifacts/snuba.junit.xml"
@echo ""

test-acceptance: build-platform-assets node-version-check
@echo "--> Building static assets"
@$(WEBPACK) --display errors-only
@echo "--> Running acceptance tests"
py.test tests/acceptance --cov . --cov-report="xml:coverage.xml" --junit-xml="junit.xml" --html="pytest.html"
py.test tests/acceptance --cov . --cov-report="xml:.artifacts/acceptance.coverage.xml" --junit-xml=".artifacts/acceptance.junit.xml" --html=".artifacts/acceptance.pytest.html"
@echo ""

lint: lint-python lint-js

lint-python:
@echo "--> Linting python"
bash -eo pipefail -c "bin/lint --python --parseable | tee flake8.pycodestyle.log"
bash -eo pipefail -c "bin/lint --python --parseable | tee .artifacts/flake8.pycodestyle.log"
@echo ""

lint-js:
Expand Down
4 changes: 2 additions & 2 deletions doc-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
docutils>=0.7
Jinja2>=2.3
markupsafe
Pygments>=1.2
Sphinx>=1.3
docutils>=0.7
markupsafe
2 changes: 1 addition & 1 deletion docs/_themes/kr/static/small_flask.css
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ div.body {

.github {
display: none;
}
}
2 changes: 1 addition & 1 deletion docs/_themes/kr/theme.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ stylesheet = flasky.css
pygments_style = flask_theme_support.FlaskyStyle

[options]
touch_icon =
touch_icon =
1 change: 0 additions & 1 deletion docs/cli/config/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ Subcommands
discover <discover/index>
generate-secret-key <generate-secret-key/index>
delete <delete/index>

1 change: 0 additions & 1 deletion docs/cli/files/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ Subcommands

info <info/index>
get <get/index>

2 changes: 1 addition & 1 deletion docs/cli/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ configuration via the ``SENTRY_CONF`` environment variable::
For a list of commands, you can also use ``sentry help``, or ``sentry
[command] --help`` for help on a specific command.

.. include:: index.rst.inc
.. include:: index.rst.inc
1 change: 0 additions & 1 deletion docs/cli/index.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ Subcommands
shell <shell/index>
config <config/index>
tsdb <tsdb/index>

1 change: 0 additions & 1 deletion docs/cli/plugins/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ Subcommands
:maxdepth: 1

list <list/index>

1 change: 0 additions & 1 deletion docs/cli/queues/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ Subcommands

purge <purge/index>
list <list/index>

1 change: 0 additions & 1 deletion docs/cli/run/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ Subcommands
web <web/index>
cron <cron/index>
smtp <smtp/index>

1 change: 0 additions & 1 deletion docs/cli/tsdb/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ Subcommands
:maxdepth: 1

query <query/index>

1 change: 0 additions & 1 deletion docs/cli/tsdb/query/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ Subcommands
:maxdepth: 1

organizations <organizations/index>

1 change: 0 additions & 1 deletion docs/tsdb.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ different cluster, provide the ``cluster`` option, as such:
SENTRY_TSDB_OPTIONS = {
'cluster': 'tsdb',
}
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
"lcov",
"cobertura"
],
"coverageDirectory": ".artifacts/coverage/",
"snapshotSerializers": [
"enzyme-to-json/serializer"
],
Expand Down Expand Up @@ -142,6 +143,9 @@
"<rootDir>/node_modules/reflux"
]
},
"jest-junit": {
"output": ".artifacts/jest.junit.xml"
},
"devDependencies": {
"@percy-io/percy-storybook": "^1.3.3",
"@storybook/addon-actions": "^3.2.17",
Expand Down
34 changes: 17 additions & 17 deletions requirements-base.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
BeautifulSoup>=3.2.1
botocore<1.5.71
boto3>=1.4.1,<1.4.6
botocore<1.5.71
celery>=3.1.8,<3.1.19
click>=5.0,<7.0
# 'cryptography>=1.3,<1.4
cssutils>=0.9.9,<0.10.0
Django>=1.6.11,<1.7
django-crispy-forms>=1.4.0,<1.5.0
django-jsonfield>=0.9.13,<0.9.14
django-picklefield>=0.3.0,<0.4.0
django-sudo>=2.1.0,<3.0.0
django-templatetag-sugar>=0.1.0
Django>=1.6.11,<1.7
djangorestframework>=2.4.8,<2.5.0
email-reply-parser>=0.2.0,<0.3.0
enum34>=1.1.6,<1.2.0
Expand All @@ -20,13 +20,16 @@ futures>=3.2.0,<4.0.0
# broken on python3
hiredis>=0.1.0,<0.2.0
honcho>=1.0.0,<1.1.0
kombu==3.0.35
ipaddress>=1.0.16,<1.1.0
loremipsum>=1.0.5,<1.1.0
jsonschema==2.6.0
jsonschema==2.6.0
kombu==3.0.35
loremipsum>=1.0.5,<1.1.0
lxml>=3.4.1
mock==2.0.0
# for vsts repo
mistune>0.7,<0.9
mmh3>=2.3.1,<2.4
mock==2.0.0
oauth2>=1.5.167
parsimonious==0.8.0
percy>=1.1.2
Expand All @@ -35,37 +38,34 @@ Pillow>=3.2.0,<=4.2.1
progressbar2>=3.10,<3.11
psycopg2>=2.6.0,<2.8.0
PyJWT>=1.5.0,<1.6.0
pytest>=3.5.0,<3.6.0
pytest-django>=2.9.1,<2.10.0
pytest-html>=1.9.0,<1.10.0
pytest>=3.5.0,<3.6.0
python-dateutil>=2.0.0,<3.0.0
python-memcached>=1.53,<2.0.0
python-openid>=2.2
python-u2flib-server>=4.0.1,<4.1.0
PyYAML>=3.11,<3.12
qrcode>=5.2.2,<6.0.0
querystring_parser>=1.2.3,<2.0.0
raven>=6.0.0,<=6.4.0
rb>=1.7.0,<2.0.0
redis-py-cluster>=1.3.4,<1.4.0
redis>=2.10.3,<2.10.6
requests[security]>=2.18.4,<2.19.0
selenium==3.11.0
semaphore>=0.1.0,<0.2.0
setproctitle>=1.1.7,<1.2.0
simplejson>=3.2.0,<3.9.0
six>=1.10.0,<1.11.0
setproctitle>=1.1.7,<1.2.0
sqlparse>=0.1.16,<0.2.0
statsd>=3.1.0,<3.2.0
strict-rfc3339>=0.7
structlog==16.1.0
sqlparse>=0.1.16,<0.2.0
symbolic>=5.0.0,<6.0.0
toronado>=0.0.11,<0.1.0
ua-parser>=0.6.1,<0.8.0
urllib3>=1.22,<1.23
uwsgi>2.0.0,<2.1.0
rb>=1.7.0,<2.0.0
qrcode>=5.2.2,<6.0.0
python-u2flib-server>=4.0.1,<4.1.0
redis-py-cluster>=1.3.4,<1.4.0
jsonschema==2.6.0
# for bitbucket client
unidiff>=0.5.4
# for vsts repo
mistune>0.7,<0.9
urllib3>=1.22,<1.23
uwsgi>2.0.0,<2.1.0
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
autopep8
Babel
flake8>=2.6,<2.7
pycodestyle>=2.0,<2.1
isort>=4.2.2,<4.3.0
pycodestyle>=2.0,<2.1
Loading

0 comments on commit d348dc4

Please sign in to comment.