Skip to content

Commit 2f6700a

Browse files
Merge with copier update, including type fixing
2 parents daf933e + e8c3643 commit 2f6700a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+773
-62
lines changed

.copier-answers.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
# Changes here will be overwritten by Copier
2-
_commit: 2.1.0
2+
_commit: 3.0.0
33
_src_path: gh:DiamondLightSource/python-copier-template
4-
author_email: [email protected]
5-
author_name: David Perl
6-
component_owner: group:default/sscc
7-
description: A service to put and get your config values from
4+
author_email: [email protected]
5+
author_name: Oliver Silvester
6+
component_lifecycle: experimental
7+
component_owner: group:default/data-acquisition
8+
component_type: service
9+
description: A service to read files on dls_sw from a blueapi container
810
distribution_name: daq-config-server
9-
docker: false
10-
docs_type: README
11+
docker: true
12+
docs_type: sphinx
1113
git_platform: github.com
1214
github_org: DiamondLightSource
1315
package_name: daq_config_server
1416
pypi: true
1517
repo_name: daq-config-server
18+
strict_typing: true
1619
type_checker: pyright

.devcontainer/devcontainer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828
}
2929
},
3030
"features": {
31-
// Some default things like git config
32-
"ghcr.io/devcontainers/features/common-utils:2": {
33-
"upgradePackages": false
34-
}
31+
// add in eternal history and other bash features
32+
"ghcr.io/diamondlightsource/devcontainer-features/bash-config:1": {}
3533
},
34+
// Create the config folder for the bash-config feature
35+
"initializeCommand": "mkdir -p ${localEnv:HOME}/.config/bash-config",
3636
"runArgs": [
3737
// Allow the container to access the host X11 display and EPICS CA
3838
"--net=host",
@@ -43,4 +43,4 @@
4343
"workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind",
4444
// After the container is created, install the python project in editable form
4545
"postCreateCommand": "pip install $([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e '.[dev]' && pre-commit install"
46-
}
46+
}

.github/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ It is recommended that developers use a [vscode devcontainer](https://code.visua
2424

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

27-
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.1.0/how-to.html).
27+
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/3.0.0/how-to.html).
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
name: Bug Report
3+
about: The template to use for reporting bugs and usability issues
4+
title: " "
5+
labels: 'bug'
6+
assignees: ''
7+
8+
---
9+
10+
Describe the bug, including a clear and concise description of the expected behaviour, the actual behavior and the context in which you encountered it (ideally include details of your environment).
11+
12+
## Steps To Reproduce
13+
Steps to reproduce the behavior:
14+
1. Go to '...'
15+
2. Click on '....'
16+
3. Scroll down to '....'
17+
4. See error
18+
19+
20+
## Acceptance Criteria
21+
- Specific criteria that will be used to judge if the issue is fixed

.github/ISSUE_TEMPLATE/issue.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
name: Issue
3+
about: The standard template to use for feature requests, design discussions and tasks
4+
title: " "
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
A brief description of the issue, including specific stakeholders and the business case where appropriate
11+
12+
## Acceptance Criteria
13+
- Specific criteria that will be used to judge if the issue is fixed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Fixes #ISSUE
2+
3+
### Instructions to reviewer on how to test:
4+
1. Do thing x
5+
2. Confirm thing y happens
6+
7+
### Checks for reviewer
8+
- [ ] Would the PR title make sense to a user on a set of release notes

.github/pages/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
<link rel="canonical" href="main/index.html">
99
</head>
1010

11-
</html>
11+
</html>

