Skip to content
This repository was archived by the owner on Mar 13, 2024. It is now read-only.

Commit 2932aa9

Browse files
authored
Merge pull request #62 from DiamondLightSource/dev
Architectural Decisions Records
2 parents 0da9c5a + 613d09c commit 2932aa9

22 files changed

+511
-65
lines changed

README.rst

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ python3-pip-skeleton-cli
33

44
|code_ci| |docs_ci| |coverage| |pypi_version| |license|
55

6-
This skeleton module (inspired by `jaraco/skeleton
7-
<https://blog.jaraco.com/skeleton/>`_) is a generic Python project structure
8-
which provides a means to keep tools and techniques in sync between multiple
9-
Python projects.
6+
``python3-pip-skeleton-cli`` provides the documentation
7+
and a command line tool to enable the adoption of python3-pip-skeleton_
8+
into a new or existing Python project.
109

1110
============== ==============================================================
1211
PyPI ``pip install python3-pip-skeleton``
@@ -15,7 +14,16 @@ Documentation https://DiamondLightSource.github.io/python3-pip-skeleton-cli
1514
Releases https://github.com/DiamondLightSource/python3-pip-skeleton-cli/releases
1615
============== ==============================================================
1716

18-
It integrates the following tools:
17+
The related python3-pip-skeleton_ repository contains the source
18+
code that can be merged into new or existing projects, and pulled from to
19+
keep them up to date. It can also serve as a working example for those who
20+
would prefer to cherry-pick.
21+
22+
python3-pip-skeleton_ is inspired by `jaraco/skeleton
23+
<https://blog.jaraco.com/skeleton/>`_.
24+
It provides a generic Python project structure
25+
and allows developers to keep tools and techniques in sync between multiple
26+
Python projects. It integrates the following tools:
1927

2028
- pip and setuptools_scm for version management
2129
- Pre-commit with black, flake8 and isort for static analysis
@@ -26,20 +34,17 @@ It integrates the following tools:
2634
- which verifies all the things that CI does
2735
- If you use VSCode, it will run black, flake8, isort and mypy on save
2836

29-
The related skeleton_ repo for this module contains the source
30-
code that can be merged into new or existing projects, and pulled from to
31-
keep them up to date. It can also serve as a working example for those who
32-
would prefer to cherry-pick.
3337

34-
.. _skeleton: https://github.com/DiamondLightSource/python3-pip-skeleton
38+
.. _python3-pip-skeleton: https://github.com/DiamondLightSource/python3-pip-skeleton
39+
40+
Quick start
41+
-----------
3542

36-
This ``python3-pip-skeleton-cli`` repo contains the
37-
docs and a command line tool to ease the adoption of this skeleton into a
38-
new project like this::
43+
To create a new project based on skeleton::
3944

4045
python3-pip-skeleton new /path/to/be/created --org my_github_user_or_org
4146

42-
and existing projects::
47+
or to adopt skeleton into existing projects::
4348

