Skip to content

Commit 9997240

Browse files
authored
Test PR process (#3)
1 parent 7a9b902 commit 9997240

File tree

12 files changed

+64
-40
lines changed

12 files changed

+64
-40
lines changed

.github/workflows/_ci_build.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
config:
3939
runs-on: ubuntu-latest
4040
outputs:
41-
CI_RUNNER: ${{ steps.config.outputs.RUNNER }}
41+
CI_RUNNER: ${{ steps.config.outputs.CI_RUNNER }}
4242
CI_TESTER_IMAGE: ${{ steps.config.outputs.CI_TESTER_IMAGE }}
4343
LOCAL_TESTER_IMAGE: ${{ steps.config.outputs.LOCAL_TESTER_IMAGE }}
4444
LOCAL_TESTER_RESULTS: ${{ steps.config.outputs.LOCAL_TESTER_RESULTS }}
@@ -70,7 +70,8 @@ jobs:
7070
LOGIN_DOCKERHUB = cfg.dyn.ci.login_dockerhub
7171
LOGIN_GITHUB = cfg.dyn.ci.login_github
7272
TEST_DATE = cfg.dyn.test_date
73-
""")
73+
""",
74+
inputs="""${{ toJson(inputs) }}""")
7475
7576
- name: Validate code
7677
run: |

