Skip to content

Update infrastructure. #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
CONDA_EXE: mamba

on:
push:
branches:
Expand Down Expand Up @@ -43,6 +40,4 @@ jobs:
run: tox -e test -- --cov=./ --cov-report=xml

- name: Upload coverage reports of tests.
if: runner.os == 'Linux' && matrix.python-version == '3.10'
shell: bash -l {0}
run: bash <(curl -s https://codecov.io/bash)
uses: codecov/codecov-action@v4
1 change: 0 additions & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ coverage:

ignore:
- ".tox/**/*"
- "setup.py"
1 change: 1 addition & 0 deletions docs/source/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ them in reverse chronological order.
## 1.7.0 - 2024-xx-xx

- {pull}`39` updates the pre-commit hooks.
- {pull}`41` updates the infrastructure.

## 1.6.0 - 2023-11-23

Expand Down
5 changes: 5 additions & 0 deletions {{cookiecutter.project_slug}}/.github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ updates:
directory: "/"
schedule:
interval: "weekly"

groups:
github-actions:
patterns:
- "*"
32 changes: 5 additions & 27 deletions {{cookiecutter.project_slug}}/.github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: mamba-org/provision-with-micromamba@main
with:
environment-file: false
Expand All @@ -42,31 +42,9 @@ jobs:
tox-conda
cache-downloads: true

# Unit, integration, and end-to-end tests.

- name: Run unit tests and doctests.
shell: bash -l {0}
run: tox -e pytest -- src tests -m "unit or (not integration and not end_to_end)" --cov=./ --cov-report=xml -n auto

- name: Upload coverage report for unit tests and doctests.
if: runner.os == 'Linux' && matrix.python-version == '3.10'
shell: bash -l {0}
run: bash <(curl -s https://codecov.io/bash) -F unit -c

- name: Run integration tests.
- name: Run tests and doctests.
shell: bash -l {0}
run: tox -e pytest -- src tests -m integration --cov=./ --cov-report=xml -n auto
run: tox -e pytest

- name: Upload coverage reports of integration tests.
if: runner.os == 'Linux' && matrix.python-version == '3.10'
shell: bash -l {0}
run: bash <(curl -s https://codecov.io/bash) -F integration -c

- name: Run end-to-end tests.
shell: bash -l {0}
run: tox -e pytest -- src tests -m end_to_end --cov=./ --cov-report=xml -n auto

- name: Upload coverage reports of end-to-end tests.
if: runner.os == 'Linux' && matrix.python-version == '3.10'
shell: bash -l {0}
run: bash <(curl -s https://codecov.io/bash) -F end_to_end -c
- name: Upload coverage report
uses: codecov/codecov-action@v4
10 changes: 3 additions & 7 deletions {{cookiecutter.project_slug}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,17 @@ repos:
- id: python-no-log-warn
- id: python-use-type-annotations
- id: text-unicode-replacement-char
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v2.2.0
hooks:
- id: setup-cfg-fmt
- repo: https://github.com/aio-libs/sort-all
rev: v1.2.0
hooks:
- id: sort-all
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.1.6
rev: v0.3.2
hooks:
- id: ruff
- id: ruff-format
{% if cookiecutter.python_version in ["3.10", "3.11", "3.12"] %}- repo: https://github.com/dosisod/refurb
rev: v1.24.0
rev: v2.0.0
hooks:
- id: refurb
{% endif %}
Expand All @@ -63,7 +59,7 @@ repos:
args: [--wrap, "88"]
files: (docs/.)
{% if cookiecutter.add_mypy == "yes" %}- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.7.0'
rev: 'v1.9.0'
hooks:
- id: mypy
args: [
Expand Down
17 changes: 12 additions & 5 deletions {{cookiecutter.project_slug}}/.readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
version: 2

build:
image: latest
os: ubuntu-22.04
tools:
python: "3.10"

python:
version: 3.10
sphinx:
configuration: docs/source/conf.py
fail_on_warning: true

conda:
environment: docs/docs_environment.yml
python:
install:
- method: pip
path: .
extra_requirements:
- docs
4 changes: 2 additions & 2 deletions {{cookiecutter.project_slug}}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}) {% endif %}
cookiecutter.github_username }}/{{ cookiecutter.project_slug
}}/main.svg)](https://results.pre-commit.ci/latest/github/{{
cookiecutter.github_username }}/{{ cookiecutter.project_slug }}/main)
[![image](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

## Usage

To get started, create the environment with

```console
$ conda/mamba env create
$ mamba env create
```

To build the project, type
Expand Down
26 changes: 26 additions & 0 deletions {{cookiecutter.project_slug}}/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
codecov:
branch: main

coverage:
precision: 2
round: down
range: 80...100
status:
project:
default:
threshold: 1%
unit:
threshold: 1%
flags:
- unit
integration:
threshold: 1%
flags:
- integration
end_to_end:
threshold: 1%
flags:
- end_to_end

ignore:
- ".tox/**/*"
12 changes: 12 additions & 0 deletions {{cookiecutter.project_slug}}/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2

updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

groups:
github-actions:
patterns:
- "*"
22 changes: 0 additions & 22 deletions {{cookiecutter.project_slug}}/docs/docs_environment.yml

This file was deleted.

4 changes: 2 additions & 2 deletions {{cookiecutter.project_slug}}/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
- conda-lock

# Package dependencies
- pytask >=0.2
- pytask >=0.4

# Misc
- black
Expand All @@ -34,5 +34,5 @@ dependencies:
- sphinx-panels

- pip:
- -e .
- sphinxext-opengraph
- -e .
73 changes: 61 additions & 12 deletions {{cookiecutter.project_slug}}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,66 @@ requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.0"]
[tool.setuptools_scm]
write_to = "src/{{ cookiecutter.project_slug }}/_version.py"

[project]
name = "{{ cookiecutter.project_slug }}"
description = "{{ cookiecutter.project_description }}"
requires-python = ">=3.8"
classifiers = [
"Intended Audience :: Science/Research",
"License :: OSI Approved :: {{ cookiecutter.open_source_license }} License",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
]
dynamic = ["version"]
dependencies = ["pytask"]

[project.readme]
file = "README.md"
content-type = "text/markdown"

[project.license]
text = "{{ cookiecutter.open_source_license }}"

[[project.authors]]
name = "{{ cookiecutter.author }}"
email = "{{ cookiecutter.email }}"

[project.optional-dependencies]
docs = [
"furo",
"ipython",
"myst-parser",
"nbsphinx",
"sphinx",
"sphinx-copybutton",
"sphinx-design>=0.3",
"sphinx-toolbox",
"sphinxext-opengraph",
]
test = []

[project.urls]
Changelog = "https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}"
Documentation = "https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}"
Github = "https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}"
Tracker = "https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}/issues"

[tool.setuptools]
include-package-data = true
zip-safe = false
platforms = ["unix", "linux", "osx", "win32"]
license-files = ["LICENSE"]

[tool.setuptools.package-dir]
"" = "src"

[tool.setuptools.packages.find]
where = ["src"]
namespaces = false

{% if cookiecutter.add_mypy == "yes" %}[tool.mypy]
files = ["src", "tests"]
check_untyped_defs = true
Expand Down Expand Up @@ -46,16 +106,5 @@ convention = "numpy"

[tool.pytest.ini_options]
addopts = ["--doctest-modules"]
testpaths = ["tests"]
filterwarnings = [
"ignore: the imp module is deprecated in favour of importlib",
"ignore: Using or importing the ABCs from 'collections' instead of from",
"ignore: The (parser|symbol) module is deprecated and will be removed in future",
]
markers = [
"wip: Tests that are work-in-progress.",
"unit: Flag for unit tests which target mainly a single function.",
"integration: Flag for integration tests which may comprise of multiple unit tests.",
"end_to_end: Flag for tests that cover the whole program.",
]
testpaths = ["src", "tests"]
norecursedirs = [".idea", ".tox"]
41 changes: 0 additions & 41 deletions {{cookiecutter.project_slug}}/setup.cfg

This file was deleted.

16 changes: 10 additions & 6 deletions {{cookiecutter.project_slug}}/tox.ini
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[tox]
envlist = pytest, sphinx
requires = tox>=4
envlist = docs, test

[testenv]
usedevelop = true
package = editable

[testenv:pytest]
[testenv:test]
conda_channels =
conda-forge
nodefaults
Expand All @@ -14,8 +15,11 @@ conda_deps =
pytest-cov
pytest-xdist

# Package dependencies
pytask

commands =
pytest {posargs}

[testenv:docs]
extras = docs, test
commands =
- sphinx-build -n -T -b html -d {envtmpdir}/doctrees docs/source docs/build/html
- sphinx-build -n -T -b doctest -d {envtmpdir}/doctrees docs/source docs/build/html