Skip to content

Commit 0d1496b

Browse files
Apply migration from 0.17.0 to 0.18.0
=== v0.18.0 ========================================================= Script URL: https://raw.githubusercontent.com/frequenz-floss/frequenz-repo-config-python/v0.18.0/cookiecutter/migrate.py ======================================================================== Removing unused cross-arch testing files... Removed .github/containers/nox-cross-arch Removed .github/containers/test-installation Removed empty .github/containers Updated CONTRIBUTING.md: removed 'Cross-Arch Testing' section ======================================================================== Updating cookiecutter replay file... Updated .cookiecutter-replay.json: added `private_repo=no` replay data ======================================================================== Updating generated CI workflows... ======================================================================== Updating auxiliary GitHub workflows... >>> .github/workflows/black-migration.yaml is missing. Generated projects are expected to have this workflow; please restore it from the template or apply the Dependabot migration workflow updates manually. Updated .github/workflows/repo-config-migration.yaml: use explicit Dependabot migration iteration ======================================================================== Normalizing GitHub Action hashes... ======================================================================== Updating issue template configuration... Skipped .github/ISSUE_TEMPLATE/config.yml: already up to date ======================================================================== Setting up the gRPC migration workflow... Updated .github/dependabot.yml: replaced old 'grpc' group with grpc-compatible / grpcio-major / protobuf-major; added grpc exclude-patterns to patch >>> .github/workflows/auto-dependabot.yaml does not match the expected layout; please add skip conditions for 'the grpc-compatible group', 'the grpcio-major group', 'the protobuf-major group' manually. Created .github/workflows/grpc-migration.yaml Updated ruleset 'Protect version branches': added 'Fix gRPC/protobuf runtime floors' required check ======================================================================== Fixing nox test path typo in CONTRIBUTING.md... Updated CONTRIBUTING.md: fixed nox 'test/' -> 'tests/' typo ======================================================================== Adjusting CONTRIBUTING.md release section for repo privacy... Skipped CONTRIBUTING.md: public repository, no change needed ======================================================================== Excluding submodules from black for API projects... Updated pyproject.toml: excluded submodules/ from black via extend-exclude ======================================================================== Setting up the isort migration workflow... Created .github/workflows/isort-migration.yaml >>> .github/workflows/auto-dependabot.yaml does not contain the expected 'Bump black from ' skip condition; please add the 'Bump isort from ' skip condition manually. Updated .github/dependabot.yml: added 'isort' to exclude-patterns of patch and minor ======================================================================== Excluding submodules from isort for API projects... Updated pyproject.toml: added isort skip_glob for submodules/ ======================================================================== ⚠️⚠️⚠️ Remember to check the manual steps: ⚠️⚠️⚠️ ⚠️⚠️⚠️ 1. .github/workflows/black-migration.yaml is missing. Generated projects are expected to have this workflow; please restore it from the template or apply the Dependabot migration workflow updates manually. ⚠️⚠️⚠️ 2. .github/workflows/auto-dependabot.yaml does not match the expected layout; please add skip conditions for 'the grpc-compatible group', 'the grpcio-major group', 'the protobuf-major group' manually. ⚠️⚠️⚠️ 3. .github/workflows/auto-dependabot.yaml does not contain the expected 'Bump black from ' skip condition; please add the 'Bump isort from ' skip condition manually. ❌ Migration script finished but requires manual intervention ❌ The migration completed but requires manual intervention.
1 parent 327894e commit 0d1496b

10 files changed

Lines changed: 220 additions & 94 deletions

File tree

.cookiecutter-replay.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"keywords": "cloud, microgrid",
99
"github_org": "frequenz-floss",
1010
"license": "MIT",
11+
"private_repo": "no",
1112
"author_name": "Frequenz Energy-as-a-Service GmbH",
1213
"author_email": "floss@frequenz.com",
1314
"python_package": "frequenz.api.reporting",
@@ -35,6 +36,10 @@
3536
"MIT",
3637
"Proprietary"
3738
],
39+
"private_repo": [
40+
"{{ 'yes' if cookiecutter.license == 'Proprietary' else 'no' }}",
41+
"{{ 'no' if cookiecutter.license == 'Proprietary' else 'yes' }}"
42+
],
3843
"author_name": "Frequenz Energy-as-a-Service GmbH",
3944
"author_email": "floss@frequenz.com",
4045
"python_package": "{{cookiecutter | python_package}}",

.github/containers/nox-cross-arch/arm64-ubuntu-20.04-python-3.11.Dockerfile

Lines changed: 0 additions & 33 deletions
This file was deleted.

.github/containers/nox-cross-arch/entrypoint.bash

Lines changed: 0 additions & 9 deletions
This file was deleted.

.github/containers/test-installation/Dockerfile

Lines changed: 0 additions & 20 deletions
This file was deleted.

