forked from pre-commit/pre-commit-hooks
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from rzuckerm/reproducible-builds
feat: Add reproducible builds
- Loading branch information
Showing
6 changed files
with
75 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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,24 @@ | ||
# Developing | ||
|
||
## Installing | ||
|
||
You will need to install `tox` like this: | ||
|
||
``` | ||
python3 -m pip install --user tox | ||
``` | ||
|
||
## Testing | ||
|
||
``` | ||
tox -e pre-commit | ||
tox -e py36 | ||
tox -e py37 | ||
tox -e py38 | ||
``` | ||
|
||
## Update requirements in setup.cfg | ||
|
||
``` | ||
tox -e py36-update-requirements | ||
``` |
This file contains 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
This file contains 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,2 @@ | ||
ruamel.yaml>=0.15 | ||
toml |
This file contains 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
This file contains 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[tox] | ||
envlist = py36,py37,py38,pypy3,pre-commit | ||
envlist = py36,py37,py38,pypy3,pre-commit,py36-update-requirements | ||
|
||
[testenv] | ||
deps = -rrequirements-dev.txt | ||
|
@@ -10,14 +10,19 @@ setenv = | |
GIT_COMMITTER_EMAIL = "[email protected]" | ||
commands = | ||
coverage erase | ||
coverage run -m pytest {posargs:tests} | ||
coverage run --source pre_commit_hooks -m pytest {posargs:tests} | ||
coverage report --fail-under 100 | ||
|
||
[testenv:pre-commit] | ||
skip_install = true | ||
deps = pre-commit | ||
commands = pre-commit run --all-files --show-diff-on-failure | ||
|
||
[testenv:py36-update-requirements] | ||
skip_install = true | ||
deps = -rrequirements.txt | ||
commands = python update_requirements.py | ||
|
||
[pep8] | ||
ignore=E265,E501,W504 | ||
|
||
|
This file contains 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,37 @@ | ||
import os | ||
import subprocess | ||
from configparser import ConfigParser | ||
|
||
print('*** Generate requirements.lock ***') | ||
subprocess.run('pip freeze >requirements.lock', shell=True, check=True) | ||
with open('requirements.lock') as f: | ||
requirements = [ | ||
line for line in f.read().strip().splitlines() | ||
if not line.startswith('pre-commit') | ||
] | ||
print('\n'.join(requirements)) | ||
|
||
os.remove('requirements.lock') | ||
print() | ||
|
||
# Read setup.cfg, replace install_requires value with requirements.lock, and | ||
# write setup.cfg | ||
parser = ConfigParser() | ||
parser.read('setup.cfg') | ||
requirements_str = ''.join(f'\n{requirement}' for requirement in requirements) | ||
parser.set('options', 'install_requires', requirements_str) | ||
with open('setup.cfg', 'w') as f: | ||
parser.write(f) | ||
|
||
# Clean up setup.cfg | ||
with open('setup.cfg') as f: | ||
setup_cfg = [ | ||
line.replace('\t', ' ').rstrip() | ||
for line in f.read().splitlines() | ||
] | ||
|
||
|
||
with open('setup.cfg', 'w') as f: | ||
f.write('\n'.join(setup_cfg)) | ||
|
||
print('setup.cfg has been updated. Please commit this change') |