Skip to content
Open
Show file tree
Hide file tree
Changes from 20 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
2 changes: 1 addition & 1 deletion .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.3.0
_commit: 5.0.0a4
_src_path: https://github.com/DiamondLightSource/python-copier-template
author_email: [email protected]
author_name: Callum Forrester
Expand Down
58 changes: 48 additions & 10 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,29 @@
},
"remoteEnv": {
// Allow X11 apps to run inside the container
"DISPLAY": "${localEnv:DISPLAY}"
"DISPLAY": "${localEnv:DISPLAY}",
// Put things that allow it in the persistent cache
"PRE_COMMIT_HOME": "/cache/pre-commit",
"UV_CACHE_DIR": "/cache/uv",
"UV_PYTHON_CACHE_DIR": "/cache/uv-python",
// Make a venv that is specific for this workspace path as the cache is shared
"UV_PROJECT_ENVIRONMENT": "/cache/venv-for${localWorkspaceFolder}",
// Do the equivalent of "activate" the venv so we don't have to "uv run" everything
"VIRTUAL_ENV": "/cache/venv-for${localWorkspaceFolder}",
"PATH": "/cache/venv-for${localWorkspaceFolder}/bin:${containerEnv:PATH}"
},
"customizations": {
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"python.defaultInterpreterPath": "/venv/bin/python"
// Use the container's python by default
"python.defaultInterpreterPath": "/cache/venv-for${localWorkspaceFolder}/bin/python",
// Don't activate the venv as it is already in the PATH
"python.terminal.activateEnvInCurrentTerminal": false,
"python.terminal.activateEnvironment": false,
// Workaround to prevent garbled python REPL in the terminal
// https://github.com/microsoft/vscode-python/issues/25505
"python.terminal.shellIntegration.enabled": false
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
Expand All @@ -33,20 +49,42 @@
]
}
},
"features": {
// add in eternal history and other bash features
"ghcr.io/diamondlightsource/devcontainer-features/bash-config:1": {}
},
// Create the config folder for the bash-config feature
"initializeCommand": "mkdir -p ${localEnv:HOME}/.config/bash-config",
// Create the config folder for the bash-config feature and uv cache
"initializeCommand": "mkdir -p ${localEnv:HOME}/.config/terminal-config",
"runArgs": [
// Allow the container to access the host X11 display and EPICS CA
"--net=host",
// Make sure SELinux does not disable with access to host filesystems like tmp
"--security-opt=label=disable"
],
"mounts": [
// Mount in the user terminal config folder so it can be edited
{
"source": "${localEnv:HOME}/.config/terminal-config",
"target": "/user-terminal-config",
"type": "bind"
},
// Keep a persistent cross container cache for uv, pre-commit, and the venvs
{
"source": "persistent-uv-cache",
"target": "/root/.cache/uv",
"type": "volume"
},
// ...and for pre-commit
{
"source": "persistent-pre-commit-cache",
"target": "/root/.cache/pre-commit",
"type": "volume"
}
// Use a volume mount for the uv venv so it is local to the container
{
"target": "/workspaces/${localWorkspaceFolderBasename}/.venv",
"source": "devcontainer-shared-cache",
"type": "volume"
}
Comment on lines +67 to +84
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been changed upstream to use a single cache for everything, do we want to keep in sync with that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, with the envvars set above this does need to change one way or the other

],
// 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": "pip install $([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e '.[dev]' && pre-commit install"
// After the container is created, recreate the venv then make pre-commit first run faster
"postCreateCommand": "uv venv --clear && uv sync && 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.3.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.0a4/how-to.html).
35 changes: 0 additions & 35 deletions .github/actions/install_requirements/action.yml

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/_container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
uses: actions/checkout@v5
with:
# Need this to get version number from last tag
fetch-depth: 0
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
tags: |
type=ref,event=tag
type=raw,value=latest

- name: Push cached image to container registry
if: github.ref_type == 'tag'
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6
Expand All @@ -85,7 +85,7 @@ jobs:
needs: build_container
steps:
- name: checkout repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
uses: actions/checkout@v5

