Skip to content

Commit

Permalink
Adopt tox-dev organization best practices (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborbernat authored Sep 27, 2021
1 parent b30bdc4 commit 06b078a
Show file tree
Hide file tree
Showing 22 changed files with 587 additions and 934 deletions.
130 changes: 130 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
name: check
on:
push:
pull_request:
schedule:
- cron: "0 8 * * *"

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/[email protected]

test:
name: test ${{ matrix.py }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
py:
- 3.10.0-rc.2
- 3.9
- 3.8
- 3.7
- 3.6
- 3.5
- pypy3
- 2.7
- pypy2

steps:
- name: Setup python for tox
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install tox
run: python -m pip install tox
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup python for test ${{ matrix.py }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.py }}
- name: Pick environment to run
run: |
import platform; import os; import sys; import codecs
cpy = platform.python_implementation() == "CPython"
base =("{}{}{}" if cpy else "{}{}").format("py" if cpy else "pypy", *sys.version_info[0:2])
env = "TOXENV={}\n".format(base)
print("Picked:\n{}for{}".format(env, sys.version))
with codecs.open(os.environ["GITHUB_ENV"], "a", "utf-8") as file_handler:
file_handler.write(env)
shell: python
- name: Setup test suite
run: tox -vv --notest
- name: Run test suite
run: tox --skip-pkg-install
env:
PYTEST_ADDOPTS: "-vv --durations=20"
CI_RUN: "yes"
DIFF_AGAINST: HEAD
- name: Rename coverage report file
run: |
import os; os.rename('.tox/coverage.{}.xml'.format(os.environ['TOXENV']), '.tox/coverage.xml')
shell: python
- uses: codecov/codecov-action@v1
with:
file: ./.tox/coverage.xml
flags: tests
name: ${{ matrix.py }} - ${{ matrix.os }}

check:
name: ${{ matrix.tox_env }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
tox_env:
- dev
- docs
- readme
exclude:
- { os: windows-latest, tox_env: readme }
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install tox
run: python -m pip install tox
- name: Setup test suite
run: tox -vv --notest -e ${{ matrix.tox_env }}
- name: Run test suite
run: tox --skip-pkg-install -e ${{ matrix.tox_env }}

publish:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs: [check, test, lint]
runs-on: ubuntu-latest
steps:
- name: Setup python to build package
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install https://pypi.org/project/build
run: python -m pip install build
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Build sdist and wheel
run: python -m build -s -w . -o dist
- name: Publish to PyPi
uses: pypa/gh-action-pypi-publish@master
with:
skip_existing: true
user: __token__
password: ${{ secrets.pypi_password }}
55 changes: 14 additions & 41 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,45 +1,18 @@
*.py[cod]

# C extensions
*.so

# Packages
*.egg
*.egg-info
dist
build
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
lib
lib64
*__pycache__
MANIFEST

# Installer logs
pip-log.txt

# Unit test / coverage reports
.coverage
dist
*.egg
.eggs
*.py[codz]
*$py.class
.tox
nosetests.xml

# Translations
*.mo

# Mr Developer
.mr.developer.cfg
.project
.pydevproject

# py-filelock
# -----------

# Docs
docs/build

.*_cache
.DS_Store
.idea
.vscode
/pip-wheel-metadata
/src/filelock/version.py
venv*
.python-version
test.lock
test.softlock
58 changes: 58 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: check-ast
- id: check-builtin-literals
- id: check-docstring-first
- id: check-merge-conflict
- id: check-yaml
- id: check-toml
- id: debug-statements
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/asottile/pyupgrade
rev: v2.26.0
hooks:
- id: pyupgrade
- repo: https://github.com/PyCQA/isort
rev: 5.9.3
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 21.9b0
hooks:
- id: black
args: [ --safe ]
- repo: https://github.com/asottile/blacken-docs
rev: v1.11.0
hooks:
- id: blacken-docs
additional_dependencies: [ black==20.8b1 ]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:
- id: rst-backticks
- repo: https://github.com/tox-dev/tox-ini-fmt
rev: "0.5.1"
hooks:
- id: tox-ini-fmt
args: [ "-p", "fix_lint" ]
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v1.17.0
hooks:
- id: setup-cfg-fmt
args: [ --min-py3-version, "3.5", "--max-py-version", "3.10" ]
- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear==21.9.1
- flake8-comprehensions==3.6.1
- flake8-pytest-style==1.5
- flake8-spellcheck==0.24
- flake8-unused-arguments==0.0.6
- flake8-noqa==1.1.0
- flake8-eradicate==1.1.0
- pep8-naming==0.12.1
23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

3 changes: 0 additions & 3 deletions MANIFEST.in

This file was deleted.

8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# py-filelock

![travis-ci](https://travis-ci.org/benediktschmitt/py-filelock.svg?branch=master)

This package contains a single module, which implements a platform independent
file lock in Python, which provides a simple way of inter-process communication:

```Python
from filelock import Timeout, FileLock
from src.filelock import Timeout, FileLock

lock = FileLock("high_ground.txt.lock")
with lock:
open("high_ground.txt", "a").write("You were the chosen one.")
open("high_ground.txt", "a").write("You were the chosen one.")
```

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

```Python
from filelock import Timeout, FileLock
from src.filelock import Timeout, FileLock

file_path = "high_ground.txt"
lock_path = "high_ground.txt.lock"
Expand Down
Loading

0 comments on commit 06b078a

Please sign in to comment.