.github/pages/make_switcher.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Make switcher.json to allow docs to switch between different versions."""
2+
13
import json
24
import logging
35
from argparse import ArgumentParser
@@ -6,6 +8,7 @@
68

79

810
def report_output(stdout: bytes, label: str) -> list[str]:
11+
"""Print and return something received frm stdout."""
912
ret = stdout.decode().strip().split("\n")
1013
print(f"{label}: {ret}")
1114
return ret
@@ -52,21 +55,20 @@ def get_versions(ref: str, add: str | None) -> list[str]:
5255
return versions
5356

5457

55-
def write_json(path: Path, repository: str, versions: str):
58+
def write_json(path: Path, repository: str, versions: list[str]):
59+
"""Write the JSON switcher to path."""
5660
org, repo_name = repository.split("/")
57-
pages_url = f"https://{org}.github.io"
58-
if repo_name != f"{org}.github.io":
59-
# Only add the repo name if it isn't the source for the org pages site
60-
pages_url += f"/{repo_name}"
6161
struct = [
62-
{"version": version, "url": f"{pages_url}/{version}/"} for version in versions
62+
{"version": version, "url": f"https://{org}.github.io/{repo_name}/{version}/"}
63+
for version in versions
6364
]
6465
text = json.dumps(struct, indent=2)
6566
print(f"JSON switcher:\n{text}")
6667
path.write_text(text, encoding="utf-8")
6768

6869

6970
def main(args=None):
71+
"""Parse args and write switcher."""
7072
parser = ArgumentParser(
7173
description="Make a versions.json file from gh-pages directories"
7274
)

.github/workflows/_container.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
on:
2+
workflow_call:
3+
4+
jobs:
5+
build:
6+
runs-on: ubuntu-latest
7+
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v4
11+
with:
12+
# Need this to get version number from last tag
13+
fetch-depth: 0
14+
15+
- name: Set up Docker Buildx
16+
id: buildx
17+
uses: docker/setup-buildx-action@v3
18+
19+
- name: Log in to GitHub Docker Registry
20+
if: github.event_name != 'pull_request'
21+
uses: docker/login-action@v3
22+
with:
23+
registry: ghcr.io
24+
username: ${{ github.actor }}
25+
password: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- name: Build and export to Docker local cache
28+
uses: docker/build-push-action@v6
29+
env:
30+
DOCKER_BUILD_RECORD_UPLOAD: false
31+
with:
32+
context: .
33+
# Need load and tags so we can test it below
34+
load: true
35+
tags: tag_for_testing
36+
37+
- name: Test cli works in cached runtime image
38+
run: docker run --rm tag_for_testing --version
39+
40+
- name: Create tags for publishing image
41+
id: meta
42+
uses: docker/metadata-action@v5
43+
with:
44+
images: ghcr.io/${{ github.repository }}
45+
tags: |
46+
type=ref,event=tag
47+
type=raw,value=latest
48+
49+
- name: Push cached image to container registry
50+
if: github.ref_type == 'tag'
51+
uses: docker/build-push-action@v6
52+
env:
53+
DOCKER_BUILD_RECORD_UPLOAD: false
54+
# This does not build the image again, it will find the image in the
55+
# Docker cache and publish it
56+
with:
57+
context: .
58+
push: true
59+
tags: ${{ steps.meta.outputs.tags }}
60+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/_docs.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
on:
2+
workflow_call:
3+
4+
jobs:
5+
build:
6+
runs-on: ubuntu-latest
7+
8+
steps:
9+
- name: Avoid git conflicts when tag and branch pushed at same time
10+
if: github.ref_type == 'tag'
11+
run: sleep 60
12+
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
with:
16+
# Need this to get version number from last tag
17+
fetch-depth: 0
18+
19+
- name: Install system packages
20+
run: sudo apt-get install graphviz
21+
22+
- name: Install python packages
23+
uses: ./.github/actions/install_requirements
24+
25+
- name: Build docs
26+
run: tox -e docs
27+
28+
- name: Remove environment.pickle
29+
run: rm build/html/.doctrees/environment.pickle
30+
31+
- name: Upload built docs artifact
32+
uses: actions/upload-artifact@v4
33+
with:
34+
name: docs
35+
path: build
36+
37+
- name: Sanitize ref name for docs version
38+
run: echo "DOCS_VERSION=${GITHUB_REF_NAME//[^A-Za-z0-9._-]/_}" >> $GITHUB_ENV
39+
40+
- name: Move to versioned directory
41+
run: mv build/html .github/pages/$DOCS_VERSION
42+
43+
- name: Write switcher.json
44+
run: python .github/pages/make_switcher.py --add $DOCS_VERSION ${{ github.repository }} .github/pages/switcher.json
45+
46+
- name: Publish Docs to gh-pages
47+
if: github.ref_type == 'tag' || github.ref_name == 'main'
48+
# We pin to the SHA, not the tag, for security reasons.
49+
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
50+
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
51+
with:
52+
github_token: ${{ secrets.GITHUB_TOKEN }}
53+
publish_dir: .github/pages
54+
keep_files: true

0 commit comments

Comments
 (0)