- name: install helm
uses: Azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4 # v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/_debug_container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
# Need this to get version number from last tag
fetch-depth: 0
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/_dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ jobs:

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

- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Build sdist and wheel
run: >
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) &&
pipx run build
uvx --from build pyproject-build

- name: Upload sdist and wheel as artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
Expand All @@ -24,12 +27,10 @@ jobs:
path: dist

- name: Check for packaging errors
run: pipx run twine check --strict dist/*
run: uvx twine check --strict dist/*

- name: Install produced wheel
uses: ./.github/actions/install_requirements
with:
pip-install: dist/*.whl
run: python -m pip install dist/*.whl

- name: Test module --version works using the installed wheel
# If more than one module in src/ replace with module name to test
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/_docs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
on:
workflow_call:


jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -12,19 +11,19 @@ jobs:
run: sleep 60

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

- name: Install system packages
run: sudo apt-get install graphviz

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

- name: Build docs
run: tox -e docs
run: uv run --locked tox -e docs

- name: Remove environment.pickle
run: rm build/html/.doctrees/environment.pickle
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

steps:
- name: Download dist artifact
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
uses: actions/download-artifact@v5
with:
name: dist
path: dist
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:

steps:
- name: Download artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
uses: actions/download-artifact@v5
with:
merge-multiple: true

Expand All @@ -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@da05d552573ad5aba039eaac05058a918a7bf631 # v2.2.2
uses: softprops/action-gh-release@6da8fa9354ddfdc4aeace5fc48d7f679b5214090 # v2.4.1
with:
prerelease: ${{ contains(github.ref_name, 'a') || contains(github.ref_name, 'b') || contains(github.ref_name, 'rc') }}
files: "*"
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/_system_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ jobs:

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

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

- name: Checkout simulated devices
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
repository: epics-containers/example-services
path: example-services
ref: '2025.8.2'
ref: "2025.8.2"

- name: Compose devices
uses: hoverkraft-tech/compose-action@3846bcd61da338e9eaaf83e7ed0234a12b099b72 # v2.4.1
Expand All @@ -49,7 +49,7 @@ jobs:
env:
EPICS_CA_NAME_SERVERS: 127.0.0.1:9064
EPICS_PVA_NAME_SERVERS: 127.0.0.1:9075
run: blueapi -c ${{ github.workspace }}/tests/system_tests/config.yaml serve &
run: uv run blueapi -c ${{ github.workspace }}/tests/system_tests/config.yaml serve &

- name: Run tests
run: tox -e system-test
run: uv run --locked tox -e system-test
31 changes: 7 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,14 +16,15 @@ on:
env:
# https://github.com/pytest-dev/pytest/issues/2042
PY_IGNORE_IMPORTMISMATCH: "1"
UV_PYTHON: ${{ inputs.python-version }}

jobs:
run:
runs-on: ${{ inputs.runs-on }}

steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
uses: actions/checkout@v5
with:
# Need this to get version number from last tag
fetch-depth: 0
Expand All @@ -32,29 +33,11 @@ jobs:
if: github.ref != 'refs/heads/main'
run: git branch --track main origin/main

- 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: pip freeze --exclude-editable > /tmp/dev-requirements.txt
- name: Install uv
uses: astral-sh/setup-uv@v7

- if: inputs.python-version == 'dev'
name: Upload dev-requirements.txt
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # 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 }}
pip-install: ".[dev]"
- name: Run tests
run: tox -e tests
run: uv run --locked tox -e tests

- name: Upload coverage to Codecov
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/_tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@ on:
description: What to run under tox
required: true


jobs:
run:
runs-on: "ubuntu-latest"

steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
uses: actions/checkout@v5

- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Install python packages
uses: ./.github/actions/install_requirements

- name: Install helm plugins
run: helm plugin install https://github.com/losisin/helm-values-schema-json.git --version 2.2.1

- name: Run tox
run: tox -e ${{ inputs.tox }}
run: uv run --locked tox -e ${{ inputs.tox }}
Loading