Skip to content
Open
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
5 changes: 3 additions & 2 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier
_commit: 4.1.0-7-gb8b3f90
_commit: 5.0.0a1
_src_path: gh:DiamondLightSource/python-copier-template
author_email: oliver.copping@diamond.ac.uk
author_name: Oliver Copping
Expand All @@ -8,7 +8,8 @@ component_owner: group:default/sscc
component_type: library
description: A package for building Phoebus GUIs
distribution_name: techui-builder
docker: false
docker: true
docker_debug: false
docs_type: README
git_platform: github.com
github_org: DiamondLightSource
Expand Down
17 changes: 3 additions & 14 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// We put venv on a different volume to cache so have to copy
"UV_LINK_MODE": "copy",
// Do the equivalent of "activate" the venv so we don't have to "uv run" everything
"PATH": "/workspaces/${localWorkspaceFolderBasename}/.venv/bin:${localEnv:PATH}"
"PATH": "/workspaces/${localWorkspaceFolderBasename}/.venv/bin:${containerEnv:PATH}"
},
"customizations": {
"vscode": {
Expand All @@ -20,16 +20,7 @@
"python.defaultInterpreterPath": "/workspaces/${localWorkspaceFolderBasename}/.venv/bin/python",
"python.terminal.activateEnvInCurrentTerminal": false,
"python.terminal.activateEnvironment": false,
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
},
"remote.autoForwardPorts": false,
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff"
}
"remote.autoForwardPorts": false
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
Expand All @@ -51,8 +42,6 @@
// Make sure SELinux does not disable with access to host filesystems like tmp
"--security-opt=label=disable"
],
// Populate the user's terminal config folder with default config if it is blank
"onCreateCommand": "/root/terminal-config/ensure-user-terminal-config.sh",
"mounts": [
// Mount in the user terminal config folder so it can be edited
{
Expand All @@ -75,5 +64,5 @@
// Mount the parent as /workspaces so we can pip install peers as editable
"workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind",
// After the container is created, install the python project in editable form
"postCreateCommand": "uv sync && uv run pre-commit install"
"postCreateCommand": "uv sync && uv run pre-commit install --install-hooks"
}
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/4.1.0/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/5.0.0a1/how-to.html).
38 changes: 0 additions & 38 deletions .github/actions/install_requirements/action.yml

This file was deleted.

64 changes: 64 additions & 0 deletions .github/workflows/_container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
on:
workflow_call:
inputs:
publish:
type: boolean
description: If true, pushes image to container registry

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Need this to get version number from last tag
fetch-depth: 0

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Docker Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and export to Docker local cache
uses: docker/build-push-action@v6
env:
DOCKER_BUILD_RECORD_UPLOAD: false
with:
context: .
# Need load and tags so we can test it below
load: true
tags: tag_for_testing

- name: Test cli works in cached runtime image
run: docker run --rm tag_for_testing --version

- name: Create tags for publishing image
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=tag
type=raw,value=latest

- name: Push cached image to container registry
if: inputs.publish && github.ref_type == 'tag'
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:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
30 changes: 6 additions & 24 deletions .github/workflows/_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ on:
inputs:
python-version:
type: string
description: The version of python to install
required: true
description: The version of python to install, default is from .python-version file
default: ""
runs-on:
type: string
description: The runner to run this job on
Expand All @@ -16,6 +16,7 @@ on:
env:
# https://github.com/pytest-dev/pytest/issues/2042
PY_IGNORE_IMPORTMISMATCH: "1"
UV_PYTHON: ${{ inputs.python-version }}

jobs:
run:
Expand All @@ -29,30 +30,11 @@ jobs:
fetch-depth: 0
submodules: recursive

- if: inputs.python-version == 'dev'
name: Install dev versions of python packages
uses: ./.github/actions/install_requirements

- if: inputs.python-version == 'dev'
name: Write the requirements as an artifact
run: uv pip freeze --exclude-editable > /tmp/dev-requirements.txt

- if: inputs.python-version == 'dev'
name: Upload dev-requirements.txt
uses: actions/upload-artifact@v4
with:
name: dev-requirements
path: /tmp/dev-requirements.txt

- if: inputs.python-version != 'dev'
name: Install latest versions of python packages
uses: ./.github/actions/install_requirements
with:
python-version: ${{ inputs.python-version }}
uv-sync: ""
- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Run tests
run: tox -e tests
run: uv run --locked tox -e tests

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/_tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v5

- name: Install python packages
uses: ./.github/actions/install_requirements
- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Run tox
run: tox -e ${{ inputs.tox }}
run: uv run --locked tox -e ${{ inputs.tox }}
21 changes: 15 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ on:
branches:
- main
tags:
- '*'
- "*"
pull_request:

jobs:

lint:
uses: ./.github/workflows/_tox.yml
with:
Expand All @@ -18,8 +17,8 @@ jobs:
test:
strategy:
matrix:
runs-on: ["ubuntu-latest"] # can add macos-latest
python-version: ["3.12"]
runs-on: ["ubuntu-latest"] # can add windows-latest, macos-latest
python-version: ["3.12", "3.13"]
fail-fast: false
uses: ./.github/workflows/_test.yml
with:
Expand All @@ -28,16 +27,26 @@ jobs:
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

container:
needs: test
if: always()
uses: ./.github/workflows/_container.yml
with:
publish: ${{ needs.test.result == 'success' }}
permissions:
contents: read
packages: write

dist:
uses: ./.github/workflows/_dist.yml

pypi:
needs: [dist, test]
if: github.ref_type == 'tag'
uses: ./.github/workflows/_pypi.yml
permissions:
id-token: write

release:
needs: [dist, test]
if: github.ref_type == 'tag'
Expand Down
22 changes: 10 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: check-added-large-files
args: ["--maxkb=1000"] # uv.lock is more than 500kB
- id: check-yaml
- id: check-merge-conflict
- id: end-of-file-fixer

- repo: https://github.com/astral-sh/uv-pre-commit
# uv version.
rev: 0.6.14
- repo: local
hooks:
- id: uv-lock

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.11.4
hooks:
# Run the linter.
- id: ruff
name: lint with ruff
language: system
entry: ruff check --force-exclude --fix
types: [python]
require_serial: true

# Run the formatter.
- id: ruff-format
name: format with ruff
language: system
entry: ruff format --force-exclude
types: [python]
require_serial: true

- id: uv-sync
name: update uv.lock and venv
pass_filenames: false
language: system
entry: uv sync
files: ^(uv\.lock|pyproject\.toml)$
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
Loading
Loading