.github/dependabot.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ updates:
2929
exclude-patterns:
3030
# pydoclint has shipped breaking changes in patch updates often
3131
- "pydoclint"
32+
# These need a migration script to fix Dependabot not updating the
33+
# runtime dependencies
34+
- "grpcio"
35+
- "grpcio-tools"
36+
- "protobuf"
37+
- "isort"
3238
minor:
3339
update-types:
3440
- "minor"
@@ -48,6 +54,7 @@ updates:
4854
- "protobuf"
4955
- "pydoclint"
5056
- "pytest-asyncio"
57+
- "isort"
5158
# We group repo-config updates as it uses optional dependencies that are
5259
# considered different dependencies otherwise, and will create one PR for
5360
# each if we don't group them.
@@ -63,10 +70,28 @@ updates:
6370
# We group grpcio and protobuf updates together, as they need special
6471
# handling on the pyproject.toml file because of the protobuf/grpcio
6572
# build/runtime cross-version guarantees
66-
grpc:
73+
# We group grpcio and protobuf updates together, as they need special
74+
# handling on the pyproject.toml file because of the protobuf/grpcio
75+
# build/runtime cross-version guarantees and wrong dependabot handling
76+
# of build/runtime dependencies.
77+
grpc-compatible:
78+
update-types:
79+
- "patch"
80+
- "minor"
81+
patterns:
82+
- "grpcio"
83+
- "grpcio-tools"
84+
- "protobuf"
85+
# For major updates we split it up. It was observed in the past that
86+
# grpcio releases lag behind protobuf releases, and they are not
87+
# compatible with a major protobuf update for a while, so we shouldn't
88+
# block the update of one with the other.
89+
grpcio-major:
6790
patterns:
6891
- "grpcio"
6992
- "grpcio-tools"
93+
protobuf-major:
94+
patterns:
7095
- "protobuf"
7196

