Skip to content

Commit

Permalink
Merge pull request #84 from PandABlocks/update_copier_template
Browse files Browse the repository at this point in the history
Update copier template
  • Loading branch information
evalott100 committed Mar 12, 2024
2 parents 2ecafc4 + 188aa10 commit 1af2759
Show file tree
Hide file tree
Showing 76 changed files with 774 additions and 1,324 deletions.
4 changes: 3 additions & 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: 1.0.0-8-g1361223
_commit: 2.0.1
_src_path: gh:DiamondLightSource/python-copier-template
author_email: [email protected]
author_name: Tom Cobb
Expand All @@ -11,4 +11,6 @@ docs_type: sphinx
git_platform: github.com
github_org: PandABlocks
package_name: pandablocks
pypi: true
repo_name: PandABlocks-client
type_checker: mypy
46 changes: 21 additions & 25 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,41 @@
"target": "developer"
},
"remoteEnv": {
// Allow X11 apps to run inside the container
"DISPLAY": "${localEnv:DISPLAY}"
},
// Add the URLs of features you want added when the container is built.
"features": {
"ghcr.io/devcontainers/features/common-utils:1": {
"username": "none",
"upgradePackages": false
}
},
"customizations": {
// Set *default* container specific settings.json values on container create.
"settings": {
"python.defaultInterpreterPath": "/venv/bin/python"
},
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"python.defaultInterpreterPath": "/venv/bin/python"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python",
"github.vscode-github-actions",
"tamasfe.even-better-toml",
"redhat.vscode-yaml",
"ryanluker.vscode-coverage-gutters"
"ryanluker.vscode-coverage-gutters",
"charliermarsh.ruff",
"ms-azuretools.vscode-docker"
]
}
},
// Make sure the files we are mapping into the container exist on the host
"initializeCommand": "bash -c 'for i in $HOME/.inputrc; do [ -f $i ] || touch $i; done'",
"features": {
// Some default things like git config
"ghcr.io/devcontainers/features/common-utils:2": {
"upgradePackages": false
}
},
"runArgs": [
// Allow the container to access the host X11 display and EPICS CA
"--net=host",
"--security-opt=label=type:container_runtime_t"
],
"mounts": [
"source=${localEnv:HOME}/.ssh,target=/root/.ssh,type=bind",
"source=${localEnv:HOME}/.inputrc,target=/root/.inputrc,type=bind",
// map in home directory - not strictly necessary but useful
"source=${localEnv:HOME},target=${localEnv:HOME},type=bind,consistency=cached"
// Make sure SELinux does not disable with access to host filesystems like tmp
"--security-opt=label=disable"
],
// make the workspace folder the same inside and outside of the container
"workspaceMount": "source=${localWorkspaceFolder},target=${localWorkspaceFolder},type=bind",
"workspaceFolder": "${localWorkspaceFolder}",
// 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 -e '.[dev]'"
"postCreateCommand": "pip install $([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e '.[dev]' && pre-commit install"
}
27 changes: 27 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Contribute to the project

Contributions and issues are most welcome! All issues and pull requests are
handled through [GitHub](https://github.com/PandABlocks/PandABlocks-client/issues). Also, please check for any existing issues before
filing a new one. If you have a great idea but it involves big changes, please
file a ticket before making a pull request! We want to make sure you don't spend
your time coding something that might not fit the scope of the project.

## Issue or Discussion?

Github also offers [discussions](https://github.com/PandABlocks/PandABlocks-client/discussions) as a place to ask questions and share ideas. If
your issue is open ended and it is not obvious when it can be "closed", please
raise it as a discussion instead.

## Code Coverage

While 100% code coverage does not make a library bug-free, it significantly
reduces the number of easily caught bugs! Please make sure coverage remains the
same or is improved by a pull request!

## Developer Information

It is recommended that developers use a [vscode devcontainer](https://code.visualstudio.com/docs/devcontainers/containers). This repository contains configuration to set up a containerized development environment that suits its own needs.

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).
78 changes: 0 additions & 78 deletions .github/CONTRIBUTING.rst

This file was deleted.

2 changes: 1 addition & 1 deletion .github/actions/install_requirements/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ inputs:
default: "dev"
pip-install:
description: Parameters to pass to pip install
default: "-e .[dev]"
default: "$([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e .[dev]"

runs:
using: composite
Expand Down
2 changes: 1 addition & 1 deletion .github/pages/make_switcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def get_versions(ref: str, add: Optional[str]) -> List[str]:
def write_json(path: Path, repository: str, versions: str):
org, repo_name = repository.split("/")
struct = [
dict(version=version, url=f"https://{org}.github.io/{repo_name}/{version}/")
{"version": version, "url": f"https://{org}.github.io/{repo_name}/{version}/"}
for version in versions
]
text = json.dumps(struct, indent=2)
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/_check.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
on:
workflow_call:
outputs:
not-in-pr:
branch-pr:
description: The PR number if the branch is in one
value: ${{ jobs.pr.outputs.not-in-pr }}
value: ${{ jobs.pr.outputs.branch-pr }}

jobs:
pr:
runs-on: "ubuntu-latest"
outputs:
not-in-pr: ${{ steps.script.outputs.result }}
branch-pr: ${{ steps.script.outputs.result }}
steps:
- uses: actions/github-script@v7
id: script
Expand All @@ -23,6 +23,5 @@ jobs:
})
if (prs.data.length) {
console.log(`::notice ::Skipping CI on branch push as it is already run in PR #${prs.data[0]["number"]}`)
} else {
return "not-in-pr"
return prs.data[0]["number"]
}
23 changes: 12 additions & 11 deletions .github/workflows/_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Avoid git conflicts when tag and branch pushed at same time
if: github.ref_type == 'tag'
run: sleep 60