4449
python3-pip-skeleton existing /path/to/existing/repo --org my_github_user_or_org
4550

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
Pinning Requirements
2+
====================
3+
4+
Introduction
5+
------------
6+
7+
By design this project only defines dependencies in one place, i.e. in
8+
the ``requires`` table in ``pyproject.toml``.
9+
10+
In the ``requires`` table it is possible to pin versions of some dependencies
11+
as needed. For library projects it is best to leave pinning to a minimum so
12+
that your library can be used by the widest range of applications.
13+
14+
When CI builds the project it will use the latest compatible set of
15+
dependencies available (after applying your pins and any dependencies' pins).
16+
17+
This approach means that there is a possibility that a future build may
18+
break because an updated release of a dependency has made a breaking change.
19+
20+
The correct way to fix such an issue is to work out the minimum pinning in
21+
``requires`` that will resolve the problem. However this can be quite hard to
22+
do and may be time consuming when simply trying to release a minor update.
23+
24+
For this reason we provide a mechanism for locking all dependencies to
25+
the same version as a previous successful release. This is a quick fix that
26+
should guarantee a successful CI build.
27+
28+
Finding the lock files
29+
----------------------
30+
31+
Every release of the project will have a set of requirements files published
32+
as release assets.
33+
34+
For example take a look at the release page for python3-pip-skeleton-cli here:
35+
https://github.com/DiamondLightSource/python3-pip-skeleton-cli/releases/tag/3.3.0
36+
37+
There is a list of requirements*.txt files showing as assets on the release.
38+
39+
There is one file for each time the CI installed the project into a virtual
40+
environment. There are multiple of these as the CI creates a number of
41+
different environments.
42+
43+
The files are created using ``pip freeze`` and will contain a full list
44+
of the dependencies and sub-dependencies with pinned versions.
45+
46+
You can download any of these files by clicking on them. It is best to use
47+
the one that ran with the lowest Python version as this is more likely to
48+
be compatible with all the versions of Python in the test matrix.
49+
i.e. ``requirements-test-ubuntu-latest-3.8.txt`` in this example.
50+
51+
Applying the lock file
52+
----------------------
53+
54+
To apply a lockfile:
55+
56+
- copy the requirements file you have downloaded to the root of your
57+
repository
58+
- rename it to requirements.txt
59+
- commit it into the repo
60+
- push the changes
61+
62+
The CI looks for a requirements.txt in the root and will pass it to pip
63+
when installing each of the test environments. pip will then install exactly
64+
the same set of packages as the previous release.
65+
66+
Removing dependency locking from CI
67+
-----------------------------------
68+
69+
Once the reasons for locking the build have been resolved it is a good idea
70+
to go back to an unlocked build. This is because you get an early indication
71+
of any incoming problems.
72+
73+
To restore unlocked builds in CI simply remove requirements.txt from the root
74+
of the repo and push.

docs/developer/how-to/run-tests.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _using pytest:
2+
13
Run the tests using pytest
24
==========================
35

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Container Local Build and Test
2+
==============================
3+
4+
CI builds a runtime container for the project. The local tests
5+
checks available via ``tox -p`` do not verify this because not
6+
all developers will have docker installed locally.
7+
8+
If CI is failing to build the container, then it is best to fix and
9+
test the problem locally. This would require that you have docker
10+
or podman installed on your local workstation.
11+
12+
In the following examples the command ``docker`` is interchangeable with
13+
``podman`` depending on which container cli you have installed.
14+
15+
To build the container and call it ``test``::
16+
17+
cd <root of the project>
18+
docker build -t test .
19+
20+
To verify that the container runs::
21+
22+
docker run -it test --help
23+
24+
You can pass any other command line parameters to your application
25+
instead of --help.

docs/developer/index.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ side-bar.
3232
how-to/lint
3333
how-to/update-tools
3434
how-to/make-release
35+
how-to/pin-requirements
36+
how-to/test-container
3537

3638
+++
3739

@@ -43,7 +45,7 @@ side-bar.
4345
:caption: Explanations
4446
:maxdepth: 1
4547

46-
explanations/decisions
48+
explanations/skeleton
4749

4850
+++
4951

docs/developer/explanations/decisions/0001-record-architecture-decisions.rst renamed to docs/user/explanations/decisions/0001-record-architecture-decisions.rst

File renamed without changes.

docs/user/explanations/docs-structure.rst renamed to docs/user/explanations/decisions/0003-docs-structure.rst

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
1-
About the documentation
2-
-----------------------
1+
.. _documentation structure:
2+
3+
3. Standard documentation structure
4+
===================================
5+
6+
Date: 2023-01-18
7+
8+
Status
9+
------
10+
11+
Accepted
12+
13+
Context
14+
-------
15+
16+
Skeleton based project's documentation requires organizing.
17+
18+
Decision
19+
--------
20+
21+
Use the approach proposed by David Laing.
322

423
:material-regular:`format_quote;2em`
524

@@ -16,3 +35,8 @@ approaches to their creation. Understanding the implications of this will help
1635
improve most documentation - often immensely.
1736

1837
`More information on this topic. <https://documentation.divio.com>`_
38+
39+
Consequences
40+
------------
41+
42+
See article linked above.

docs/user/explanations/why-src.rst renamed to docs/user/explanations/decisions/0004-why-src.rst

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
1-
Why use a source directory
2-
==========================
1+
.. _src:
32

4-
This skeleton repo has made the decision to use a source directory. The reasons
5-
for this are set out in `Hynek's article`_ and summarized below.
3+
4. Use a source directory
4+
=========================
5+
6+
Date: 2023-01-18
7+
8+
Status
9+
------
10+
11+
Accepted
12+
13+
Context
14+
-------
15+
16+
We need to decide how to structure the source code in skeleton based projects.
17+
18+
19+
Decision
20+
--------
21+
22+
As per `Hynek's article`_ and summarized below.
623

724
.. _Hynek's article: https://hynek.me/articles/testing-packaging/
825

@@ -26,3 +43,8 @@ This is tested in CI in the following way:
2643
checks that all files needed for the tests are packaged with the distribution.
2744

2845
.. _editable install: https://pip.pypa.io/en/stable/cli/pip_install/#editable-installs
46+
47+
Consequences
48+
------------
49+
50+
See the article linked above.

0 commit comments

Comments
 (0)