Skip to content

Commit

Permalink
Update to copier-template 2.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DiamondJoseph committed Nov 15, 2024
1 parent e51530c commit 3fb428c
Show file tree
Hide file tree
Showing 29 changed files with 187 additions and 40 deletions.
4 changes: 3 additions & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Changes here will be overwritten by Copier
_commit: 2.0.1
_commit: 2.5.0
_src_path: gh:DiamondLightSource/python-copier-template
author_email: [email protected]
author_name: Callum Forrester
component_lifecycle: production
component_owner: user:vid18871
component_type: service
description: Lightweight bluesky-as-a-service wrapper application. Also usable as
a library.
distribution_name: blueapi
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@
"workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind",
// After the container is created, install the python project in editable form
"postCreateCommand": "pip install $([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e '.[dev]' && pre-commit install"
}
}
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ It is recommended that developers use a [vscode devcontainer](https://code.visua

This project was created using the [Diamond Light Source Copier Template](https://github.com/DiamondLightSource/python-copier-template) for Python projects.

For more information on common tasks like setting up a developer environment, running the tests, and setting a pre-commit hook, see the template's [How-to guides](https://diamondlightsource.github.io/python-copier-template/2.0.1/how-to.html).
For more information on common tasks like setting up a developer environment, running the tests, and setting a pre-commit hook, see the template's [How-to guides](https://diamondlightsource.github.io/python-copier-template/2.5.0/how-to.html).
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Bug Report
about: The template to use for reporting bugs and usability issues
title: " "
labels: 'bug'
assignees: ''

---

Describe the bug, including a clear and concise description of the expected behavior, the actual behavior and the context in which you encountered it (ideally include details of your environment).

## Steps To Reproduce
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error


## Acceptance Criteria
- Specific criteria that will be used to judge if the issue is fixed
13 changes: 13 additions & 0 deletions .github/ISSUE_TEMPLATE/issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
name: Issue
about: The standard template to use for feature requests, design discussions and tasks
title: " "
labels: ''
assignees: ''

---

A brief description of the issue, including specific stakeholders and the business case where appropriate

## Acceptance Criteria
- Specific criteria that will be used to judge if the issue is fixed
8 changes: 8 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Fixes #ISSUE

### Instructions to reviewer on how to test:
1. Do thing x
2. Confirm thing y happens

### Checks for reviewer
- [ ] Would the PR title make sense to a user on a set of release notes
2 changes: 1 addition & 1 deletion .github/pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
<link rel="canonical" href="main/index.html">
</head>

</html>
</html>
5 changes: 5 additions & 0 deletions .github/pages/make_switcher.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Make switcher.json to allow docs to switch between different versions."""

import json
import logging
from argparse import ArgumentParser
Expand All @@ -6,6 +8,7 @@


def report_output(stdout: bytes, label: str) -> list[str]:
"""Print and return something received frm stdout."""
ret = stdout.decode().strip().split("\n")
print(f"{label}: {ret}")
return ret
Expand Down Expand Up @@ -53,6 +56,7 @@ def get_versions(ref: str, add: str | None) -> list[str]:


def write_json(path: Path, repository: str, versions: list[str]):
"""Write the JSON switcher to path."""
org, repo_name = repository.split("/")
struct = [
{"version": version, "url": f"https://{org}.github.io/{repo_name}/{version}/"}
Expand All @@ -64,6 +68,7 @@ def write_json(path: Path, repository: str, versions: list[str]):


def main(args=None):
"""Parse args and write switcher."""
parser = ArgumentParser(
description="Make a versions.json file from gh-pages directories"
)
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/_container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and export to Docker local cache
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
env:
DOCKER_BUILD_RECORD_UPLOAD: false
with:
context: .
# Need load and tags so we can test it below
Expand All @@ -64,7 +66,9 @@ jobs:
- name: Push cached image to container registry
if: github.ref_type == 'tag'
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
env:
DOCKER_BUILD_RECORD_UPLOAD: false
# This does not build the image again, it will find the image in the
# Docker cache and publish it
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ jobs:
if: github.ref_type == 'tag' || github.ref_name == 'main'
# We pin to the SHA, not the tag, for security reasons.
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
uses: peaceiris/actions-gh-pages@373f7f263a76c20808c831209c920827a82a2847 # v3.9.3
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: .github/pages
keep_files: true
keep_files: true
2 changes: 2 additions & 0 deletions .github/workflows/_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ jobs:

- name: Publish to PyPI using trusted publishing
uses: pypa/gh-action-pypi-publish@release/v1
with:
attestations: false
2 changes: 1 addition & 1 deletion .github/workflows/_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Create GitHub Release
# We pin to the SHA, not the tag, for security reasons.
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
uses: softprops/action-gh-release@e7a8f85e1c67a31e6ed99a94b41bd0b71bbee6b8 # v2.0.9
with:
prerelease: ${{ contains(github.ref_name, 'a') || contains(github.ref_name, 'b') || contains(github.ref_name, 'rc') }}
files: "*"
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
matrix:
runs-on: ["ubuntu-latest"] # can add windows-latest, macos-latest
python-version: ["3.10", "3.11"]
python-version: ["3.10", "3.11", "3.12"]
include:
# Include one that runs in the dev environment
- runs-on: "ubuntu-latest"
Expand All @@ -39,6 +39,7 @@ jobs:
if: needs.check.outputs.branch-pr == ''
uses: ./.github/workflows/_container.yml
permissions:
contents: read
packages: write

docs:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ cov.xml

# Sphinx documentation
docs/_build/
docs/_api

# PyBuilder
target/
Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ repos:
- id: check-yaml
exclude: ^helm\/.*\/templates\/.*|catalog-info.yaml
- id: check-merge-conflict
- id: end-of-file-fixer

- repo: local
hooks:
Expand Down
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"recommendations": [
"ms-vscode-remote.remote-containers",
]
}
}
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
},
"files.insertFinalNewline": true,
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
},
}
}
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"problemMatcher": [],
}
]
}
}
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# The devcontainer should use the developer target and run as root with podman
# or docker with user namespaces.
ARG PYTHON_VERSION=3.11
FROM python:${PYTHON_VERSION} as developer
FROM python:${PYTHON_VERSION} AS developer

# Add any system dependencies for the developer/build environment here
RUN apt-get update && apt-get install -y --no-install-recommends \
Expand All @@ -13,13 +13,13 @@ RUN python -m venv /venv
ENV PATH=/venv/bin:$PATH

# The build stage installs the context into the venv
FROM developer as build
FROM developer AS build
COPY . /context
WORKDIR /context
RUN touch dev-requirements.txt && pip install --upgrade pip && pip install -c dev-requirements.txt .

# The runtime stage copies the built venv into a slim runtime container
FROM python:${PYTHON_VERSION}-slim as runtime
FROM python:${PYTHON_VERSION}-slim AS runtime
# Add apt-get system dependecies for runtime here if needed
RUN apt-get update && apt-get install -y --no-install-recommends \
# Git required for installing packages at runtime
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![CI](https://github.com/DiamondLightSource/blueapi/actions/workflows/ci.yml/badge.svg)](https://github.com/DiamondLightSource/blueapi/actions/workflows/ci.yml)
[![Coverage](https://codecov.io/gh/DiamondLightSource/blueapi/branch/main/graph/badge.svg)](https://codecov.io/gh/DiamondLightSource/blueapi)
[![PyPI](https://img.shields.io/pypi/v/blueapi.svg)](https://pypi.org/project/blueapi)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)

# blueapi

Expand Down
16 changes: 16 additions & 0 deletions docs/_api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
:orphan:

..
This page is not included in the TOC tree, but must exist so that the
autosummary pages are generated for blueapi and all its
subpackages
API
===

.. autosummary::
:toctree: _api
:template: custom-module-template.rst
:recursive:

blueapi
37 changes: 37 additions & 0 deletions docs/_templates/custom-module-template.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{{ ('``' + fullname + '``') | underline }}

{%- set filtered_members = [] %}
{%- for item in members %}
{%- if item in functions + classes + exceptions + attributes %}
{% set _ = filtered_members.append(item) %}
{%- endif %}
{%- endfor %}

.. automodule:: {{ fullname }}
:members:

{% block modules %}
{% if modules %}
.. rubric:: Submodules

.. autosummary::
:toctree:
:template: custom-module-template.rst
:recursive:
{% for item in modules %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block members %}
{% if filtered_members %}
.. rubric:: Members

.. autosummary::
:nosignatures:
{% for item in filtered_members %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
27 changes: 18 additions & 9 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
"""Configuration file for the Sphinx documentation builder.
This file only contains a selection of the most common options. For a full
list see the documentation:
https://www.sphinx-doc.org/en/master/usage/configuration.html
"""

import sys
from pathlib import Path
Expand Down Expand Up @@ -32,6 +33,8 @@
extensions = [
# Use this for generating API docs
"sphinx.ext.autodoc",
# and making summary tables at the top of API docs
"sphinx.ext.autosummary",
# This can parse google style docstrings
"sphinx.ext.napoleon",
# For linking to external sphinx documentation
Expand Down Expand Up @@ -84,6 +87,12 @@
# Don't inherit docstrings from baseclasses
autodoc_inherit_docstrings = False

# Document only what is in __all__
autosummary_ignore_module_all = False

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

# Output graphviz directive produced images in a scalable format
graphviz_output_format = "svg"

Expand Down Expand Up @@ -139,10 +148,10 @@
# Theme options for pydata_sphinx_theme
# We don't check switcher because there are 3 possible states for a repo:
# 1. New project, docs are not published so there is no switcher
# 2. Existing project with latest skeleton, switcher exists and works
# 3. Existing project with old skeleton that makes broken switcher,
# 2. Existing project with latest copier template, switcher exists and works
# 3. Existing project with old copier template that makes broken switcher,
# switcher exists but is broken
# Point 3 makes checking switcher difficult, because the updated skeleton
# Point 3 makes checking switcher difficult, because the updated copier template
# will fix the switcher at the end of the docs workflow, but never gets a chance
# to complete as the docs build warns and fails.
html_theme_options = {
Expand Down Expand Up @@ -170,7 +179,7 @@
# A dictionary of values to pass into the template engine’s context for all pages
html_context = {
"github_user": github_user,
"github_repo": project,
"github_repo": github_repo,
"github_version": version,
"doc_path": "docs",
}
Expand Down
2 changes: 1 addition & 1 deletion docs/how-to/contribute.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
```{include} ../../.github/CONTRIBUTING.md
```
```
2 changes: 1 addition & 1 deletion docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Technical reference material including APIs and release notes.
:maxdepth: 1
:glob:
reference/*
API <_api/blueapi>
genindex
Release Notes <https://github.com/DiamondLightSource/blueapi/releases>
```
2 changes: 1 addition & 1 deletion docs/tutorials/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Check your version of python

You will need python 3.8 or later. You can check your version of python by
You will need python 3.10 or later. You can check your version of python by
typing into a terminal:
```
python3 --version
Expand Down
Loading

0 comments on commit 3fb428c

Please sign in to comment.