7297
- package-ecosystem: "github-actions"
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Automatic grpc/protobuf build/runtime sync for Dependabot PRs
2+
#
3+
# The template's `pyproject.toml` pins `protobuf`, `grpcio` and `grpcio-tools`
4+
# in `[build-system].requires` as *exact* versions, and also declares
5+
# `protobuf` and `grpcio` in `[project].dependencies` with a `>= <build-pin>`
6+
# lower bound. The lower bound must always match the exact pin, because the
7+
# protobuf cross-version runtime guarantee requires the runtime to be at
8+
# least the version used at generation time:
9+
# https://protobuf.dev/support/cross-version-runtime-guarantee/
10+
#
11+
# Dependabot correctly bumps `[build-system].requires`, but it does not bump
12+
# the matching `>=` floor in `[project].dependencies`. This workflow runs
13+
# after a Dependabot grpc/protobuf group PR, rewrites the `>=` floor to match
14+
# the new build pins, and pushes the fix-up commit back onto the PR branch.
15+
#
16+
# The companion auto-dependabot workflow skips the `grpc-compatible`,
17+
# `grpcio-major` and `protobuf-major` groups so those PRs are handled
18+
# exclusively by this migration workflow.
19+
#
20+
# XXX: !!! SECURITY WARNING !!!
21+
# pull_request_target has write access to the repo, and can read secrets.
22+
# This is required because Dependabot PRs are treated as fork PRs: the
23+
# GITHUB_TOKEN is read-only and secrets are unavailable with a plain
24+
# pull_request trigger. The action mitigates the risk by:
25+
# - Never executing code from the PR (the migration script is fetched
26+
# from the repo-config branch configured below, not taken from the PR).
27+
# - Gating migration steps on github.actor == 'dependabot[bot]' AND the
28+
# PR title.
29+
# - Running checkout with persist-credentials: false and isolating
30+
# push credentials from the migration script environment.
31+
# For more details read:
32+
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
33+
34+
name: gRPC Migration
35+
36+
on:
37+
merge_group: # To allow using this as a required check for merging
38+
pull_request_target:
39+
types: [opened, synchronize, reopened, labeled, unlabeled]
40+
41+
permissions:
42+
# Commit the sync-up to the PR branch.
43+
contents: write
44+
# Create and normalize migration state labels.
45+
issues: write
46+
# Read/update pull request metadata and comments.
47+
pull-requests: write
48+
49+
jobs:
50+
grpc-migration:
51+
name: Fix gRPC/protobuf runtime floors
52+
# Skip if it was triggered by the merge queue. We only need the workflow to
53+
# be executed to meet the "Required check" condition for merging, but we
54+
# don't need to actually run the job, having the job present as Skipped is
55+
# enough.
56+
if: |
57+
github.event_name == 'pull_request_target' &&
58+
github.actor == 'dependabot[bot]' &&
59+
(contains(github.event.pull_request.title, 'the grpc-compatible group') ||
60+
contains(github.event.pull_request.title, 'the grpcio-major group') ||
61+
contains(github.event.pull_request.title, 'the protobuf-major group'))
62+
runs-on: ubuntu-24.04
63+
steps:
64+
- name: Generate token
65+
id: create-app-token
66+
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
67+
with:
68+
app-id: ${{ secrets.FREQUENZ_AUTO_DEPENDABOT_APP_ID }}
69+
private-key: ${{ secrets.FREQUENZ_AUTO_DEPENDABOT_APP_PRIVATE_KEY }}
70+
# Push the sync-up commit to the PR branch.
71+
permission-contents: write
72+
# Create and normalize migration state labels.
73+
permission-issues: write
74+
# Read/update pull request metadata and labels.
75+
permission-pull-requests: write
76+
- name: Migrate
77+
uses: frequenz-floss/gh-action-dependabot-migrate@27763fb5eb56476d91abe00132e8a0614171f92f # v1.2.0
78+
with:
79+
script-url-template: >- # v0.18.0
80+
https://raw.githubusercontent.com/frequenz-floss/frequenz-repo-config-python/529d30b554392e6d8b66e84e92c04ac9cd170da7/cookiecutter/scripts/dependabot-grpc-fixer.py
81+
token: ${{ steps.create-app-token.outputs.token }}
82+
version-iteration: "false"
83+
sign-commits: "true"
84+
auto-merged-label: "tool:auto-merged"
85+
migrated-label: "tool:grpc:migration:executed"
86+
intervention-pending-label: "tool:grpc:migration:intervention-pending"
87+
intervention-done-label: "tool:grpc:migration:intervention-done"
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Automatic isort migration for Dependabot PRs
2+
#
3+
# When Dependabot upgrades isort, this workflow installs the new version and
4+
# runs `isort .` so the PR already contains any import-ordering changes
5+
# introduced by the upgrade, while leaving the PR open for review.
6+
#
7+
# isort follows SemVer but its release policy
8+
# (https://github.com/PyCQA/isort/blob/main/docs/major_releases/release_policy.md)
9+
# explicitly allows intentional formatting changes in minor releases, and
10+
# patch releases may also adjust output in smaller bug-fix ways. Because of
11+
# that, isort is excluded from the regular `patch` and `minor` Dependabot
12+
# groups: every isort bump produces an individual `Bump isort from …` PR and
13+
# is routed through this migration workflow.
14+
#
15+
# The companion auto-dependabot workflow skips those PRs so they're handled
16+
# exclusively by this migration workflow.
17+
#
18+
# XXX: !!! SECURITY WARNING !!!
19+
# pull_request_target has write access to the repo, and can read secrets.
20+
# This is required because Dependabot PRs are treated as fork PRs: the
21+
# GITHUB_TOKEN is read-only and secrets are unavailable with a plain
22+
# pull_request trigger. The action mitigates the risk by:
23+
# - Never executing code from the PR (the migration script is embedded
24+
# in this workflow file on the base branch, not taken from the PR).
25+
# - Gating migration steps on github.actor == 'dependabot[bot]'.
26+
# - Running checkout with persist-credentials: false and isolating
27+
# push credentials from the migration script environment.
28+
# For more details read:
29+
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
30+
31+
name: isort Migration
32+
33+
on:
34+
merge_group: # To allow using this as a required check for merging
35+
pull_request_target:
36+
types: [opened, synchronize, reopened, labeled, unlabeled]
37+
38+
permissions:
39+
# Commit reformatted files back to the PR branch.
40+
contents: write
41+
# Create and normalize migration state labels.
42+
issues: write
43+
# Read/update pull request metadata and comments.
44+
pull-requests: write
45+
46+
jobs:
47+
isort-migration:
48+
name: Migrate isort
49+
# Skip if it was triggered by the merge queue. We only need the workflow to
50+
# be executed to meet the "Required check" condition for merging, but we
51+
# don't need to actually run the job, having the job present as Skipped is
52+
# enough.
53+
if: |
54+
github.event_name == 'pull_request_target' &&
55+
github.actor == 'dependabot[bot]' &&
56+
contains(github.event.pull_request.title, 'Bump isort from ')
57+
runs-on: ubuntu-24.04
58+
steps:
59+
- name: Generate token
60+
id: create-app-token
61+
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
62+
with:
63+
app-id: ${{ secrets.FREQUENZ_AUTO_DEPENDABOT_APP_ID }}
64+
private-key: ${{ secrets.FREQUENZ_AUTO_DEPENDABOT_APP_PRIVATE_KEY }}
65+
# Push reformatted files to the PR branch.
66+
permission-contents: write
67+
# Create and normalize migration state labels.
68+
permission-issues: write
69+
# Read/update pull request metadata and labels.
70+
permission-pull-requests: write
71+
- name: Migrate
72+
uses: frequenz-floss/gh-action-dependabot-migrate@27763fb5eb56476d91abe00132e8a0614171f92f # v1.2.0
73+
with:
74+
migration-script: |
75+
import os
76+
import subprocess
77+
import sys
78+
79+
version = os.environ["MIGRATION_VERSION"].lstrip("v")
80+
subprocess.run(
81+
[sys.executable, "-Im", "pip", "install", f"isort=={version}"],
82+
check=True,
83+
)
84+
subprocess.run([sys.executable, "-Im", "isort", "."], check=True)
85+
token: ${{ steps.create-app-token.outputs.token }}
86+
auto-merge-on-changes: "false"
87+
version-iteration: "false"
88+
sign-commits: "true"
89+
auto-merged-label: "tool:auto-merged"
90+
migrated-label: "tool:isort:migration:executed"
91+
intervention-pending-label: "tool:isort:migration:intervention-pending"
92+
intervention-done-label: "tool:isort:migration:intervention-done"