.github/workflows/deb_release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
config:
2323
runs-on: ubuntu-latest
2424
outputs:
25+
DEB_ENABLED: ${{steps.config.outputs.DEB_ENABLED}}
2526
DEB_BASE_IMAGES: ${{steps.config.outputs.DEB_BASE_IMAGES}}
2627
DEB_BUILD_ARCHITECTURES: ${{steps.config.outputs.DEB_BUILD_ARCHITECTURES}}
2728
DEB_ARTIFACTS_PREFIX: ${{steps.config.outputs.DEB_ARTIFACTS_PREFIX}}
@@ -45,10 +46,12 @@ jobs:
4546
DEB_BASE_IMAGES = cfg.dyn.debian.base_images_matrix
4647
DEB_BUILD_ARCHITECTURES = cfg.dyn.debian.build_architectures_matrix
4748
DEB_ARTIFACTS_PREFIX = cfg.debian.artifacts_prefix
49+
DEB_ENABLED = cfg.dyn.debian.enabled
4850
""")
4951
5052
build-packages:
5153
needs: config
54+
if: needs.config.outputs.DEB_ENABLED
5255
strategy:
5356
matrix:
5457
base-image: ${{ fromJson(needs.config.outputs.DEB_BASE_IMAGES ) }}

.github/workflows/pull_request.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
BASIC_VALIDATION_BUILD_PLATFORMS: ${{ steps.config.outputs.BASIC_VALIDATION_BUILD_PLATFORMS }}
3838
BASIC_VALIDATION_BASE_IMAGES: ${{ steps.config.outputs.BASIC_VALIDATION_BASE_IMAGES }}
3939
DEB_VALIDATION_BASE_IMAGES: ${{ steps.config.outputs.DEB_VALIDATION_BASE_IMAGES }}
40-
DEB_VALIDATION_BUILD_PLATFORMS: ${{ steps.config.outputs.DEB_VALIDATION_BUILD_PLATFORMS }}
40+
DEB_VALIDATION_BUILD_ARCHITECTURES: ${{ steps.config.outputs.DEB_VALIDATION_BUILD_ARCHITECTURES }}
4141
FULL_VALIDATION_BASE_IMAGES: ${{ steps.config.outputs.FULL_VALIDATION_BASE_IMAGES }}
4242
FULL_VALIDATION_BUILD_PLATFORMS: ${{ steps.config.outputs.FULL_VALIDATION_BUILD_PLATFORMS }}
4343
VALIDATE_BASIC: ${{ steps.config.outputs.VALIDATE_BASIC }}
@@ -98,11 +98,11 @@ jobs:
9898
if: ${{ needs.check-trigger.outputs.VALIDATE_DEB }}
9999
strategy:
100100
matrix:
101-
build-platform: ${{ fromJson(needs.check-trigger.outputs.DEB_VALIDATION_BUILD_PLATFORMS) }}
101+
build-architecture: ${{ fromJson(needs.check-trigger.outputs.DEB_VALIDATION_BUILD_ARCHITECTURES) }}
102102
base-image: ${{ fromJson(needs.check-trigger.outputs.DEB_VALIDATION_BASE_IMAGES) }}
103103
uses: ./.github/workflows/_deb_build.yml
104104
secrets: inherit
105105
with:
106106
base-image: ${{ matrix.base-image }}
107-
build-platform: ${{ matrix.build-platform }}
107+
build-architecture: ${{ matrix.build-architecture }}
108108

.github/workflows/pull_request_closed.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ permissions:
2727

2828
env:
2929
CLONE_DIR: src/repo
30-
ADMIN_IMAGE: ghcr.io/${{ github.repository }}-admin:latest
3130

3231
jobs:
3332
cleanup_jobs:
@@ -42,6 +41,19 @@ jobs:
4241
with:
4342
path: ${{ env.CLONE_DIR }}
4443
submodules: true
44+
45+
- name: Configure workflow
46+
id: config
47+
shell: python
48+
run: |
49+
import sys
50+
sys.path.insert(0, "${{ env.CLONE_DIR }}/.github")
51+
from workflows_pyconfig import configure
52+
configure(
53+
github="""${{ toJson(github) }}""",
54+
outputs="""\
55+
ADMIN_IMAGE = cfg.ci.admin_image
56+
""")
4557
4658
- name: Log in to GitHub
4759
uses: docker/login-action@v3
@@ -56,7 +68,7 @@ jobs:
5668
-v $(pwd):/workspace \
5769
-e GH_TOKEN=${GH_TOKEN} \
5870
-w /workspace \
59-
${ADMIN_IMAGE} \
71+
${{steps.config.outputs.ADMIN_IMAGE}} \
6072
${{ env.CLONE_DIR }}/scripts/ci-admin \
6173
-c ${{ github.run_id }} \
6274
pr-closed \

.github/workflows/release_cleanup.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ permissions:
1919

2020
env:
2121
CLONE_DIR: src/repo
22-
ADMIN_IMAGE: ghcr.io/${{ github.repository }}-admin:latest
2322

2423
jobs:
2524
cleanup_jobs:
@@ -32,13 +31,26 @@ jobs:
3231
path: ${{ env.CLONE_DIR }}
3332
submodules: true
3433

34+
- name: Configure workflow
35+
id: config
36+
shell: python
37+
run: |
38+
import sys
39+
sys.path.insert(0, "${{ env.CLONE_DIR }}/.github")
40+
from workflows_pyconfig import configure
41+
configure(
42+
github="""${{ toJson(github) }}""",
43+
outputs="""\
44+
ADMIN_IMAGE = cfg.ci.admin_image
45+
""")
46+
3547
- name: "Clean up workflow runs"
3648
run: |
3749
docker run --rm \
3850
-v $(pwd):/workspace \
3951
-e GH_TOKEN=${GH_TOKEN} \
4052
-w /workspace \
41-
${ADMIN_IMAGE} \
53+
${{steps.config.outputs.ADMIN_IMAGE}} \
4254
${{ env.CLONE_DIR }}/scripts/ci-admin \
4355
-c ${{ github.run_id }} \
4456
nightly-cleanup \

.github/workflows_pyconfig/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
def _dict_to_tuple(key: str, val: dict) -> NamedTuple:
3131
fields = {}
3232
for k, v in val.items():
33+
if k.startswith("_"):
34+
# field unsupported by namedtuple
35+
continue
3336
if isinstance(v, dict):
3437
v = _dict_to_tuple(k, v)
3538
k = k.replace("-", "_").replace("/", "_")

.github/workflows_pyconfig/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ def settings(cfg: NamedTuple, github: NamedTuple) -> dict:
126126
]
127127
)
128128

129+
debian_enabled = (clone_dir / "debian" / "control").is_file()
129130
debian_base_images_matrix = json.dumps(cfg.debian.base_images)
130131
debian_build_architectures_matrix = json.dumps(cfg.debian.build_architectures)
131132
debian_registries = _extract_registries(
@@ -168,6 +169,7 @@ def settings(cfg: NamedTuple, github: NamedTuple) -> dict:
168169
"debian": {
169170
"base_images_matrix": debian_base_images_matrix,
170171
"build_architectures_matrix": debian_build_architectures_matrix,
172+
"enabled": debian_enabled,
171173
"login_dockerhub": "dockerhub" in debian_registries,
172174
"login_github": "github" in debian_registries,
173175
},

.github/workflows_pyconfig/settings.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ pull_request:
4747
deb:
4848
base_images:
4949
- ubuntu:22.04
50-
build_platforms:
51-
- linux/amd64
50+
build_architectures:
51+
- amd64
5252

5353
#############################################################################
5454
# Release settings

.github/workflows_pyconfig/workflows/ci_build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def configure(cfg: NamedTuple, github: NamedTuple, inputs: NamedTuple) -> dict:
2121
runner = json.dumps(getattr(cfg.ci.runners, inputs.build_platform.replace("/", "_")))
2222

2323
repo = github.repository.split("/")[-1]
24-
build_platform_label = cfg.dyn.build.platform.replace("/", "-")
24+
build_platform_label = inputs.build_platform.replace("/", "-")
2525
base_image_tag = inputs.base_image.replace(":", "-")
2626
ci_tester_image = f"{cfg.ci.ci_tester_repo}:{base_image_tag}"
2727

.github/workflows_pyconfig/workflows/pull_request.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ def configure(cfg: NamedTuple, github: NamedTuple, inputs: NamedTuple) -> dict:
9696
)
9797
result_basic = review_state != "approved"
9898

99+
# Debian testing requires a debian package.
100+
result_deb = result_deb and (clone_dir / "debian" / "control").is_file()
101+
99102
print(f"PR {pr_no} configuration: basic={result_basic}, full={result_full}, deb={result_deb}")
100103

101104
return {
@@ -104,7 +107,9 @@ def configure(cfg: NamedTuple, github: NamedTuple, inputs: NamedTuple) -> dict:
104107
cfg.pull_request.validation.basic.build_platforms
105108
),
106109
"DEB_VALIDATION_BASE_IMAGES": json.dumps(cfg.pull_request.validation.deb.base_images),
107-
"DEB_VALIDATION_BUILD_PLATFORMS": json.dumps(cfg.pull_request.validation.deb.build_platforms),
110+
"DEB_VALIDATION_BUILD_ARCHITECTURES": json.dumps(
111+
cfg.pull_request.validation.deb.build_architectures
112+
),
108113
"FULL_VALIDATION_BASE_IMAGES": json.dumps(cfg.pull_request.validation.full.base_images),
109114
"FULL_VALIDATION_BUILD_PLATFORMS": json.dumps(cfg.pull_request.validation.full.build_platforms),
110115
"VALIDATE_FULL": result_full,

0 commit comments

Comments
 (0)