Skip to content

Commit f7e2e60

Browse files
authored
Modernize CI and setup (#49)
* Add `test` and `deploy` workflows. * Modernize `tox.ini` and `setup.py`. * Remove obsolete files. * Skipping tests requiring `mysql_system_database`: Requires further investigation, skipping for now. #50 * Add `RELEASING.rst`
1 parent 70d3751 commit f7e2e60

File tree

13 files changed

+188
-134
lines changed

13 files changed

+188
-134
lines changed

.github/workflows/deploy.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
# Required by attest-build-provenance-github.
16+
permissions:
17+
id-token: write
18+
attestations: write
19+
env:
20+
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.inputs.version }}
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Build and Check Package
26+
uses: hynek/[email protected]
27+
with:
28+
attest-build-provenance-github: 'true'
29+
30+
31+
deploy:
32+
needs: package
33+
runs-on: ubuntu-latest
34+
environment: PyPI
35+
permissions:
36+
id-token: write # For PyPI trusted publishers.
37+
contents: write # For tag and release notes.
38+
39+
steps:
40+
- uses: actions/checkout@v4
41+
42+
- name: Download Package
43+
uses: actions/download-artifact@v4
44+
with:
45+
name: Packages
46+
path: dist
47+
48+
- name: Publish package to PyPI
49+
uses: pypa/[email protected]
50+
with:
51+
attestations: true
52+
53+
- name: Push tag
54+
run: |
55+
git config user.name "pytest bot"
56+
git config user.email "[email protected]"
57+
git tag --annotate --message=v${{ github.event.inputs.version }} v${{ github.event.inputs.version }} ${{ github.sha }}
58+
git push origin v${{ github.event.inputs.version }}
59+
60+
- name: GitHub Release
61+
uses: softprops/action-gh-release@v2
62+
with:
63+
files: dist/*
64+
tag_name: v${{ github.event.inputs.version }}

.github/workflows/test.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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+
20+
runs-on: ubuntu-latest
21+
22+
permissions:
23+
id-token: write
24+
attestations: write
25+
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: Build and Check Package
29+
uses: hynek/[email protected]
30+
31+
test:
32+
needs: [package]
33+
34+
runs-on: ubuntu-latest
35+
36+
strategy:
37+
fail-fast: false
38+
matrix:
39+
python: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
40+
41+
steps:
42+
- uses: actions/checkout@v4
43+
44+
- name: Download Package
45+
uses: actions/download-artifact@v4
46+
with:
47+
name: Packages
48+
path: dist
49+
50+
- name: Set up Python
51+
uses: actions/setup-python@v5
52+
with:
53+
python-version: ${{ matrix.python }}
54+
allow-prereleases: true
55+
56+
- name: System dependencies
57+
run: |
58+
sudo apt-get update
59+
sudo apt-get install xvfb python3-dev libmemcached-dev libmysqlclient-dev memcached libmemcached-tools
60+
61+
- name: Install tox
62+
run: |
63+
python -m pip install --upgrade pip
64+
pip install tox
65+
66+
- name: Test
67+
shell: bash
68+
run: |
69+
tox run -e py --installpkg `find dist/*.tar.gz`

.travis.yml

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

DEPENDENCIES

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

MANIFEST.in

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

Makefile

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

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-services --ref release-VERSION -f version=VERSION
10+
```
11+
12+
5. Merge the PR.

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
[build-system]
2-
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4.1"]
2+
requires = ["setuptools>=61", "setuptools_scm[toml]>=6.2"]
33
build-backend = "setuptools.build_meta"
4+
5+
[tool.setuptools_scm]

pytest_services/mysql.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""Fixtures for mysql."""
22
import os
33
import shutil
4+
from textwrap import dedent
45

5-
from distutils.spawn import find_executable # pylint: disable=E0611
66
import pytest
77

88
from .process import (
@@ -16,22 +16,28 @@ def mysql_defaults_file(
1616
run_services, tmp_path_factory, memory_temp_dir, request):
1717
"""MySQL defaults file."""
1818
if run_services:
19-
cfg = tmp_path_factory.mktemp(request.session.name)
19+
cfg = tmp_path_factory.mktemp("pytest-services")
2020
defaults_path = str(cfg / 'defaults.cnf')
2121

2222
with open(defaults_path, 'w+') as fd:
23-
fd.write("""
24-
[mysqld]
25-
user = {user}
26-
tmpdir = {tmpdir}
27-
default-time-zone = SYSTEM
28-
""".format(user=os.environ['USER'], tmpdir=memory_temp_dir))
23+
user = os.environ["USER"]
24+
fd.write(
25+
dedent(
26+
f"""
27+
[mysqld]
28+
user = {user}
29+
tmpdir = {memory_temp_dir}
30+
default-time-zone = SYSTEM
31+
"""
32+
)
33+
)
2934
return defaults_path
35+
return None
3036

3137

3238
@pytest.fixture(scope='session')
3339
def mysql_base_dir():
34-
my_print_defaults = find_executable('my_print_defaults')
40+
my_print_defaults = shutil.which('my_print_defaults')
3541
assert my_print_defaults, 'You have to install my_print_defaults script.'
3642

3743
return os.path.dirname(os.path.dirname(os.path.realpath(my_print_defaults)))
@@ -49,7 +55,8 @@ def mysql_system_database(
4955
):
5056
"""Install database to given path."""
5157
if run_services:
52-
mysqld = find_executable('mysqld')
58+
pytest.skip(reason="#50 needs investigation")
59+
mysqld = shutil.which('mysqld')
5360
assert mysqld, 'You have to install mysqld script.'
5461

5562
try:

requirements-testing.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# apt-get install xvfb python-dev libmemcached-dev libmysqlclient-dev
2-
coverage
31
mysqlclient
42
pylibmc
5-
pytest-pep8
63
astroid

0 commit comments

Comments
 (0)