.github/workflows/repo-config-migration.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,14 @@ jobs:
4747
app-id: ${{ secrets.FREQUENZ_AUTO_DEPENDABOT_APP_ID }}
4848
private-key: ${{ secrets.FREQUENZ_AUTO_DEPENDABOT_APP_PRIVATE_KEY }}
4949
- name: Migrate
50-
uses: frequenz-floss/gh-action-dependabot-migrate@45994e185a9040449304a470e8f02d0e197873b4 # v1.1.1
50+
uses: frequenz-floss/gh-action-dependabot-migrate@27763fb5eb56476d91abe00132e8a0614171f92f # v1.2.0
5151
with:
5252
script-url-template: >-
5353
https://raw.githubusercontent.com/frequenz-floss/frequenz-repo-config-python/{version}/cookiecutter/migrate.py
5454
token: ${{ steps.create-app-token.outputs.token }}
5555
migration-token: ${{ secrets.REPO_CONFIG_MIGRATION_TOKEN }}
56+
version-iteration: "minor"
57+
if-no-iterations: "pass"
5658
sign-commits: "true"
5759
auto-merged-label: "tool:auto-merged"
5860
migrated-label: "tool:repo-config:migration:executed"

CONTRIBUTING.md

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ pytest tests/test_*.py
9696
Or you can use `nox`:
9797

9898
```sh
99-
nox -R -s pytest -- test/test_*.py
99+
nox -R -s pytest -- tests/test_*.py
100100
```
101101

102102
The same appliest to `pylint` or `mypy` for example:
103103

104104
```sh
105-
nox -R -s pylint -- test/test_*.py
106-
nox -R -s mypy -- test/test_*.py
105+
nox -R -s pylint -- tests/test_*.py
106+
nox -R -s mypy -- tests/test_*.py
107107
```
108108

109109
### Building the documentation
@@ -200,30 +200,3 @@ These are the steps to create a new release:
200200
eventually too).
201201

202202
7. Celebrate!
203-
204-
## Cross-Arch Testing
205-
206-
This project has built-in support for testing across multiple architectures.
207-
Currently, our CI conducts tests on `arm64` machines using QEMU emulation. We
208-
also have the flexibility to expand this support to include additional
209-
architectures in the future.
210-
211-
This project contains Dockerfiles that can be used in the CI to test the
212-
python package in non-native machine architectures, e.g., `arm64`. The
213-
Dockerfiles exist in the directory `.github/containers/nox-cross-arch`, and
214-
follow a naming scheme so that they can be easily used in build matrices in the
215-
CI, in `nox-cross-arch` job. The naming scheme is:
216-
217-
```
218-
<arch>-<os>-python-<python-version>.Dockerfile
219-
```
220-
221-
E.g.,
222-
223-
```
224-
arm64-ubuntu-20.04-python-3.11.Dockerfile
225-
```
226-
227-
If a Dockerfile for your desired target architecture, OS, and python version
228-
does not exist here, please add one before proceeding to add your options to
229-
the test matrix.

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,15 @@ Support = "https://github.com/frequenz-floss/frequenz-api-reporting/discussions/
114114
[tool.black]
115115
line-length = 88
116116
target-version = ['py311']
117+
# Submodules may contain external code that doesn't follow our formatting rules.
118+
extend-exclude = '^/submodules/'
117119

118120
[tool.isort]
119121
profile = "black"
120122
line_length = 88
121123
src_paths = ["benchmarks", "examples", "src", "tests"]
124+
# Submodules may contain external code that doesn't follow our import sorting rules.
125+
skip_glob = ["submodules/*"]
122126

123127
[tool.flake8]
124128
# We give some flexibility to go over 88, there are cases like long URLs or

0 commit comments

Comments
 (0)