mx-bluesky 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mx_bluesky-0.0.1/.devcontainer/Dockerfile +37 -0
- mx_bluesky-0.0.1/.devcontainer/devcontainer.json +47 -0
- mx_bluesky-0.0.1/.github/CONTRIBUTING.rst +35 -0
- mx_bluesky-0.0.1/.github/actions/install_requirements/action.yml +58 -0
- mx_bluesky-0.0.1/.github/dependabot.yml +16 -0
- mx_bluesky-0.0.1/.github/pages/index.html +11 -0
- mx_bluesky-0.0.1/.github/pages/make_switcher.py +99 -0
- mx_bluesky-0.0.1/.github/workflows/code.yml +205 -0
- mx_bluesky-0.0.1/.github/workflows/docs.yml +54 -0
- mx_bluesky-0.0.1/.github/workflows/docs_clean.yml +43 -0
- mx_bluesky-0.0.1/.github/workflows/linkcheck.yml +30 -0
- mx_bluesky-0.0.1/.gitignore +87 -0
- mx_bluesky-0.0.1/.pre-commit-config.yaml +35 -0
- mx_bluesky-0.0.1/.vscode/extensions.json +10 -0
- mx_bluesky-0.0.1/.vscode/launch.json +25 -0
- mx_bluesky-0.0.1/.vscode/mx-bluesky.code-workspace +19 -0
- mx_bluesky-0.0.1/.vscode/settings.json +21 -0
- mx_bluesky-0.0.1/.vscode/tasks.json +16 -0
- mx_bluesky-0.0.1/LICENSE +201 -0
- mx_bluesky-0.0.1/PKG-INFO +289 -0
- mx_bluesky-0.0.1/README.rst +50 -0
- mx_bluesky-0.0.1/deploy/deploy_edm_for_ssx.sh +51 -0
- mx_bluesky-0.0.1/dls_dev_setup.sh +22 -0
- mx_bluesky-0.0.1/docs/conf.py +186 -0
- mx_bluesky-0.0.1/docs/developer/explanations/decisions/0001-record-architecture-decisions.rst +26 -0
- mx_bluesky-0.0.1/docs/developer/explanations/decisions.rst +17 -0
- mx_bluesky-0.0.1/docs/developer/how-to/build-docs.rst +38 -0
- mx_bluesky-0.0.1/docs/developer/how-to/contribute.rst +1 -0
- mx_bluesky-0.0.1/docs/developer/how-to/lint.rst +34 -0
- mx_bluesky-0.0.1/docs/developer/how-to/make-release.rst +16 -0
- mx_bluesky-0.0.1/docs/developer/how-to/run-tests.rst +12 -0
- mx_bluesky-0.0.1/docs/developer/how-to/static-analysis.rst +8 -0
- mx_bluesky-0.0.1/docs/developer/how-to/update-tools.rst +16 -0
- mx_bluesky-0.0.1/docs/developer/index.rst +62 -0
- mx_bluesky-0.0.1/docs/developer/reference/standards.rst +63 -0
- mx_bluesky-0.0.1/docs/developer/tutorials/dev-install.rst +60 -0
- mx_bluesky-0.0.1/docs/genindex.rst +5 -0
- mx_bluesky-0.0.1/docs/images/dls-favicon.ico +0 -0
- mx_bluesky-0.0.1/docs/images/dls-logo.svg +11 -0
- mx_bluesky-0.0.1/docs/index.rst +29 -0
- mx_bluesky-0.0.1/docs/user/explanations/docs-structure.rst +18 -0
- mx_bluesky-0.0.1/docs/user/how-to/run-container.rst +15 -0
- mx_bluesky-0.0.1/docs/user/index.rst +57 -0
- mx_bluesky-0.0.1/docs/user/reference/api.rst +14 -0
- mx_bluesky-0.0.1/docs/user/tutorials/installation.rst +38 -0
- mx_bluesky-0.0.1/pyproject.toml +123 -0
- mx_bluesky-0.0.1/setup.cfg +4 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/__init__.py +0 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/__init__.py +0 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/dcid.py +407 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/extruder/EX-gui-edm/DetStage.edl +139 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/extruder/EX-gui-edm/DiamondExtruder-I24-py3v1.edl +2277 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/extruder/EX-gui-edm/microdrop_alignment.edl +1084 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/extruder/__init__.py +0 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/extruder/i24ssx_Extruder_Collect_py3v2.py +476 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/fixed_target/FT-gui-edm/CustomChip_py3v1.edl +833 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/fixed_target/FT-gui-edm/DetStage.edl +139 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/fixed_target/FT-gui-edm/DiamondChipI24-py3v1.edl +4089 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/fixed_target/FT-gui-edm/ME14E-GeneralPurpose.edl +4960 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/fixed_target/FT-gui-edm/ME14E-motors.edl +1874 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/fixed_target/FT-gui-edm/MappingLite-oxford_py3v1.edl +2667 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/fixed_target/FT-gui-edm/PMAC_Command.edl +103 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/fixed_target/FT-gui-edm/Shutter_Control.edl +108 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/fixed_target/FT-gui-edm/microdrop_alignment.edl +1083 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/fixed_target/FT-gui-edm/nudgechip.edl +1171 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/fixed_target/FT-gui-edm/pumpprobe-py3v1.edl +1561 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/fixed_target/__init__.py +0 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/fixed_target/ft_utils.py +32 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/fixed_target/i24ssx_Chip_Collect_py3v1.py +695 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/fixed_target/i24ssx_Chip_Manager_py3v1.py +1070 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/fixed_target/i24ssx_Chip_Mapping_py3v1.py +167 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/fixed_target/i24ssx_Chip_StartUp_py3v1.py +463 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/fixed_target/i24ssx_moveonclick.py +204 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/log.py +101 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/parameters/__init__.py +5 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/parameters/constants.py +39 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/parameters/fixed_target/cs/cs_maker.json +9 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/parameters/fixed_target/cs/fiducial_1.txt +4 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/parameters/fixed_target/cs/fiducial_2.txt +4 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/parameters/fixed_target/cs/motor_direction.txt +10 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/parameters/fixed_target/litemaps/currentchip.map +81 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/parameters/fixed_target/parameters.txt +13 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/parameters/fixed_target/pvar_files/minichip-oxford.pvar +19 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/parameters/fixed_target/pvar_files/oxford.pvar +85 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/run_serial.py +52 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/run_ssx.sh +28 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/set_visit_directory.sh +51 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/setup_beamline/__init__.py +14 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/setup_beamline/ca.py +54 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/setup_beamline/pv.py +470 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/setup_beamline/pv_abstract.py +72 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/setup_beamline/setup_beamline.py +672 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/setup_beamline/setup_detector.py +100 -0
- mx_bluesky-0.0.1/src/mx_bluesky/I24/serial/write_nexus.py +113 -0
- mx_bluesky-0.0.1/src/mx_bluesky/__init__.py +6 -0
- mx_bluesky-0.0.1/src/mx_bluesky/__main__.py +20 -0
- mx_bluesky-0.0.1/src/mx_bluesky/_version.py +4 -0
- mx_bluesky-0.0.1/src/mx_bluesky/example.py +19 -0
- mx_bluesky-0.0.1/src/mx_bluesky/jupyter_example.ipynb +73 -0
- mx_bluesky-0.0.1/src/mx_bluesky.egg-info/PKG-INFO +289 -0
- mx_bluesky-0.0.1/src/mx_bluesky.egg-info/SOURCES.txt +118 -0
- mx_bluesky-0.0.1/src/mx_bluesky.egg-info/dependency_links.txt +1 -0
- mx_bluesky-0.0.1/src/mx_bluesky.egg-info/entry_points.txt +4 -0
- mx_bluesky-0.0.1/src/mx_bluesky.egg-info/requires.txt +23 -0
- mx_bluesky-0.0.1/src/mx_bluesky.egg-info/top_level.txt +1 -0
- mx_bluesky-0.0.1/start_jupyter.sh +2 -0
- mx_bluesky-0.0.1/tests/I24/serial/extruder/test_extruder_collect.py +105 -0
- mx_bluesky-0.0.1/tests/I24/serial/fixed_target/__init__.py +0 -0
- mx_bluesky-0.0.1/tests/I24/serial/fixed_target/test_chip_manager.py +189 -0
- mx_bluesky-0.0.1/tests/I24/serial/fixed_target/test_chip_startup.py +81 -0
- mx_bluesky-0.0.1/tests/I24/serial/fixed_target/test_ft_collect.py +100 -0
- mx_bluesky-0.0.1/tests/I24/serial/fixed_target/test_moveonclick.py +50 -0
- mx_bluesky-0.0.1/tests/I24/serial/setup_beamline/test_pv_abstract.py +11 -0
- mx_bluesky-0.0.1/tests/I24/serial/setup_beamline/test_setup_beamline.py +78 -0
- mx_bluesky-0.0.1/tests/I24/serial/setup_beamline/test_setup_detector.py +58 -0
- mx_bluesky-0.0.1/tests/I24/serial/test_dcid.py +30 -0
- mx_bluesky-0.0.1/tests/I24/serial/test_log.py +46 -0
- mx_bluesky-0.0.1/tests/__init__.py +0 -0
- mx_bluesky-0.0.1/tests/test_cli.py +9 -0
- mx_bluesky-0.0.1/tests/test_example.py +16 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# This file is for use as a devcontainer and a runtime container
|
|
2
|
+
#
|
|
3
|
+
# The devcontainer should use the build target and run as root with podman
|
|
4
|
+
# or docker with user namespaces.
|
|
5
|
+
#
|
|
6
|
+
FROM python:3.11 as build
|
|
7
|
+
|
|
8
|
+
ARG PIP_OPTIONS
|
|
9
|
+
|
|
10
|
+
# Add any system dependencies for the developer/build environment here e.g.
|
|
11
|
+
# RUN apt-get update && apt-get upgrade -y && \
|
|
12
|
+
# apt-get install -y --no-install-recommends \
|
|
13
|
+
# desired-packages \
|
|
14
|
+
# && rm -rf /var/lib/apt/lists/*
|
|
15
|
+
|
|
16
|
+
# set up a virtual environment and put it in PATH
|
|
17
|
+
RUN python -m venv /venv
|
|
18
|
+
ENV PATH=/venv/bin:$PATH
|
|
19
|
+
|
|
20
|
+
# Copy any required context for the pip install over
|
|
21
|
+
COPY . /context
|
|
22
|
+
WORKDIR /context
|
|
23
|
+
|
|
24
|
+
# install python package into /venv
|
|
25
|
+
RUN pip install ${PIP_OPTIONS}
|
|
26
|
+
|
|
27
|
+
FROM python:3.11-slim as runtime
|
|
28
|
+
|
|
29
|
+
# Add apt-get system dependecies for runtime here if needed
|
|
30
|
+
|
|
31
|
+
# copy the virtual environment from the build stage and put it in PATH
|
|
32
|
+
COPY --from=build /venv/ /venv/
|
|
33
|
+
ENV PATH=/venv/bin:$PATH
|
|
34
|
+
|
|
35
|
+
# change this entrypoint if it is not the same as the repo
|
|
36
|
+
ENTRYPOINT ["mx_bluesky"]
|
|
37
|
+
CMD ["--version"]
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// For format details, see https://aka.ms/devcontainer.json
|
|
2
|
+
{
|
|
3
|
+
"name": "Python 3 Developer Container",
|
|
4
|
+
"build": {
|
|
5
|
+
"dockerfile": "Dockerfile",
|
|
6
|
+
"target": "build",
|
|
7
|
+
// Only upgrade pip, we will install the project below
|
|
8
|
+
"args": {
|
|
9
|
+
"PIP_OPTIONS": "--upgrade pip"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"remoteEnv": {
|
|
13
|
+
"DISPLAY": "${localEnv:DISPLAY}"
|
|
14
|
+
},
|
|
15
|
+
// Set *default* container specific settings.json values on container create.
|
|
16
|
+
"settings": {
|
|
17
|
+
"python.defaultInterpreterPath": "/venv/bin/python"
|
|
18
|
+
},
|
|
19
|
+
"customizations": {
|
|
20
|
+
"vscode": {
|
|
21
|
+
// Add the IDs of extensions you want installed when the container is created.
|
|
22
|
+
"extensions": [
|
|
23
|
+
"ms-python.python",
|
|
24
|
+
"tamasfe.even-better-toml",
|
|
25
|
+
"redhat.vscode-yaml",
|
|
26
|
+
"ryanluker.vscode-coverage-gutters"
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
// Make sure the files we are mapping into the container exist on the host
|
|
31
|
+
"initializeCommand": "bash -c 'for i in $HOME/.inputrc; do [ -f $i ] || touch $i; done'",
|
|
32
|
+
"runArgs": [
|
|
33
|
+
"--net=host",
|
|
34
|
+
"--security-opt=label=type:container_runtime_t"
|
|
35
|
+
],
|
|
36
|
+
"mounts": [
|
|
37
|
+
"source=${localEnv:HOME}/.ssh,target=/root/.ssh,type=bind",
|
|
38
|
+
"source=${localEnv:HOME}/.inputrc,target=/root/.inputrc,type=bind",
|
|
39
|
+
// map in home directory - not strictly necessary but useful
|
|
40
|
+
"source=${localEnv:HOME},target=${localEnv:HOME},type=bind,consistency=cached"
|
|
41
|
+
],
|
|
42
|
+
// make the workspace folder the same inside and outside of the container
|
|
43
|
+
"workspaceMount": "source=${localWorkspaceFolder},target=${localWorkspaceFolder},type=bind",
|
|
44
|
+
"workspaceFolder": "${localWorkspaceFolder}",
|
|
45
|
+
// After the container is created, install the python project in editable form
|
|
46
|
+
"postCreateCommand": "pip install -e .[dev]"
|
|
47
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Contributing to the project
|
|
2
|
+
===========================
|
|
3
|
+
|
|
4
|
+
Contributions and issues are most welcome! All issues and pull requests are
|
|
5
|
+
handled through GitHub_. Also, please check for any existing issues before
|
|
6
|
+
filing a new one. If you have a great idea but it involves big changes, please
|
|
7
|
+
file a ticket before making a pull request! We want to make sure you don't spend
|
|
8
|
+
your time coding something that might not fit the scope of the project.
|
|
9
|
+
|
|
10
|
+
.. _GitHub: https://github.com/DiamondLightSource/mx_bluesky/issues
|
|
11
|
+
|
|
12
|
+
Issue or Discussion?
|
|
13
|
+
--------------------
|
|
14
|
+
|
|
15
|
+
Github also offers discussions_ as a place to ask questions and share ideas. If
|
|
16
|
+
your issue is open ended and it is not obvious when it can be "closed", please
|
|
17
|
+
raise it as a discussion instead.
|
|
18
|
+
|
|
19
|
+
.. _discussions: https://github.com/DiamondLightSource/mx_bluesky/discussions
|
|
20
|
+
|
|
21
|
+
Code coverage
|
|
22
|
+
-------------
|
|
23
|
+
|
|
24
|
+
While 100% code coverage does not make a library bug-free, it significantly
|
|
25
|
+
reduces the number of easily caught bugs! Please make sure coverage remains the
|
|
26
|
+
same or is improved by a pull request!
|
|
27
|
+
|
|
28
|
+
Developer guide
|
|
29
|
+
---------------
|
|
30
|
+
|
|
31
|
+
The `Developer Guide`_ contains information on setting up a development
|
|
32
|
+
environment, running the tests and what standards the code and documentation
|
|
33
|
+
should follow.
|
|
34
|
+
|
|
35
|
+
.. _Developer Guide: https://diamondlightsource.github.io/mx_bluesky/main/developer/how-to/contribute.html
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
name: Install requirements
|
|
2
|
+
description: Run pip install with requirements and upload resulting requirements
|
|
3
|
+
inputs:
|
|
4
|
+
requirements_file:
|
|
5
|
+
description: Name of requirements file to use and upload
|
|
6
|
+
required: true
|
|
7
|
+
install_options:
|
|
8
|
+
description: Parameters to pass to pip install
|
|
9
|
+
required: true
|
|
10
|
+
python_version:
|
|
11
|
+
description: Python version to install
|
|
12
|
+
default: "3.x"
|
|
13
|
+
|
|
14
|
+
runs:
|
|
15
|
+
using: composite
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- name: Setup python
|
|
19
|
+
uses: actions/setup-python@v4
|
|
20
|
+
with:
|
|
21
|
+
python-version: ${{ inputs.python_version }}
|
|
22
|
+
|
|
23
|
+
- name: Pip install
|
|
24
|
+
run: |
|
|
25
|
+
touch ${{ inputs.requirements_file }}
|
|
26
|
+
# -c uses requirements.txt as constraints, see 'Validate requirements file'
|
|
27
|
+
pip install -c ${{ inputs.requirements_file }} ${{ inputs.install_options }}
|
|
28
|
+
shell: bash
|
|
29
|
+
|
|
30
|
+
- name: Create lockfile
|
|
31
|
+
run: |
|
|
32
|
+
mkdir -p lockfiles
|
|
33
|
+
pip freeze --exclude-editable > lockfiles/${{ inputs.requirements_file }}
|
|
34
|
+
# delete the self referencing line and make sure it isn't blank
|
|
35
|
+
sed -i '/file:/d' lockfiles/${{ inputs.requirements_file }}
|
|
36
|
+
shell: bash
|
|
37
|
+
|
|
38
|
+
- name: Upload lockfiles
|
|
39
|
+
uses: actions/upload-artifact@v3
|
|
40
|
+
with:
|
|
41
|
+
name: lockfiles
|
|
42
|
+
path: lockfiles
|
|
43
|
+
|
|
44
|
+
# This eliminates the class of problems where the requirements being given no
|
|
45
|
+
# longer match what the packages themselves dictate. E.g. In the rare instance
|
|
46
|
+
# where I install some-package which used to depend on vulnerable-dependency
|
|
47
|
+
# but now uses good-dependency (despite being nominally the same version)
|
|
48
|
+
# pip will install both if given a requirements file with -r
|
|
49
|
+
- name: If requirements file exists, check it matches pip installed packages
|
|
50
|
+
run: |
|
|
51
|
+
if [ -s ${{ inputs.requirements_file }} ]; then
|
|
52
|
+
if ! diff -u ${{ inputs.requirements_file }} lockfiles/${{ inputs.requirements_file }}; then
|
|
53
|
+
echo "Error: ${{ inputs.requirements_file }} need the above changes to be exhaustive"
|
|
54
|
+
exit 1
|
|
55
|
+
fi
|
|
56
|
+
fi
|
|
57
|
+
shell: bash
|
|
58
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
|
3
|
+
# Please see the documentation for all configuration options:
|
|
4
|
+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
5
|
+
|
|
6
|
+
version: 2
|
|
7
|
+
updates:
|
|
8
|
+
- package-ecosystem: "github-actions"
|
|
9
|
+
directory: "/"
|
|
10
|
+
schedule:
|
|
11
|
+
interval: "weekly"
|
|
12
|
+
|
|
13
|
+
- package-ecosystem: "pip"
|
|
14
|
+
directory: "/"
|
|
15
|
+
schedule:
|
|
16
|
+
interval: "weekly"
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import logging
|
|
3
|
+
from argparse import ArgumentParser
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from subprocess import CalledProcessError, check_output
|
|
6
|
+
from typing import List, Optional
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def report_output(stdout: bytes, label: str) -> List[str]:
|
|
10
|
+
ret = stdout.decode().strip().split("\n")
|
|
11
|
+
print(f"{label}: {ret}")
|
|
12
|
+
return ret
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def get_branch_contents(ref: str) -> List[str]:
|
|
16
|
+
"""Get the list of directories in a branch."""
|
|
17
|
+
stdout = check_output(["git", "ls-tree", "-d", "--name-only", ref])
|
|
18
|
+
return report_output(stdout, "Branch contents")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def get_sorted_tags_list() -> List[str]:
|
|
22
|
+
"""Get a list of sorted tags in descending order from the repository."""
|
|
23
|
+
stdout = check_output(["git", "tag", "-l", "--sort=-v:refname"])
|
|
24
|
+
return report_output(stdout, "Tags list")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def get_versions(ref: str, add: Optional[str], remove: Optional[str]) -> List[str]:
|
|
28
|
+
"""Generate the file containing the list of all GitHub Pages builds."""
|
|
29
|
+
# Get the directories (i.e. builds) from the GitHub Pages branch
|
|
30
|
+
try:
|
|
31
|
+
builds = set(get_branch_contents(ref))
|
|
32
|
+
except CalledProcessError:
|
|
33
|
+
builds = set()
|
|
34
|
+
logging.warning(f"Cannot get {ref} contents")
|
|
35
|
+
|
|
36
|
+
# Add and remove from the list of builds
|
|
37
|
+
if add:
|
|
38
|
+
builds.add(add)
|
|
39
|
+
if remove:
|
|
40
|
+
assert remove in builds, f"Build '{remove}' not in {sorted(builds)}"
|
|
41
|
+
builds.remove(remove)
|
|
42
|
+
|
|
43
|
+
# Get a sorted list of tags
|
|
44
|
+
tags = get_sorted_tags_list()
|
|
45
|
+
|
|
46
|
+
# Make the sorted versions list from main branches and tags
|
|
47
|
+
versions: List[str] = []
|
|
48
|
+
for version in ["master", "main"] + tags:
|
|
49
|
+
if version in builds:
|
|
50
|
+
versions.append(version)
|
|
51
|
+
builds.remove(version)
|
|
52
|
+
|
|
53
|
+
# Add in anything that is left to the bottom
|
|
54
|
+
versions += sorted(builds)
|
|
55
|
+
print(f"Sorted versions: {versions}")
|
|
56
|
+
return versions
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def write_json(path: Path, repository: str, versions: str):
|
|
60
|
+
org, repo_name = repository.split("/")
|
|
61
|
+
struct = [
|
|
62
|
+
{"version": version, "url": f"https://{org}.github.io/{repo_name}/{version}/"}
|
|
63
|
+
for version in versions
|
|
64
|
+
]
|
|
65
|
+
text = json.dumps(struct, indent=2)
|
|
66
|
+
print(f"JSON switcher:\n{text}")
|
|
67
|
+
path.write_text(text)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def main(args=None):
|
|
71
|
+
parser = ArgumentParser(
|
|
72
|
+
description="Make a versions.txt file from gh-pages directories"
|
|
73
|
+
)
|
|
74
|
+
parser.add_argument(
|
|
75
|
+
"--add",
|
|
76
|
+
help="Add this directory to the list of existing directories",
|
|
77
|
+
)
|
|
78
|
+
parser.add_argument(
|
|
79
|
+
"--remove",
|
|
80
|
+
help="Remove this directory from the list of existing directories",
|
|
81
|
+
)
|
|
82
|
+
parser.add_argument(
|
|
83
|
+
"repository",
|
|
84
|
+
help="The GitHub org and repository name: ORG/REPO",
|
|
85
|
+
)
|
|
86
|
+
parser.add_argument(
|
|
87
|
+
"output",
|
|
88
|
+
type=Path,
|
|
89
|
+
help="Path of write switcher.json to",
|
|
90
|
+
)
|
|
91
|
+
args = parser.parse_args(args)
|
|
92
|
+
|
|
93
|
+
# Write the versions file
|
|
94
|
+
versions = get_versions("origin/gh-pages", args.add, args.remove)
|
|
95
|
+
write_json(args.output, args.repository, versions)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
if __name__ == "__main__":
|
|
99
|
+
main()
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
name: Code CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
schedule:
|
|
7
|
+
# Run weekly to check latest versions of dependencies
|
|
8
|
+
- cron: "0 8 * * WED"
|
|
9
|
+
env:
|
|
10
|
+
# The target python version, which must match the Dockerfile version
|
|
11
|
+
CONTAINER_PYTHON: "3.11"
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
lint:
|
|
15
|
+
# pull requests are a duplicate of a branch push if within the same repo.
|
|
16
|
+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- name: Checkout
|
|
21
|
+
uses: actions/checkout@v3
|
|
22
|
+
|
|
23
|
+
- name: Install python packages
|
|
24
|
+
uses: ./.github/actions/install_requirements
|
|
25
|
+
with:
|
|
26
|
+
requirements_file: requirements-dev-3.x.txt
|
|
27
|
+
install_options: -e .[dev]
|
|
28
|
+
python_version: "3.11"
|
|
29
|
+
|
|
30
|
+
- name: Lint
|
|
31
|
+
run: tox -e pre-commit,mypy
|
|
32
|
+
|
|
33
|
+
test:
|
|
34
|
+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
|
|
35
|
+
strategy:
|
|
36
|
+
fail-fast: false
|
|
37
|
+
matrix:
|
|
38
|
+
os: ["ubuntu-latest"] # can add windows-latest, macos-latest
|
|
39
|
+
python: ["3.10", "3.11"]
|
|
40
|
+
install: ["-e .[dev]"]
|
|
41
|
+
# Make one version be non-editable to test both paths of version code
|
|
42
|
+
include:
|
|
43
|
+
- os: "ubuntu-latest"
|
|
44
|
+
python: "3.9"
|
|
45
|
+
install: ".[dev]"
|
|
46
|
+
|
|
47
|
+
runs-on: ${{ matrix.os }}
|
|
48
|
+
env:
|
|
49
|
+
# https://github.com/pytest-dev/pytest/issues/2042
|
|
50
|
+
PY_IGNORE_IMPORTMISMATCH: "1"
|
|
51
|
+
|
|
52
|
+
steps:
|
|
53
|
+
- name: Checkout
|
|
54
|
+
uses: actions/checkout@v3
|
|
55
|
+
with:
|
|
56
|
+
# Need this to get version number from last tag
|
|
57
|
+
fetch-depth: 0
|
|
58
|
+
|
|
59
|
+
- name: Install python packages
|
|
60
|
+
uses: ./.github/actions/install_requirements
|
|
61
|
+
with:
|
|
62
|
+
python_version: ${{ matrix.python }}
|
|
63
|
+
requirements_file: requirements-test-${{ matrix.os }}-${{ matrix.python }}.txt
|
|
64
|
+
install_options: ${{ matrix.install }}
|
|
65
|
+
|
|
66
|
+
- name: List dependency tree
|
|
67
|
+
run: pipdeptree
|
|
68
|
+
|
|
69
|
+
- name: Run tests
|
|
70
|
+
run: pytest
|
|
71
|
+
|
|
72
|
+
- name: Upload coverage to Codecov
|
|
73
|
+
uses: codecov/codecov-action@v3
|
|
74
|
+
with:
|
|
75
|
+
name: ${{ matrix.python }}/${{ matrix.os }}
|
|
76
|
+
files: cov.xml
|
|
77
|
+
|
|
78
|
+
dist:
|
|
79
|
+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
|
|
80
|
+
runs-on: "ubuntu-latest"
|
|
81
|
+
|
|
82
|
+
steps:
|
|
83
|
+
- name: Checkout
|
|
84
|
+
uses: actions/checkout@v3
|
|
85
|
+
with:
|
|
86
|
+
# Need this to get version number from last tag
|
|
87
|
+
fetch-depth: 0
|
|
88
|
+
|
|
89
|
+
- name: Build sdist and wheel
|
|
90
|
+
run: |
|
|
91
|
+
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) && \
|
|
92
|
+
pipx run build
|
|
93
|
+
|
|
94
|
+
- name: Upload sdist and wheel as artifacts
|
|
95
|
+
uses: actions/upload-artifact@v3
|
|
96
|
+
with:
|
|
97
|
+
name: dist
|
|
98
|
+
path: dist
|
|
99
|
+
|
|
100
|
+
- name: Check for packaging errors
|
|
101
|
+
run: pipx run twine check --strict dist/*
|
|
102
|
+
|
|
103
|
+
- name: Install python packages
|
|
104
|
+
uses: ./.github/actions/install_requirements
|
|
105
|
+
with:
|
|
106
|
+
python_version: ${{env.CONTAINER_PYTHON}}
|
|
107
|
+
requirements_file: requirements.txt
|
|
108
|
+
install_options: dist/*.whl
|
|
109
|
+
|
|
110
|
+
- name: Test module --version works using the installed wheel
|
|
111
|
+
# If more than one module in src/ replace with module name to test
|
|
112
|
+
run: python -m $(ls src | head -1) --version
|
|
113
|
+
|
|
114
|
+
container:
|
|
115
|
+
needs: [lint, dist, test]
|
|
116
|
+
runs-on: ubuntu-latest
|
|
117
|
+
|
|
118
|
+
permissions:
|
|
119
|
+
contents: read
|
|
120
|
+
packages: write
|
|
121
|
+
|
|
122
|
+
steps:
|
|
123
|
+
- name: Checkout
|
|
124
|
+
uses: actions/checkout@v3
|
|
125
|
+
|
|
126
|
+
# image names must be all lower case
|
|
127
|
+
- name: Generate image repo name
|
|
128
|
+
run: echo IMAGE_REPOSITORY=ghcr.io/$(tr '[:upper:]' '[:lower:]' <<< "${{ github.repository }}") >> $GITHUB_ENV
|
|
129
|
+
|
|
130
|
+
- name: Download wheel and lockfiles
|
|
131
|
+
uses: actions/download-artifact@v3
|
|
132
|
+
with:
|
|
133
|
+
path: .devcontainer
|
|
134
|
+
|
|
135
|
+
- name: Log in to GitHub Docker Registry
|
|
136
|
+
if: github.event_name != 'pull_request'
|
|
137
|
+
uses: docker/login-action@v2
|
|
138
|
+
with:
|
|
139
|
+
registry: ghcr.io
|
|
140
|
+
username: ${{ github.actor }}
|
|
141
|
+
password: ${{ secrets.GITHUB_TOKEN }}
|
|
142
|
+
|
|
143
|
+
- name: Docker meta
|
|
144
|
+
id: meta
|
|
145
|
+
uses: docker/metadata-action@v4
|
|
146
|
+
with:
|
|
147
|
+
images: ${{ env.IMAGE_REPOSITORY }}
|
|
148
|
+
tags: |
|
|
149
|
+
type=ref,event=tag
|
|
150
|
+
type=raw,value=latest
|
|
151
|
+
|
|
152
|
+
- name: Set up Docker Buildx
|
|
153
|
+
id: buildx
|
|
154
|
+
uses: docker/setup-buildx-action@v2
|
|
155
|
+
|
|
156
|
+
- name: Build runtime image
|
|
157
|
+
uses: docker/build-push-action@v3
|
|
158
|
+
with:
|
|
159
|
+
build-args: |
|
|
160
|
+
PIP_OPTIONS=dist/*.whl
|
|
161
|
+
# PIP_OPTIONS=-r lockfiles/requirements.txt dist/*.whl
|
|
162
|
+
# See issue https://github.com/DiamondLightSource/mx_bluesky/issues/28
|
|
163
|
+
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
|
|
164
|
+
load: ${{ ! (github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) }}
|
|
165
|
+
tags: ${{ steps.meta.outputs.tags }}
|
|
166
|
+
labels: ${{ steps.meta.outputs.labels }}
|
|
167
|
+
context: .devcontainer
|
|
168
|
+
# If you have a long docker build, uncomment the following to turn on caching
|
|
169
|
+
# For short build times this makes it a little slower
|
|
170
|
+
#cache-from: type=gha
|
|
171
|
+
#cache-to: type=gha,mode=max
|
|
172
|
+
|
|
173
|
+
- name: Test cli works in runtime image
|
|
174
|
+
run: docker run ${{ env.IMAGE_REPOSITORY }} --version
|
|
175
|
+
|
|
176
|
+
release:
|
|
177
|
+
# upload to PyPI and make a release on every tag
|
|
178
|
+
needs: [lint, dist, test]
|
|
179
|
+
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
|
|
180
|
+
runs-on: ubuntu-latest
|
|
181
|
+
|
|
182
|
+
steps:
|
|
183
|
+
- uses: actions/download-artifact@v3
|
|
184
|
+
|
|
185
|
+
- name: Fixup blank lockfiles
|
|
186
|
+
# Github release artifacts can't be blank
|
|
187
|
+
run: for f in lockfiles/*; do [ -s $f ] || echo '# No requirements' >> $f; done
|
|
188
|
+
|
|
189
|
+
- name: Github Release
|
|
190
|
+
# We pin to the SHA, not the tag, for security reasons.
|
|
191
|
+
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
|
|
192
|
+
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 # v0.1.14
|
|
193
|
+
with:
|
|
194
|
+
prerelease: ${{ contains(github.ref_name, 'a') || contains(github.ref_name, 'b') || contains(github.ref_name, 'rc') }}
|
|
195
|
+
files: |
|
|
196
|
+
dist/*
|
|
197
|
+
lockfiles/*
|
|
198
|
+
generate_release_notes: true
|
|
199
|
+
env:
|
|
200
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
201
|
+
|
|
202
|
+
- name: Publish to PyPI
|
|
203
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
204
|
+
with:
|
|
205
|
+
password: ${{ secrets.PYPI_TOKEN }}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
name: Docs CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
docs:
|
|
9
|
+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
steps:
|
|
13
|
+
- name: Avoid git conflicts when tag and branch pushed at same time
|
|
14
|
+
if: startsWith(github.ref, 'refs/tags')
|
|
15
|
+
run: sleep 60
|
|
16
|
+
|
|
17
|
+
- name: Checkout
|
|
18
|
+
uses: actions/checkout@v3
|
|
19
|
+
with:
|
|
20
|
+
# Need this to get version number from last tag
|
|
21
|
+
fetch-depth: 0
|
|
22
|
+
|
|
23
|
+
- name: Install system packages
|
|
24
|
+
# Can delete this if you don't use graphviz in your docs
|
|
25
|
+
run: sudo apt-get install graphviz
|
|
26
|
+
|
|
27
|
+
- name: Install python packages
|
|
28
|
+
uses: ./.github/actions/install_requirements
|
|
29
|
+
with:
|
|
30
|
+
requirements_file: requirements-dev-3.x.txt
|
|
31
|
+
install_options: -e .[dev]
|
|
32
|
+
python_version: "3.11"
|
|
33
|
+
|
|
34
|
+
- name: Build docs
|
|
35
|
+
run: tox -e docs
|
|
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.event_name == 'push' && github.actor != 'dependabot[bot]'
|
|
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@de7ea6f8efb354206b205ef54722213d99067935 # v3.9.0
|
|
51
|
+
with:
|
|
52
|
+
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
53
|
+
publish_dir: .github/pages
|
|
54
|
+
keep_files: true
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
name: Docs Cleanup CI
|
|
2
|
+
|
|
3
|
+
# delete branch documentation when a branch is deleted
|
|
4
|
+
# also allow manually deleting a documentation version
|
|
5
|
+
on:
|
|
6
|
+
delete:
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
inputs:
|
|
9
|
+
version:
|
|
10
|
+
description: "documentation version to DELETE"
|
|
11
|
+
required: true
|
|
12
|
+
type: string
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
remove:
|
|
16
|
+
if: github.event.ref_type == 'branch' || github.event_name == 'workflow_dispatch'
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- name: Checkout
|
|
21
|
+
uses: actions/checkout@v3
|
|
22
|
+
with:
|
|
23
|
+
ref: gh-pages
|
|
24
|
+
|
|
25
|
+
- name: removing documentation for branch ${{ github.event.ref }}
|
|
26
|
+
if: ${{ github.event_name != 'workflow_dispatch' }}
|
|
27
|
+
run: echo "REF_NAME=${{ github.event.ref }}" >> $GITHUB_ENV
|
|
28
|
+
|
|
29
|
+
- name: manually removing documentation version ${{ github.event.inputs.version }}
|
|
30
|
+
if: ${{ github.event_name == 'workflow_dispatch' }}
|
|
31
|
+
run: echo "REF_NAME=${{ github.event.inputs.version }}" >> $GITHUB_ENV
|
|
32
|
+
|
|
33
|
+
- name: Sanitize ref name for docs version
|
|
34
|
+
run: echo "DOCS_VERSION=${REF_NAME//[^A-Za-z0-9._-]/_}" >> $GITHUB_ENV
|
|
35
|
+
|
|
36
|
+
- name: update index and push changes
|
|
37
|
+
run: |
|
|
38
|
+
rm -r $DOCS_VERSION
|
|
39
|
+
python make_switcher.py --remove $DOCS_VERSION ${{ github.repository }} switcher.json
|
|
40
|
+
git config --global user.name 'GitHub Actions Docs Cleanup CI'
|
|
41
|
+
git config --global user.email 'GithubActionsCleanup@noreply.github.com'
|
|
42
|
+
git commit -am "Removing redundant docs version $DOCS_VERSION"
|
|
43
|
+
git push
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: Link Check
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
schedule:
|
|
6
|
+
# Run weekly to check URL links still resolve
|
|
7
|
+
- cron: "0 8 * * WED"
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
docs:
|
|
11
|
+
strategy:
|
|
12
|
+
fail-fast: false
|
|
13
|
+
matrix:
|
|
14
|
+
python: ["3.10"]
|
|
15
|
+
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- name: Checkout
|
|
20
|
+
uses: actions/checkout@v3
|
|
21
|
+
|
|
22
|
+
- name: Install python packages
|
|
23
|
+
uses: ./.github/actions/install_requirements
|
|
24
|
+
with:
|
|
25
|
+
requirements_file: requirements-dev-3.x.txt
|
|
26
|
+
install_options: -e .[dev]
|
|
27
|
+
python_version: "3.11"
|
|
28
|
+
|
|
29
|
+
- name: Check links
|
|
30
|
+
run: tox -e docs build -- -b linkcheck
|