-
-
Notifications
You must be signed in to change notification settings - Fork 58
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 #188 from hugovk/log-elapsed-time
- Loading branch information
Showing
7 changed files
with
181 additions
and
2 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,22 @@ | ||
name: Lint | ||
|
||
on: [push, pull_request, workflow_dispatch] | ||
|
||
env: | ||
FORCE_COLOR: 1 | ||
PIP_DISABLE_PIP_VERSION_CHECK: 1 | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.x" | ||
cache: pip | ||
- uses: pre-commit/[email protected] |
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,34 @@ | ||
name: Test | ||
|
||
on: [push, pull_request, workflow_dispatch] | ||
|
||
permissions: | ||
contents: read | ||
|
||
env: | ||
FORCE_COLOR: 1 | ||
|
||
jobs: | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.10", "3.11", "3.12", "3.13"] | ||
os: [ubuntu-latest] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
allow-prereleases: true | ||
|
||
- name: Install uv | ||
uses: hynek/setup-cached-uv@v2 | ||
|
||
- name: Tox tests | ||
run: | | ||
uvx --with tox-uv tox -e py |
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,47 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.6.0 | ||
hooks: | ||
- id: check-added-large-files | ||
- id: check-case-conflict | ||
- id: check-merge-conflict | ||
- id: check-toml | ||
- id: check-yaml | ||
- id: debug-statements | ||
- id: end-of-file-fixer | ||
- id: forbid-submodules | ||
- id: requirements-txt-fixer | ||
- id: trailing-whitespace | ||
|
||
- repo: https://github.com/python-jsonschema/check-jsonschema | ||
rev: 0.29.2 | ||
hooks: | ||
- id: check-github-workflows | ||
|
||
- repo: https://github.com/rhysd/actionlint | ||
rev: v1.7.1 | ||
hooks: | ||
- id: actionlint | ||
|
||
- repo: https://github.com/tox-dev/pyproject-fmt | ||
rev: 2.2.3 | ||
hooks: | ||
- id: pyproject-fmt | ||
|
||
- repo: https://github.com/abravalheri/validate-pyproject | ||
rev: v0.19 | ||
hooks: | ||
- id: validate-pyproject | ||
|
||
- repo: https://github.com/tox-dev/tox-ini-fmt | ||
rev: 1.4.0 | ||
hooks: | ||
- id: tox-ini-fmt | ||
|
||
- repo: meta | ||
hooks: | ||
- id: check-hooks-apply | ||
- id: check-useless-excludes | ||
|
||
ci: | ||
autoupdate_schedule: quarterly |
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,3 @@ | ||
[tool.pytest.ini_options] | ||
pythonpath = [ "." ] | ||
testpaths = [ "tests" ] |
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,26 @@ | ||
import pytest | ||
|
||
from build_docs import format_seconds | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"seconds, expected", | ||
[ | ||
(0.4, "0s"), | ||
(0.5, "0s"), | ||
(0.6, "1s"), | ||
(1.5, "2s"), | ||
(30, "30s"), | ||
(60, "1m 0s"), | ||
(185, "3m 5s"), | ||
(454, "7m 34s"), | ||
(7456, "2h 4m 16s"), | ||
(30.1, "30s"), | ||
(60.2, "1m 0s"), | ||
(185.3, "3m 5s"), | ||
(454.4, "7m 34s"), | ||
(7456.5, "2h 4m 16s"), | ||
], | ||
) | ||
def test_format_seconds(seconds: float, expected: str) -> None: | ||
assert format_seconds(seconds) == expected |
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,25 @@ | ||
[tox] | ||
requires = | ||
tox>=4.2 | ||
env_list = | ||
lint | ||
py{313, 312, 311, 310} | ||
|
||
[testenv] | ||
package = wheel | ||
wheel_build_env = .pkg | ||
skip_install = true | ||
deps = | ||
-r requirements.txt | ||
pytest | ||
commands = | ||
{envpython} -m pytest {posargs} | ||
|
||
[testenv:lint] | ||
skip_install = true | ||
deps = | ||
pre-commit | ||
pass_env = | ||
PRE_COMMIT_COLOR | ||
commands = | ||
pre-commit run --all-files --show-diff-on-failure |