Skip to content

Commit 06b078a

Browse files
authored
Adopt tox-dev organization best practices (#87)
1 parent b30bdc4 commit 06b078a

22 files changed

+587
-934
lines changed

.github/workflows/check.yml

+130
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: check
2+
on:
3+
push:
4+
pull_request:
5+
schedule:
6+
- cron: "0 8 * * *"
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions/setup-python@v2
14+
- uses: pre-commit/[email protected]
15+
16+
test:
17+
name: test ${{ matrix.py }} - ${{ matrix.os }}
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
os:
23+
- ubuntu-latest
24+
- windows-latest
25+
- macos-latest
26+
py:
27+
- 3.10.0-rc.2
28+
- 3.9
29+
- 3.8
30+
- 3.7
31+
- 3.6
32+
- 3.5
33+
- pypy3
34+
- 2.7
35+
- pypy2
36+
37+
steps:
38+
- name: Setup python for tox
39+
uses: actions/setup-python@v2
40+
with:
41+
python-version: 3.9
42+
- name: Install tox
43+
run: python -m pip install tox
44+
- uses: actions/checkout@v2
45+
with:
46+
fetch-depth: 0
47+
- name: Setup python for test ${{ matrix.py }}
48+
uses: actions/setup-python@v2
49+
with:
50+
python-version: ${{ matrix.py }}
51+
- name: Pick environment to run
52+
run: |
53+
import platform; import os; import sys; import codecs
54+
cpy = platform.python_implementation() == "CPython"
55+
base =("{}{}{}" if cpy else "{}{}").format("py" if cpy else "pypy", *sys.version_info[0:2])
56+
env = "TOXENV={}\n".format(base)
57+
print("Picked:\n{}for{}".format(env, sys.version))
58+
with codecs.open(os.environ["GITHUB_ENV"], "a", "utf-8") as file_handler:
59+
file_handler.write(env)
60+
shell: python
61+
- name: Setup test suite
62+
run: tox -vv --notest
63+
- name: Run test suite
64+
run: tox --skip-pkg-install
65+
env:
66+
PYTEST_ADDOPTS: "-vv --durations=20"
67+
CI_RUN: "yes"
68+
DIFF_AGAINST: HEAD
69+
- name: Rename coverage report file
70+
run: |
71+
import os; os.rename('.tox/coverage.{}.xml'.format(os.environ['TOXENV']), '.tox/coverage.xml')
72+
shell: python
73+
- uses: codecov/codecov-action@v1
74+
with:
75+
file: ./.tox/coverage.xml
76+
flags: tests
77+
name: ${{ matrix.py }} - ${{ matrix.os }}
78+
79+
check:
80+
name: ${{ matrix.tox_env }} - ${{ matrix.os }}
81+
runs-on: ${{ matrix.os }}
82+
strategy:
83+
fail-fast: false
84+
matrix:
85+
os:
86+
- ubuntu-latest
87+
- windows-latest
88+
tox_env:
89+
- dev
90+
- docs
91+
- readme
92+
exclude:
93+
- { os: windows-latest, tox_env: readme }
94+
steps:
95+
- uses: actions/checkout@v2
96+
with:
97+
fetch-depth: 0
98+
- name: Setup Python 3.9
99+
uses: actions/setup-python@v2
100+
with:
101+
python-version: 3.9
102+
- name: Install tox
103+
run: python -m pip install tox
104+
- name: Setup test suite
105+
run: tox -vv --notest -e ${{ matrix.tox_env }}
106+
- name: Run test suite
107+
run: tox --skip-pkg-install -e ${{ matrix.tox_env }}
108+
109+
publish:
110+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
111+
needs: [check, test, lint]
112+
runs-on: ubuntu-latest
113+
steps:
114+
- name: Setup python to build package
115+
uses: actions/setup-python@v2
116+
with:
117+
python-version: 3.9
118+
- name: Install https://pypi.org/project/build
119+
run: python -m pip install build
120+
- uses: actions/checkout@v2
121+
with:
122+
fetch-depth: 0
123+
- name: Build sdist and wheel
124+
run: python -m build -s -w . -o dist
125+
- name: Publish to PyPi
126+
uses: pypa/gh-action-pypi-publish@master
127+
with:
128+
skip_existing: true
129+
user: __token__
130+
password: ${{ secrets.pypi_password }}

.gitignore

+14-41
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,18 @@
1-
*.py[cod]
2-
3-
# C extensions
4-
*.so
5-
6-
# Packages
7-
*.egg
81
*.egg-info
9-
dist
102
build
11-
eggs
12-
parts
13-
bin
14-
var
15-
sdist
16-
develop-eggs
17-
.installed.cfg
18-
lib
19-
lib64
20-
*__pycache__
21-
MANIFEST
22-
23-
# Installer logs
24-
pip-log.txt
25-
26-
# Unit test / coverage reports
27-
.coverage
3+
dist
4+
*.egg
5+
.eggs
6+
*.py[codz]
7+
*$py.class
288
.tox
29-
nosetests.xml
30-
31-
# Translations
32-
*.mo
33-
34-
# Mr Developer
35-
.mr.developer.cfg
36-
.project
37-
.pydevproject
38-
39-
# py-filelock
40-
# -----------
41-
42-
# Docs
43-
docs/build
44-
9+
.*_cache
10+
.DS_Store
11+
.idea
12+
.vscode
13+
/pip-wheel-metadata
14+
/src/filelock/version.py
15+
venv*
16+
.python-version
4517
test.lock
18+
test.softlock

.pre-commit-config.yaml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.0.1
4+
hooks:
5+
- id: check-ast
6+
- id: check-builtin-literals
7+
- id: check-docstring-first
8+
- id: check-merge-conflict
9+
- id: check-yaml
10+
- id: check-toml
11+
- id: debug-statements
12+
- id: end-of-file-fixer
13+
- id: trailing-whitespace
14+
- repo: https://github.com/asottile/pyupgrade
15+
rev: v2.26.0
16+
hooks:
17+
- id: pyupgrade
18+
- repo: https://github.com/PyCQA/isort
19+
rev: 5.9.3
20+
hooks:
21+
- id: isort
22+
- repo: https://github.com/psf/black
23+
rev: 21.9b0
24+
hooks:
25+
- id: black
26+
args: [ --safe ]
27+
- repo: https://github.com/asottile/blacken-docs
28+
rev: v1.11.0
29+
hooks:
30+
- id: blacken-docs
31+
additional_dependencies: [ black==20.8b1 ]
32+
- repo: https://github.com/pre-commit/pygrep-hooks
33+
rev: v1.9.0
34+
hooks:
35+
- id: rst-backticks
36+
- repo: https://github.com/tox-dev/tox-ini-fmt
37+
rev: "0.5.1"
38+
hooks:
39+
- id: tox-ini-fmt
40+
args: [ "-p", "fix_lint" ]
41+
- repo: https://github.com/asottile/setup-cfg-fmt
42+
rev: v1.17.0
43+
hooks:
44+
- id: setup-cfg-fmt
45+
args: [ --min-py3-version, "3.5", "--max-py-version", "3.10" ]
46+
- repo: https://github.com/PyCQA/flake8
47+
rev: 3.9.2
48+
hooks:
49+
- id: flake8
50+
additional_dependencies:
51+
- flake8-bugbear==21.9.1
52+
- flake8-comprehensions==3.6.1
53+
- flake8-pytest-style==1.5
54+
- flake8-spellcheck==0.24
55+
- flake8-unused-arguments==0.0.6
56+
- flake8-noqa==1.1.0
57+
- flake8-eradicate==1.1.0
58+
- pep8-naming==0.12.1

.travis.yml

-23
This file was deleted.

MANIFEST.in

-3
This file was deleted.

README.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
# py-filelock
22

3-
![travis-ci](https://travis-ci.org/benediktschmitt/py-filelock.svg?branch=master)
4-
53
This package contains a single module, which implements a platform independent
64
file lock in Python, which provides a simple way of inter-process communication:
75

86
```Python
9-
from filelock import Timeout, FileLock
7+
from src.filelock import Timeout, FileLock
108

119
lock = FileLock("high_ground.txt.lock")
1210
with lock:
13-
open("high_ground.txt", "a").write("You were the chosen one.")
11+
open("high_ground.txt", "a").write("You were the chosen one.")
1412
```
1513

1614
**Don't use** a *FileLock* to lock the file you want to write to, instead create
@@ -50,7 +48,7 @@ resource or working
5048
directory is currently used. To do so, create a *FileLock* first:
5149

5250
```Python
53-
from filelock import Timeout, FileLock
51+
from src.filelock import Timeout, FileLock
5452

5553
file_path = "high_ground.txt"
5654
lock_path = "high_ground.txt.lock"

0 commit comments

Comments
 (0)