Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions .github/scripts/check-renovate-series.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
#!/usr/bin/env python3
"""Keep Renovate's version filters on the same release series as the junctions.

`elements/*.bst` pin a junction with a `track:` glob and a resolved `ref:`:

track: freedesktop-sdk-26.08*
ref: freedesktop-sdk-26.08.0-0-gdb97cce...

`renovate.json` decides which upstream tags are candidates for a bump with a
per-package `extractVersion` anchored to that same series:

"extractVersion": "^freedesktop-sdk-(?<version>26\\.08\\.[0-9]+)$"

Nothing ties the two together. When a junction moves to a new series and the
Renovate rule does not, the rule stops matching every tag upstream publishes.
Renovate then reports no updates rather than an error, so the junction quietly
stops receiving bumps and the `track-refs` job in build.yml has nothing to
resolve. That is not hypothetical: the freedesktop-sdk rule still read
`25\\.08\\.` after the junction moved to `freedesktop-sdk-26.08.0`.

This script fails closed on that drift. It reads the series out of each
junction's `track:` glob and asserts the matching `extractVersion` in
renovate.json is anchored to the same one.
"""

import json
import re
import sys
from pathlib import Path

ROOT = Path(__file__).resolve().parents[2]
RENOVATE_JSON = ROOT / "renovate.json"

# depName in renovate.json -> the junction whose `track:` is authoritative.
JUNCTIONS = {
"https://gitlab.com/freedesktop-sdk/freedesktop-sdk.git": (
ROOT / "elements" / "freedesktop-sdk.bst"
),
"https://gitlab.gnome.org/GNOME/gnome-build-meta.git": (
ROOT / "elements" / "gnome-build-meta.bst"
),
}

TRACK_RE = re.compile(r"^\s*track:\s*[\"']?([^\"'\s]+)[\"']?\s*$", re.MULTILINE)


def read(path):
if not path.is_file():
sys.exit(f"ERROR: expected file not found: {path.relative_to(ROOT)}")
return path.read_text(encoding="utf-8")


def series_of(track):
"""The literal prefix of a track glob, with the trailing '*' removed.

`freedesktop-sdk-26.08*` -> `freedesktop-sdk-26.08`
`gnome-50` -> `gnome-50` (no glob; the whole value)
"""
return track.split("*", 1)[0]


def digits(text):
"""Version-ish digit groups, so an escaped regex and a plain glob compare.

`^freedesktop-sdk-(?<version>26\\.08\\.[0-9]+)$` -> ['26', '08']
`freedesktop-sdk-26.08` -> ['26', '08']
`[0-9]+` is dropped: it is the part Renovate fills in, not a series digit.
"""
stripped = text.replace("\\.", ".").replace("[0-9]+", "")
return [g for g in re.findall(r"\d+", stripped)]


def main():
config = json.loads(read(RENOVATE_JSON))
rules = config.get("packageRules", [])
failures = []
checked = 0

for dep_name, junction_path in JUNCTIONS.items():
matching = [
rule
for rule in rules
if dep_name in rule.get("matchPackageNames", [])
and "extractVersion" in rule
]
if not matching:
failures.append(
f"renovate.json has no packageRule with an extractVersion for "
f"{dep_name}; {junction_path.relative_to(ROOT)} would never be bumped"
)
continue

track_match = TRACK_RE.search(read(junction_path))
if not track_match:
failures.append(
f"{junction_path.relative_to(ROOT)} declares no `track:`; "
"cannot verify the Renovate series against it"
)
continue

series = series_of(track_match.group(1))
want = digits(series)

for rule in matching:
checked += 1
got = digits(rule["extractVersion"])
if got != want:
failures.append(
f"{junction_path.relative_to(ROOT)} tracks `{track_match.group(1)}` "
f"(series {'.'.join(want) or '<none>'}) but renovate.json filters "
f"{dep_name} with extractVersion {rule['extractVersion']!r} "
f"(series {'.'.join(got) or '<none>'}). Renovate matches no tag, "
"so this junction gets no update PRs."
)

if failures:
for failure in failures:
print(f"ERROR: {failure}", file=sys.stderr)
sys.exit(1)

print(f"OK: {checked} Renovate version filter(s) match their junction `track:` series")


if __name__ == "__main__":
main()
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ permissions:
contents: read

jobs:

build:
# Read-only token (workflow default): on pull_request this job checks out
# and executes PR-controlled code, so it must never hold a write token.
Expand All @@ -35,7 +36,7 @@ jobs:
- name: Set up just
uses: taiki-e/install-action@7b8d4719ee4aaa279bdf55df38dacb9ebfe12a6c # v2
with:
tool: just
tool: just@1.58.0

- name: Validate Element Graph
run: just validate
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/kernel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- name: Set up just
uses: taiki-e/install-action@7b8d4719ee4aaa279bdf55df38dacb9ebfe12a6c # v2
with:
tool: just
tool: just@1.58.0

