Skip to content

Commit e1f696b

Browse files
committed
Use the new private ARM runner for private repositories
We used to use the same name for our private ARM runner as the public one from GitHub, so we could easily re-use the same workflow for private and public repos. This doesn't work anymore because GitHub now randomly picks any runner with that name, and if it is a public one, then it will refuse to run for private repos. Because of this we now use the suffix `-arm64` for our private ARM runner, and we target the right runner based on the `github.repository_visibility` context variable. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 45d1949 commit e1f696b

File tree

9 files changed

+68
-28
lines changed
  • .github/workflows
  • cookiecutter
  • tests_golden/integration/test_cookiecutter_generation
    • actor/frequenz-actor-test/.github/workflows
    • api/frequenz-api-test/.github/workflows
    • app/frequenz-app-test/.github/workflows
    • lib/frequenz-test-python/.github/workflows
    • model/frequenz-model-test/.github/workflows

9 files changed

+68
-28
lines changed

.github/workflows/ci.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
matrix:
3131
arch:
3232
- amd64
33-
- arm
33+
- arm64
3434
os:
3535
- ubuntu-24.04
3636
python:
@@ -41,7 +41,7 @@ jobs:
4141
# that uses the same venv to run multiple linting sessions
4242
- "ci_checks_max"
4343
- "pytest_min"
44-
runs-on: ${{ matrix.os }}${{ matrix.arch != 'amd64' && format('-{0}', matrix.arch) || '' }}
44+
runs-on: ${{ matrix.os }}${{ matrix.arch == 'arm64' && (github.repository_visibility == 'private' && '-arm64' || '-arm') || '' }}
4545

4646
steps:
4747
- name: Run nox
@@ -107,13 +107,13 @@ jobs:
107107
matrix:
108108
arch:
109109
- amd64
110-
- arm
110+
- arm64
111111
os:
112112
- ubuntu-24.04
113113
python:
114114
- "3.11"
115115
- "3.12"
116-
runs-on: ${{ matrix.os }}${{ matrix.arch != 'amd64' && format('-{0}', matrix.arch) || '' }}
116+
runs-on: ${{ matrix.os }}${{ matrix.arch == 'arm64' && (github.repository_visibility == 'private' && '-arm64' || '-arm') || '' }}
117117

118118
steps:
119119
- name: Setup Git

RELEASE_NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ But you might still need to adapt your code:
3636
### Cookiecutter template
3737

3838
- mkdocstrings: Move `paths` key to the right section in `mkdocs.yml`.
39+
- The CI workflow now uses the new private ARM runner for private repositories (and the public ARM runners for public repositories).

cookiecutter/migrate.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ def main() -> None:
4545
print("Fixing wrongly located `paths` keys in mkdocs.yml...")
4646
migrate_mkdocs_yaml(Path("mkdocs.yml"))
4747
print("=" * 72)
48+
print("Migrating GitHub workflows to use the new arm64 runner...")
49+
workflow_dir = Path(".github/workflows")
50+
for workflow_file in [workflow_dir / "release.yaml", workflow_dir / "ci.yaml"]:
51+
migrate_arm64_ci_yaml(workflow_file)
52+
print("=" * 72)
4853
print("Migration script finished. Remember to follow any manual instructions.")
4954
print("=" * 72)
5055

@@ -221,6 +226,40 @@ def migrate_mkdocs_yaml(file_path: Path) -> None:
221226
file_path.write_text("".join(new_lines), encoding="utf-8")
222227

223228

229+
def migrate_arm64_ci_yaml(file_path: Path) -> None:
230+
"""Migrate the CI YAML file to use arm64 architecture."""
231+
print(f" - {file_path}")
232+
if not file_path.is_file():
233+
manual_step(f"File {file_path} does not exist, skipping automatic migration.")
234+
return
235+
236+
lines = file_path.read_text(encoding="utf-8").splitlines(keepends=True)
237+
new_lines: list[str] = []
238+
239+
for line in lines:
240+
# 1) Replace "- arm" with "- arm64" (preserve indentation)
241+
if match := re.match(r"^(\s*)-\s*arm(64)?\s*$", line):
242+
indent = match.group(1)
243+
new_lines.append(f"{indent}- arm64\n")
244+
continue
245+
246+
# 2) Update the runs-on line
247+
if match := re.match(r"^(\s*)runs-on:\s*\$\{\{.*matrix\.arch.*\}\}\s*$", line):
248+
indent = match.group(1)
249+
new_line = (
250+
f"{indent}runs-on: ${{{{ matrix.os }}}}"
251+
f"${{{{ matrix.arch == 'arm64' && "
252+
f"(github.repository_visibility == 'private' && '-arm64' || '-arm') || '' }}}}\n"
253+
)
254+
new_lines.append(new_line)
255+
continue
256+
257+
# Otherwise, keep the line as-is
258+
new_lines.append(line)
259+
260+
file_path.write_text("".join(new_lines), encoding="utf-8")
261+
262+
224263
def apply_patch(patch_content: str) -> None:
225264
"""Apply a patch using the patch utility."""
226265
subprocess.run(["patch", "-p1"], input=patch_content.encode(), check=True)

