-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from DiamondLightSource/copier-template
Copier template
- Loading branch information
Showing
155 changed files
with
1,738 additions
and
2,766 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Changes here will be overwritten by Copier | ||
_commit: 1.0.2-87-g16b7b0e | ||
_src_path: gh:DiamondLightSource/python-copier-template | ||
author_email: giles.knap@diamond.ac.uk | ||
author_name: Giles Knap | ||
component_owner: group:default/sscc | ||
description: GUI for low level control and monitoring of turbo pmac and power pmac | ||
motion controllers | ||
distribution_name: dls-pmac-control | ||
docker: true | ||
docs_type: sphinx | ||
git_platform: github.com | ||
github_org: DiamondLightSource | ||
package_name: dls_pmac_control | ||
repo_name: dls-pmac-control |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,46 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: | ||
// https://github.com/microsoft/vscode-dev-containers/tree/v0.231.6/containers/python-3 | ||
// For format details, see https://containers.dev/implementors/json_reference/ | ||
{ | ||
"name": "Python 3", | ||
"name": "Python 3 Developer Container", | ||
"build": { | ||
"dockerfile": "Dockerfile", | ||
"target": "developer", | ||
"context": "..", | ||
"args": {} | ||
"dockerfile": "../Dockerfile", | ||
"target": "developer" | ||
}, | ||
"remoteEnv": { | ||
// Allow X11 apps to run inside the container | ||
"DISPLAY": "${localEnv:DISPLAY}" | ||
}, | ||
// Set *default* container specific settings.json values on container create. | ||
"settings": { | ||
"python.defaultInterpreterPath": "/usr/local/bin/python", | ||
"python.linting.enabled": true, | ||
"python.linting.pylintEnabled": true, | ||
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8", | ||
"python.formatting.blackPath": "/usr/local/py-utils/bin/black", | ||
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf", | ||
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit", | ||
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8", | ||
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy", | ||
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle", | ||
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle", | ||
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint" | ||
"customizations": { | ||
"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", | ||
"charliermarsh.ruff", | ||
"ms-azuretools.vscode-docker" | ||
] | ||
} | ||
}, | ||
// Add the IDs of extensions you want installed when the container is created. | ||
"extensions": [ | ||
"ms-python.python", | ||
"ms-python.vscode-pylance", | ||
"streetsidesoftware.code-spell-checker", | ||
"ryanluker.vscode-coverage-gutters", | ||
"mhutchie.git-graph", | ||
"eamodio.gitlens", | ||
"gruntfuggly.todo-tree", | ||
"redhat.vscode-yaml", | ||
"nsd.vscode-epics", | ||
"alefragnani.bookmarks" | ||
], | ||
"features": { | ||
//"docker-from-docker": "20.10", | ||
"git": "os-provided" | ||
// Some default things like git config | ||
"ghcr.io/devcontainers/features/common-utils:2": { | ||
"upgradePackages": false | ||
} | ||
}, | ||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. | ||
// "remoteUser": "vscode", | ||
// Make sure the files we are mapping into the container exist on the host | ||
"initializeCommand": "bash -c 'for i in $HOME/.inputrc $HOME/.bashrc_dev; do [ -f $i ] || touch $i; done'", | ||
"runArgs": [ | ||
"--privileged", | ||
// Allow the container to access the host X11 display and EPICS CA | ||
"--net=host", | ||
"-v=${localEnv:HOME}/.ssh:/root/.ssh", | ||
"-v=${localEnv:HOME}/.bashrc_dev:/root/.bashrc", | ||
"-v=${localEnv:HOME}/.inputrc:/root/.inputrc" | ||
], | ||
"mounts": [ | ||
// map in home directory - not strictly necessary but may be 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" | ||
], | ||
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind", | ||
"workspaceFolder": "/workspace", | ||
// 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 | ||
// This installs into the system python of the container | ||
"postCreateCommand": "pip install $([ -f requirements_dev.txt ] && echo -r requirements_dev.txt ) -e .[dev]" | ||
"postCreateCommand": "pip install $([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e '.[dev]' && pre-commit install" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Dockerfile | ||
README.md | ||
tests\** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/DiamondLightSource/dls-pmac-control/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/DiamondLightSource/dls-pmac-control/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. | ||
The template's [Developer Guide](https://diamondlightsource.github.io/python-copier-template) contains detailed information on setting up a development environment, running the tests and what standards the code and documentation | ||
should follow. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Install requirements | ||
description: Install a version of python then call pip install and report what was installed | ||
inputs: | ||
python-version: | ||
description: Python version to install, default is from Dockerfile | ||
default: "dev" | ||
pip-install: | ||
description: Parameters to pass to pip install | ||
default: "$([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e .[dev]" | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Get version of python | ||
run: | | ||
PYTHON_VERSION="${{ inputs.python-version }}" | ||
if [ $PYTHON_VERSION == "dev" ]; then | ||
PYTHON_VERSION=$(sed -n "s/ARG PYTHON_VERSION=//p" Dockerfile) | ||
fi | ||
echo "PYTHON_VERSION=$PYTHON_VERSION" >> "$GITHUB_ENV" | ||
shell: bash | ||
|
||
- name: Setup python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
|
||
- name: Install packages | ||
run: pip install ${{ inputs.pip-install }} | ||
shell: bash | ||
|
||
- name: Report what was installed | ||
run: pip freeze | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import json | ||
import logging | ||
from argparse import ArgumentParser | ||
from pathlib import Path | ||
from subprocess import CalledProcessError, check_output | ||
from typing import Optional | ||
|
||
|
||
def report_output(stdout: bytes, label: str) -> list[str]: | ||
ret = stdout.decode().strip().split("\n") | ||
print(f"{label}: {ret}") | ||
return ret | ||
|
||
|
||
def get_branch_contents(ref: str) -> list[str]: | ||
"""Get the list of directories in a branch.""" | ||
stdout = check_output(["git", "ls-tree", "-d", "--name-only", ref]) | ||
return report_output(stdout, "Branch contents") | ||
|
||
|
||
def get_sorted_tags_list() -> list[str]: | ||
"""Get a list of sorted tags in descending order from the repository.""" | ||
stdout = check_output(["git", "tag", "-l", "--sort=-v:refname"]) | ||
return report_output(stdout, "Tags list") | ||
|
||
|
||
def get_versions(ref: str, add: Optional[str]) -> list[str]: | ||
"""Generate the file containing the list of all GitHub Pages builds.""" | ||
# Get the directories (i.e. builds) from the GitHub Pages branch | ||
try: | ||
builds = set(get_branch_contents(ref)) | ||
except CalledProcessError: | ||
builds = set() | ||
logging.warning(f"Cannot get {ref} contents") | ||
|
||
# Add and remove from the list of builds | ||
if add: | ||
builds.add(add) | ||
|
||
# Get a sorted list of tags | ||
tags = get_sorted_tags_list() | ||
|
||
# Make the sorted versions list from main branches and tags | ||
versions: list[str] = [] | ||
for version in ["master", "main"] + tags: | ||
if version in builds: | ||
versions.append(version) | ||
builds.remove(version) | ||
|
||
# Add in anything that is left to the bottom | ||
versions += sorted(builds) | ||
print(f"Sorted versions: {versions}") | ||
return versions | ||
|
||
|
||
def write_json(path: Path, repository: str, versions: str): | ||
org, repo_name = repository.split("/") | ||
struct = [ | ||
{"version": version, "url": f"https://{org}.github.io/{repo_name}/{version}/"} | ||
for version in versions | ||
] | ||
text = json.dumps(struct, indent=2) | ||
print(f"JSON switcher:\n{text}") | ||
path.write_text(text, encoding="utf-8") | ||
|
||
|
||
def main(args=None): | ||
parser = ArgumentParser( | ||
description="Make a versions.json file from gh-pages directories" | ||
) | ||
parser.add_argument( | ||
"--add", | ||
help="Add this directory to the list of existing directories", | ||
) | ||
parser.add_argument( | ||
"repository", | ||
help="The GitHub org and repository name: ORG/REPO", | ||
) | ||
parser.add_argument( | ||
"output", | ||
type=Path, | ||
help="Path of write switcher.json to", | ||
) | ||
args = parser.parse_args(args) | ||
|
||
# Write the versions file | ||
versions = get_versions("origin/gh-pages", args.add) | ||
write_json(args.output, args.repository, versions) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.