Skip to content

Commit d310e8c

Browse files
committed
fixup! ci: overhaul CI
1 parent 45f5f0c commit d310e8c

File tree

3 files changed

+27
-16
lines changed

3 files changed

+27
-16
lines changed

.github/scripts/ci_config.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import argparse
1313
import json
14+
import os
1415
import subprocess
1516
import sys
1617
from pathlib import Path
@@ -55,15 +56,24 @@ def github_group_end():
5556
print("::endgroup::", flush=True)
5657

5758

59+
def github_output(name: str, value: str):
60+
"""Write a GitHub Actions output variable."""
61+
output_file = os.environ.get("GITHUB_OUTPUT")
62+
if output_file:
63+
with open(output_file, "a") as f:
64+
f.write(f"{name}={value}\n")
65+
66+
5867
def verify_groups(args):
5968
"""Verify all workspace crates are assigned to test groups."""
6069
metadata = get_workspace_metadata()
6170
workspace_crates = {pkg["name"] for pkg in metadata["packages"]}
6271

6372
config = load_yaml(args.groups_file)
73+
groups = config.get("groups", {})
6474

6575
assigned = set()
66-
for group_crates in config.get("groups", {}).values():
76+
for group_crates in groups.values():
6777
if group_crates:
6878
assigned.update(group_crates)
6979
assigned.update(config.get("excluded", []) or [])
@@ -77,6 +87,10 @@ def verify_groups(args):
7787
return 1
7888

7989
print(f"All {len(workspace_crates)} workspace crates are assigned to test groups")
90+
91+
# Output groups for GitHub Actions matrix
92+
github_output("groups", json.dumps(list(groups.keys())))
93+
8094
return 0
8195

8296

.github/workflows/build-and-test.yml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,18 @@ on:
66
os:
77
required: true
88
type: string
9+
groups:
10+
required: true
11+
type: string
912

1013
jobs:
11-
load-groups:
12-
name: Load groups
13-
runs-on: ubuntu-latest
14-
outputs:
15-
groups: ${{ steps.get-groups.outputs.groups }}
16-
steps:
17-
- uses: actions/checkout@v6
18-
- id: get-groups
19-
run: |
20-
groups=$(python3 -c "import yaml, json; print(json.dumps(list(yaml.safe_load(open('.github/ci-groups.yml'))['groups'].keys())))")
21-
echo "groups=$groups" >> "$GITHUB_OUTPUT"
22-
2314
test:
2415
name: ${{ matrix.group }}
25-
needs: load-groups
2616
runs-on: ${{ inputs.os }}
2717
strategy:
2818
fail-fast: false
2919
matrix:
30-
group: ${{ fromJson(needs.load-groups.outputs.groups) }}
20+
group: ${{ fromJson(inputs.groups) }}
3121
steps:
3222
- uses: actions/checkout@v6
3323
- uses: dtolnay/rust-toolchain@stable

.github/workflows/rust.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ jobs:
4848
verify-execution:
4949
name: Verify Test Execution
5050
runs-on: ubuntu-latest
51+
outputs:
52+
groups: ${{ steps.verify.outputs.groups }}
5153
steps:
5254
- uses: actions/checkout@v6
5355
- uses: actions/setup-python@v5
@@ -56,7 +58,8 @@ jobs:
5658
cache: "pip"
5759
cache-dependency-path: .github/scripts/requirements.txt
5860
- run: pip install -r .github/scripts/requirements.txt
59-
- name: Check all crates are assigned to test groups
61+
- name: Verify all creates are assigned and get matrix
62+
id: verify
6063
run: python .github/scripts/ci_config.py verify-groups
6164

6265
test-ubuntu:
@@ -65,27 +68,31 @@ jobs:
6568
uses: ./.github/workflows/build-and-test.yml
6669
with:
6770
os: ubuntu-latest
71+
groups: ${{ needs.verify-execution.outputs.groups }}
6872

6973
test-ubuntu-arm:
7074
name: Ubuntu ARM
7175
needs: verify-execution
7276
uses: ./.github/workflows/build-and-test.yml
7377
with:
7478
os: ubuntu-22.04-arm
79+
groups: ${{ needs.verify-execution.outputs.groups }}
7580

7681
test-macos:
7782
name: macOS
7883
needs: verify-execution
7984
uses: ./.github/workflows/build-and-test.yml
8085
with:
8186
os: macos-latest
87+
groups: ${{ needs.verify-execution.outputs.groups }}
8288

8389
test-windows:
8490
name: Windows
8591
needs: verify-execution
8692
uses: ./.github/workflows/build-and-test.yml
8793
with:
8894
os: windows-latest
95+
groups: ${{ needs.verify-execution.outputs.groups }}
8996

9097
no-std:
9198
name: No-std Checks

0 commit comments

Comments
 (0)