cookiecutter/{{cookiecutter.github_repo_name}}/.github/workflows/ci.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
matrix:
6464
arch:
6565
- amd64
66-
- arm
66+
- arm64
6767
os:
6868
- ubuntu-24.04
6969
python:
@@ -74,7 +74,7 @@ jobs:
7474
# that uses the same venv to run multiple linting sessions
7575
- "ci_checks_max"
7676
- "pytest_min"
77-
runs-on: ${{ matrix.os }}${{ matrix.arch != 'amd64' && format('-{0}', matrix.arch) || '' }}
77+
runs-on: ${{ matrix.os }}${{ matrix.arch == 'arm64' && (github.repository_visibility == 'private' && '-arm64' || '-arm') || '' }}
7878

7979
steps:
8080
- name: Run nox
@@ -147,13 +147,13 @@ jobs:
147147
matrix:
148148
arch:
149149
- amd64
150-
- arm
150+
- arm64
151151
os:
152152
- ubuntu-24.04
153153
python:
154154
- "3.11"
155155
- "3.12"
156-
runs-on: ${{ matrix.os }}${{ matrix.arch != 'amd64' && format('-{0}', matrix.arch) || '' }}
156+
runs-on: ${{ matrix.os }}${{ matrix.arch == 'arm64' && (github.repository_visibility == 'private' && '-arm64' || '-arm') || '' }}
157157

158158
steps:
159159
- name: Setup Git

tests_golden/integration/test_cookiecutter_generation/actor/frequenz-actor-test/.github/workflows/ci.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
matrix:
3131
arch:
3232
- amd64
33-
- arm
33+
- arm64
3434
os:
3535
- ubuntu-24.04
3636
python:
@@ -41,7 +41,7 @@ jobs:
4141
# that uses the same venv to run multiple linting sessions
4242
- "ci_checks_max"
4343
- "pytest_min"
44-
runs-on: ${{ matrix.os }}${{ matrix.arch != 'amd64' && format('-{0}', matrix.arch) || '' }}
44+
runs-on: ${{ matrix.os }}${{ matrix.arch == 'arm64' && (github.repository_visibility == 'private' && '-arm64' || '-arm') || '' }}
4545

4646
steps:
4747
- name: Run nox
@@ -114,13 +114,13 @@ jobs:
114114
matrix:
115115
arch:
116116
- amd64
117-
- arm
117+
- arm64
118118
os:
119119
- ubuntu-24.04
120120
python:
121121
- "3.11"
122122
- "3.12"
123-
runs-on: ${{ matrix.os }}${{ matrix.arch != 'amd64' && format('-{0}', matrix.arch) || '' }}
123+
runs-on: ${{ matrix.os }}${{ matrix.arch == 'arm64' && (github.repository_visibility == 'private' && '-arm64' || '-arm') || '' }}
124124

125125
steps:
126126
- name: Setup Git

tests_golden/integration/test_cookiecutter_generation/api/frequenz-api-test/.github/workflows/ci.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
matrix:
6161
arch:
6262
- amd64
63-
- arm
63+
- arm64
6464
os:
6565
- ubuntu-24.04
6666
python:
@@ -71,7 +71,7 @@ jobs:
7171
# that uses the same venv to run multiple linting sessions
7272
- "ci_checks_max"
7373
- "pytest_min"
74-
runs-on: ${{ matrix.os }}${{ matrix.arch != 'amd64' && format('-{0}', matrix.arch) || '' }}
74+
runs-on: ${{ matrix.os }}${{ matrix.arch == 'arm64' && (github.repository_visibility == 'private' && '-arm64' || '-arm') || '' }}
7575

7676
steps:
7777
- name: Run nox
@@ -144,13 +144,13 @@ jobs:
144144
matrix:
145145
arch:
146146
- amd64
147-
- arm
147+
- arm64
148148
os:
149149
- ubuntu-24.04
150150
python:
151151
- "3.11"
152152
- "3.12"
153-
runs-on: ${{ matrix.os }}${{ matrix.arch != 'amd64' && format('-{0}', matrix.arch) || '' }}
153+
runs-on: ${{ matrix.os }}${{ matrix.arch == 'arm64' && (github.repository_visibility == 'private' && '-arm64' || '-arm') || '' }}
154154

