Skip to content

Commit e70354c

Browse files
committed
Modernize workflows and settings
1 parent 6ab17fc commit e70354c

26 files changed

+488
-340
lines changed

.github/dependabot.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Keep GitHub Actions up to date with GitHub's Dependabot...
2+
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot
3+
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem
4+
version: 2
5+
updates:
6+
- package-ecosystem: github-actions
7+
directory: /
8+
groups:
9+
github-actions:
10+
patterns:
11+
- "*" # Group all Actions updates into a single larger pull request
12+
schedule:
13+
interval: weekly

.github/workflows/build-package.yml

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

.github/workflows/deploy.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: deploy
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Release version'
8+
required: true
9+
default: '1.2.3'
10+
11+
jobs:
12+
13+
package:
14+
runs-on: ubuntu-latest
15+
env:
16+
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.inputs.version }}
17+
18+
steps:
19+
- uses: actions/checkout@v3
20+
21+
- name: Build and Check Package
22+
uses: hynek/[email protected]
23+
24+
deploy:
25+
needs: package
26+
runs-on: ubuntu-latest
27+
environment: deploy
28+
permissions:
29+
id-token: write # For PyPI trusted publishers.
30+
contents: write # For tag and release notes.
31+
32+
steps:
33+
- uses: actions/checkout@v3
34+
35+
- name: Download Package
36+
uses: actions/download-artifact@v3
37+
with:
38+
name: Packages
39+
path: dist
40+
41+
- name: Publish package to PyPI
42+
uses: pypa/[email protected]
43+
44+
- name: Push tag
45+
run: |
46+
git config user.name "pytest bot"
47+
git config user.email "[email protected]"
48+
git tag --annotate --message=v${{ github.event.inputs.version }} v${{ github.event.inputs.version }} ${{ github.sha }}
49+
git push origin v${{ github.event.inputs.version }}
50+
51+
- name: GitHub Release
52+
uses: softprops/action-gh-release@v1
53+
with:
54+
body_path: scripts/latest-release-notes.md
55+
files: dist/*
56+
tag_name: v${{ github.event.inputs.version }}

.github/workflows/publish-package.yml

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

.github/workflows/test.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- "test-me-*"
8+
9+
pull_request:
10+
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
18+
package:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v3
22+
- name: Build and Check Package
23+
uses: hynek/[email protected]
24+
25+
test:
26+
27+
needs: [package]
28+
29+
runs-on: ${{ matrix.os }}
30+
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
35+
os: [ubuntu-latest, windows-latest]
36+
37+
steps:
38+
- uses: actions/checkout@v3
39+
40+
- name: Download Package
41+
uses: actions/download-artifact@v3
42+
with:
43+
name: Packages
44+
path: dist
45+
46+
- name: Set up Python
47+
uses: actions/setup-python@v4
48+
with:
49+
python-version: ${{ matrix.python }}
50+
51+
- name: Install tox
52+
run: |
53+
python -m pip install --upgrade pip
54+
pip install tox
55+
56+
- name: Test
57+
shell: bash
58+
run: |
59+
tox run -e py --installpkg `find dist/*.tar.gz`

.pre-commit-config.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
exclude: '^($|.*\.bin)'
2+
repos:
3+
- repo: local
4+
hooks:
5+
- id: rst
6+
name: rst
7+
entry: rst-lint --encoding utf-8
8+
files: ^(CHANGELOG.rst|README.rst|HOWTORELEASE.rst)$
9+
language: python
10+
additional_dependencies: [pygments, restructuredtext_lint]
11+
- repo: https://github.com/astral-sh/ruff-pre-commit
12+
rev: v0.3.3
13+
hooks:
14+
- id: ruff
15+
args: ["--fix"]
16+
- id: ruff-format

RELEASING.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Here are the steps on how to make a new release.
2+
3+
1. Create a ``release-VERSION`` branch from ``upstream/main``.
4+
2. Update ``CHANGELOG.rst``.
5+
3. Push the branch to ``upstream``.
6+
4. Once all tests pass, start the ``deploy`` workflow manually or via:
7+
8+
```
9+
gh workflow run deploy.yml --repo pytest-dev/pytest-mock --ref release-VERSION -f version=VERSION
10+
```
11+
12+
5. Merge the PR.

pyproject.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[build-system]
2+
requires = [
3+
"setuptools",
4+
"setuptools-scm>=8",
5+
]
6+
build-backend = "setuptools.build_meta"
7+
8+
[tool.pytest.ini_options]
9+
testpaths = ["tests"]
10+
addopts = "-r a"
11+
asyncio_mode = "auto"
12+
filterwarnings = [
13+
"ignore:.*usage of Session..*:DeprecationWarning"
14+
]
15+
16+
[tool.ruff]
17+
line-length = 120

random_order/bucket_types.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ def bucket_type_key(bucket_type):
1111
"""
1212

1313
def decorator(f):
14-
1514
@functools.wraps(f)
1615
def wrapped(item, session):
1716
key = f(item)
@@ -28,24 +27,24 @@ def wrapped(item, session):
2827
return decorator
2928

3029

31-
@bucket_type_key('global')
30+
@bucket_type_key("global")
3231
def get_global_key(item):
3332
return None
3433

3534

36-
@bucket_type_key('package')
35+
@bucket_type_key("package")
3736
def get_package_key(item):
3837
if not hasattr(item, "module"):
3938
return os.path.split(item.location[0])[0]
4039
return item.module.__package__
4140

4241

43-
@bucket_type_key('module')
42+
@bucket_type_key("module")
4443
def get_module_key(item):
4544
return item.location[0]
4645

4746

48-
@bucket_type_key('class')
47+
@bucket_type_key("class")
4948
def get_class_key(item):
5049
if not hasattr(item, "cls"):
5150
return item.location[0]
@@ -55,19 +54,19 @@ def get_class_key(item):
5554
return item.module.__name__
5655

5756

58-
@bucket_type_key('parent')
57+
@bucket_type_key("parent")
5958
def get_parent_key(item):
6059
return item.parent
6160

6261

63-
@bucket_type_key('grandparent')
62+
@bucket_type_key("grandparent")
6463
def get_grandparent_key(item):
6564
return item.parent.parent
6665

6766

68-
@bucket_type_key('none')
67+
@bucket_type_key("none")
6968
def get_none_key(item):
70-
raise RuntimeError('When shuffling is disabled (bucket_type=none), item key should not be calculated')
69+
raise RuntimeError("When shuffling is disabled (bucket_type=none), item key should not be calculated")
7170

7271

7372
bucket_types = bucket_type_keys.keys()

random_order/cache.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@
55
66
"""
77

8-
FAILED_FIRST_LAST_FAILED_BUCKET_KEY = '<failed_first_last_failed>'
8+
FAILED_FIRST_LAST_FAILED_BUCKET_KEY = "<failed_first_last_failed>"
99

1010

1111
def process_failed_first_last_failed(session, config, items):
12-
if not hasattr(config, 'cache'):
12+
if not hasattr(config, "cache"):
1313
return
1414

15-
if not config.getoption('failedfirst'):
15+
if not config.getoption("failedfirst"):
1616
return
1717

18-
last_failed_raw = config.cache.get('cache/lastfailed', None)
18+
last_failed_raw = config.cache.get("cache/lastfailed", None)
1919
if not last_failed_raw:
2020
return
2121

2222
# Get the names of last failed tests
2323
last_failed = []
2424
for key in last_failed_raw.keys():
25-
parts = key.split('::')
25+
parts = key.split("::")
2626
if len(parts) == 3:
2727
last_failed.append(tuple(parts))
2828
elif len(parts) == 2:

0 commit comments

Comments
 (0)