- name: Checkout
uses: actions/checkout@v4
with:
Expand All @@ -24,23 +28,20 @@ jobs:
- name: Remove environment.pickle
run: rm build/html/.doctrees/environment.pickle

- name: Sanitize ref name for docs version
run: echo "DOCS_VERSION=${GITHUB_REF_NAME//[^A-Za-z0-9._-]/_}" >> $GITHUB_ENV

- name: Move to versioned directory
run: mv build/html build/$DOCS_VERSION

- name: Upload built docs artifact
uses: actions/upload-artifact@v4
with:
name: docs
path: build

- name: Add other static pages files
run: cp .github/pages/* build
- name: Sanitize ref name for docs version
run: echo "DOCS_VERSION=${GITHUB_REF_NAME//[^A-Za-z0-9._-]/_}" >> $GITHUB_ENV

- name: Move to versioned directory
run: mv build/html .github/pages/$DOCS_VERSION

- name: Write switcher.json
run: python .github/pages/make_switcher.py --add $DOCS_VERSION ${{ github.repository }} build/switcher.json
run: python .github/pages/make_switcher.py --add $DOCS_VERSION ${{ github.repository }} .github/pages/switcher.json

- name: Publish Docs to gh-pages
if: github.ref_type == 'tag' || github.ref_name == 'main'
Expand All @@ -49,5 +50,5 @@ jobs:
uses: peaceiris/actions-gh-pages@373f7f263a76c20808c831209c920827a82a2847 # v3.9.3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: build
keep_files: true
publish_dir: .github/pages
keep_files: true
2 changes: 0 additions & 2 deletions .github/workflows/_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,3 @@ jobs:

- name: Publish to PyPI using trusted publishing
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}
19 changes: 9 additions & 10 deletions .github/workflows/_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ jobs:
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true

- name: Prepare release files
- name: Zip up docs
run: |
if [ -d docs ]; then
cd docs && zip -r docs.zip *
echo 'DOCS=docs/docs.zip' >> $GITHUB_ENV
fi
if [ -d dist ]; then
echo 'DIST=dist/*' >> $GITHUB_ENV
set -vxeuo pipefail
if [ -d html ]; then
mv html $GITHUB_REF_NAME
zip -r docs.zip $GITHUB_REF_NAME
rm -rf $GITHUB_REF_NAME
fi
- name: Create GitHub Release
Expand All @@ -25,9 +26,7 @@ jobs:
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
with:
prerelease: ${{ contains(github.ref_name, 'a') || contains(github.ref_name, 'b') || contains(github.ref_name, 'rc') }}
files: |
${{ env.DOCS }}
${{ env.DIST }}
files: "*"
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20 changes: 18 additions & 2 deletions .github/workflows/_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
type: string
description: The runner to run this job on
required: true
secrets:
CODECOV_TOKEN:
required: true

env:
# https://github.com/pytest-dev/pytest/issues/2042
Expand All @@ -29,6 +32,17 @@ jobs:
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

- 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
Expand All @@ -37,10 +51,12 @@ jobs:
pip-install: ".[dev]"

- name: Run tests
run: tox -e pytest
run: tox -e tests

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
name: ${{ inputs.python-version }}/${{ inputs.runs-on }}
files: cov.xml
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
Loading

0 comments on commit 1af2759

Please sign in to comment.