155155
steps:
156156
- name: Setup Git

tests_golden/integration/test_cookiecutter_generation/app/frequenz-app-test/.github/workflows/ci.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
matrix:
3131
arch:
3232
- amd64
33-
- arm
33+
- arm64
3434
os:
3535
- ubuntu-24.04
3636
python:
@@ -41,7 +41,7 @@ jobs:
4141
# that uses the same venv to run multiple linting sessions
4242
- "ci_checks_max"
4343
- "pytest_min"
44-
runs-on: ${{ matrix.os }}${{ matrix.arch != 'amd64' && format('-{0}', matrix.arch) || '' }}
44+
runs-on: ${{ matrix.os }}${{ matrix.arch == 'arm64' && (github.repository_visibility == 'private' && '-arm64' || '-arm') || '' }}
4545

4646
steps:
4747
- name: Run nox
@@ -114,13 +114,13 @@ jobs:
114114
matrix:
115115
arch:
116116
- amd64
117-
- arm
117+
- arm64
118118
os:
119119
- ubuntu-24.04
120120
python:
121121
- "3.11"
122122
- "3.12"
123-
runs-on: ${{ matrix.os }}${{ matrix.arch != 'amd64' && format('-{0}', matrix.arch) || '' }}
123+
runs-on: ${{ matrix.os }}${{ matrix.arch == 'arm64' && (github.repository_visibility == 'private' && '-arm64' || '-arm') || '' }}
124124

125125
steps:
126126
- name: Setup Git

tests_golden/integration/test_cookiecutter_generation/lib/frequenz-test-python/.github/workflows/ci.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
matrix:
3131
arch:
3232
- amd64
33-
- arm
33+
- arm64
3434
os:
3535
- ubuntu-24.04
3636
python:
@@ -41,7 +41,7 @@ jobs:
4141
# that uses the same venv to run multiple linting sessions
4242
- "ci_checks_max"
4343
- "pytest_min"
44-
runs-on: ${{ matrix.os }}${{ matrix.arch != 'amd64' && format('-{0}', matrix.arch) || '' }}
44+
runs-on: ${{ matrix.os }}${{ matrix.arch == 'arm64' && (github.repository_visibility == 'private' && '-arm64' || '-arm') || '' }}
4545

4646
steps:
4747
- name: Run nox
@@ -114,13 +114,13 @@ jobs:
114114
matrix:
115115
arch:
116116
- amd64
117-
- arm
117+
- arm64
118118
os:
119119
- ubuntu-24.04
120120
python:
121121
- "3.11"
122122
- "3.12"
123-
runs-on: ${{ matrix.os }}${{ matrix.arch != 'amd64' && format('-{0}', matrix.arch) || '' }}
123+
runs-on: ${{ matrix.os }}${{ matrix.arch == 'arm64' && (github.repository_visibility == 'private' && '-arm64' || '-arm') || '' }}
124124

125125
steps:
126126
- name: Setup Git

tests_golden/integration/test_cookiecutter_generation/model/frequenz-model-test/.github/workflows/ci.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
matrix:
3131
arch:
3232
- amd64
33-
- arm
33+
- arm64
3434
os:
3535
- ubuntu-24.04
3636
python:
@@ -41,7 +41,7 @@ jobs:
4141
# that uses the same venv to run multiple linting sessions
4242
- "ci_checks_max"
4343
- "pytest_min"
44-
runs-on: ${{ matrix.os }}${{ matrix.arch != 'amd64' && format('-{0}', matrix.arch) || '' }}
44+
runs-on: ${{ matrix.os }}${{ matrix.arch == 'arm64' && (github.repository_visibility == 'private' && '-arm64' || '-arm') || '' }}
4545

4646
steps:
4747
- name: Run nox
@@ -114,13 +114,13 @@ jobs:
114114
matrix:
115115
arch:
116116
- amd64
117-
- arm
117+
- arm64
118118
os:
119119
- ubuntu-24.04
120120
python:
121121
- "3.11"
122122
- "3.12"
123-
runs-on: ${{ matrix.os }}${{ matrix.arch != 'amd64' && format('-{0}', matrix.arch) || '' }}
123+
runs-on: ${{ matrix.os }}${{ matrix.arch == 'arm64' && (github.repository_visibility == 'private' && '-arm64' || '-arm') || '' }}
124124

125125
steps:
126126
- name: Setup Git

0 commit comments

Comments
 (0)