- name: Validate Element Graph
run: just validate
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/track-junctions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Set up just
uses: taiki-e/install-action@7b8d4719ee4aaa279bdf55df38dacb9ebfe12a6c # v2
with:
tool: just
tool: just@1.58.0

- name: Track and resolve BuildStream junction refs
run: |
Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,32 @@ on:
pull_request:
paths:
- '.github/scripts/**'
- '.github/workflows/build.yml'
- '.github/workflows/unit-tests.yml'
- '.pre-commit-config.yaml'
- 'elements/**'
- 'files/**'
- 'include/**'
- 'project.conf'
- 'tests/unit/**'
- 'Justfile'
- 'renovate.json'
- 'elements/*.bst'
push:
branches: [main]
paths:
- '.github/scripts/**'
- '.github/workflows/build.yml'
- '.github/workflows/unit-tests.yml'
- '.pre-commit-config.yaml'
- 'elements/**'
- 'files/**'
- 'include/**'
- 'project.conf'
- 'tests/unit/**'
- 'Justfile'
- 'renovate.json'
- 'elements/*.bst'

permissions:
contents: read
Expand All @@ -41,7 +55,7 @@ jobs:
- name: Set up just
uses: taiki-e/install-action@7b8d4719ee4aaa279bdf55df38dacb9ebfe12a6c # v2
with:
tool: just
tool: just@1.58.0

- name: Run unit tests
run: just test-unit
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ repos:
language: system
pass_filenames: false
files: ^(project\.conf|elements/freedesktop-sdk\.bst|\.github/scripts/check-release-version\.py)$
- id: check-renovate-series
name: Renovate version filters match the junction track series
entry: python .github/scripts/check-renovate-series.py
language: system
pass_filenames: false
files: ^(renovate\.json|elements/(freedesktop-sdk|gnome-build-meta)\.bst|\.github/scripts/check-renovate-series\.py)$
- id: check-k0s-version
name: k0s version derived from include/k0s.yml, not restated
entry: python .github/scripts/check-k0s-version.py
Expand Down
1 change: 1 addition & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ tags:
validate:
python3 .github/scripts/check-release-version.py
python3 .github/scripts/check-k0s-version.py
python3 .github/scripts/check-renovate-series.py
just bst show --deps all oci/bluefin-server-ddi.bst
just bst show --deps all oci/bluefin-server-installer.bst
just bst show --deps all oci/k0s-sysext.bst
Expand Down
15 changes: 14 additions & 1 deletion docs/skills/ci-tooling.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,21 @@ before adding an action.

### Installing `just` — taiki-e/install-action, not snap/cargo/apt

Pin the tool version too, not only the action SHA. Without `@<version>`,
`install-action` resolves `just@latest` at run time, so the CI contract
(`just validate`, `just test-unit`, the DDI/kernel export recipes) runs against
a binary chosen by an upstream release rather than by a commit in this repo.

```yaml
- uses: taiki-e/install-action@b6b84cf49ebfe0176417bdce007c624f0db37f20 # v2
with:
tool: just
tool: just@1.58.0
```

The version is repeated at each call site — currently `build.yml` (two jobs),
`kernel.yml` and `unit-tests.yml`. Bumping `just` means changing all of them in
one commit, so CI never runs two versions at once.

### Workflow permissions

`.github/workflows/build.yml` defaults to a read-only token:
Expand Down Expand Up @@ -142,17 +151,21 @@ uploaded to a GitHub Release tagged `installer-v<FSDK-RELEASE>`.
|---|---|
| "It's just a minor version tag, supply-chain risk is low." | One compromised tag push owns every repo using it. Pin to SHA. |
| "I'll check what SHA other repos use later." | Check now — it's one `gh api` call and takes a few seconds. |
| "`tool: just` always installs a working version." | It installs whatever is latest that day. A `just` release can change recipe parsing or `--fmt` output and break CI with no commit in this repo. |

## Red Flags

- Any `uses:` line with a mutable ref (`@v2`, `@main`, `@latest`).
- An `install-action` step whose `tool:` has no `@<version>` — the pin is half
done, since the action is fixed but the binary it installs is not.
- `sudo podman` in one step and plain `podman` in another step doing the same
operation.
- A new action not present in any sibling repo — check upstream first.

## Verification

- [ ] Every `uses:` line has a full 40-character SHA and a `# vX` comment.
- [ ] Every `install-action` `tool:` names an explicit version (`just@1.58.0`).
- [ ] `just validate` passes after workflow changes.
- [ ] No new mutable action refs introduced.
- [ ] The release signing step uploads detached `.gpg` signatures for every
Expand Down
2 changes: 1 addition & 1 deletion renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{
"matchDatasources": ["git-refs"],
"matchPackageNames": ["https://gitlab.com/freedesktop-sdk/freedesktop-sdk.git"],
"extractVersion": "^freedesktop-sdk-(?<version>25\\.08\\.[0-9]+)$",
"extractVersion": "^freedesktop-sdk-(?<version>26\\.08\\.[0-9]+)$",
"versioning": "semver"
},
{
Expand Down
Loading
Loading