Skip to content

Commit 47e4431

Browse files
committed
Document requirements.txt files
1 parent b52e93e commit 47e4431

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

readme.md

+26
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,32 @@ Reasons for a centralized workflow repository:
99
- reusability of course: no need to update dozens of repository where 95% of workflows are the same
1010
- centralize all dependencies pertaining to automation: think of the point-release of an action that triggers dependabot upgrade to all your repositories depending on it
1111

12+
## Why all these `*requirements.txt` files?
13+
14+
Let's look for example atthe `lint-yaml` job from [`.github/workflows/lint.yaml`](https://github.com/kdeldycke/workflows/blob/main/.github/workflows/lint.yaml#L126). Here we only need the `yamllint` CLI. This CLI is [distributed on PyPi](https://pypi.org/project/yamllint/). So before executing it, we could have simply run the following step:
15+
```yaml
16+
- name: Install yamllint
17+
run: |
18+
pip install yamllint
19+
```
20+
21+
Instead, we install it via the [`yamllint-requirements.txt` at the root of this repository](https://github.com/kdeldycke/workflows/blob/main/yamllint-requirements.txt).
22+
23+
Why? Because I want the version of `yamllint` to be pinned. By pinning it, I make the workflow stable, predictable and reproducible.
24+
25+
So why use a dedicated requirements file? Why don't we simply add the version? Like:
26+
```yaml
27+
- name: Install yamllint
28+
run: |
29+
pip install yamllint==1.35.1
30+
```
31+
32+
That would indeed pin the version. But it requires the maintainer (me) to keep track of new release and update manually the version string. That's a lot of work. And I'm lazy. So this should be automated.
33+
34+
To automate that, the only practical way I found was to rely on dependabot. But dependabot cannot update arbitrary versions in `run:` YAML blocks. It [only supports `**/*requirements.txt` and `**/pyproject.toml`](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#pip-and-pip-compile) files for Python projects.
35+
36+
So to keep track of new versions of dependencies while keeping them stable, we've hard-coded all Python libraries and CLIs in the `*requirements.txt` files. All with pinned versions.
37+
1238
## Permissions and token
1339

1440
This repository updates itself via GitHub actions. It particularly updates its own YAML files in `.github/workflows`. That's forbidden by default. So we need extra permissions.

0 commit comments

Comments
 (0)