Skip to content

Commit 7dc21f1

Browse files
committed
ci(build-depends.repos): separate repos for humble and nightly
Signed-off-by: Mete Fatih Cırıt <mfc@autoware.org>
1 parent 61530d6 commit 7dc21f1

12 files changed

+241
-35
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# combine-repos-action
2+
3+
## Description
4+
5+
**Combine Repos Action** is a GitHub Action designed to merge two `.repos` files—a base file and an overlay file—into a single file. The overlay file takes precedence over the base file when duplicate repository entries exist. This is especially useful for projects that need to dynamically combine configuration files for dependency management or CI workflows.
6+
7+
## Usage
8+
9+
Below is an example of how to include it in your workflow:
10+
11+
```yaml
12+
jobs:
13+
combine:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Combine Repos Files
20+
uses: ./.github/actions/combine-repos-action
21+
with:
22+
base_file: build_depends_humble.repos
23+
overlay_file: build_depends_nightly.repos
24+
output_file: build_depends.repos
25+
```
26+
27+
In this example:
28+
29+
- The action reads the `build_depends_humble.repos` file and the `build_depends_nightly.repos` file.
30+
- It merges them with overlay file taking precedence.
31+
- The resulting file is saved as `build_depends.repos` (or a custom filename if specified).
32+
33+
## Inputs
34+
35+
| Input | Description | Required | Default |
36+
| -------------- | --------------------------------- | -------- | ---------------- |
37+
| `base_file` | Path to the base `.repos` file | Yes | - |
38+
| `overlay_file` | Path to the overlay `.repos` file | Yes | - |
39+
| `output_file` | Path for the combined output file | No | `combined.repos` |
40+
41+
## Outputs
42+
43+
This action creates or updates the file specified by the `output_file` input with the combined contents of the two `.repos` files. The final file's content is also echoed to the workflow logs for easy verification.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Combine Repos Action
2+
description: Merge base and overlay .repos files, with overlay entries taking precedence.
3+
inputs:
4+
base_file:
5+
description: Path to the base .repos file
6+
required: true
7+
overlay_file:
8+
description: Path to the overlay .repos file
9+
required: true
10+
output_file:
11+
description: Path for the combined output file
12+
required: false
13+
default: combined.repos
14+
15+
runs:
16+
using: composite
17+
steps:
18+
- name: Install python3-pip
19+
run: |
20+
sudo apt-get -yqq update
21+
sudo apt-get -yqq install python3-pip python-is-python3
22+
shell: bash
23+
24+
- name: Display Python version
25+
run: |
26+
python --version
27+
which pip
28+
pip --version
29+
shell: bash
30+
31+
- name: Install PyYAML dependency
32+
run: pip install pyyaml
33+
shell: bash
34+
35+
- name: Combine repos files
36+
run: |
37+
python "${GITHUB_ACTION_PATH}/combine-repos.py" \
38+
--base "${{ inputs.base_file }}" \
39+
--overlay "${{ inputs.overlay_file }}" \
40+
--output "${{ inputs.output_file }}"
41+
shell: bash
42+
43+
- name: Display combined repos file
44+
run: |
45+
echo "=== Combined .repos File Content ==="
46+
cat "${{ inputs.output_file }}"
47+
echo "===================================="
48+
shell: bash
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env python3
2+
import argparse
3+
import sys
4+
5+
import yaml
6+
7+
8+
def main():
9+
parser = argparse.ArgumentParser(
10+
description="Merge base and overlay .repos files with overlay taking precedence."
11+
)
12+
parser.add_argument("--base", required=True, help="Path to the base .repos file")
13+
parser.add_argument("--overlay", required=True, help="Path to the overlay .repos file")
14+
parser.add_argument(
15+
"--output",
16+
default="combined.repos",
17+
help="Path for the combined output file (default: combined.repos)",
18+
)
19+
args = parser.parse_args()
20+
21+
try:
22+
with open(args.base, "r") as bf:
23+
base_data = yaml.safe_load(bf)
24+
except Exception as e:
25+
sys.exit(f"Error reading base file '{args.base}': {e}")
26+
27+
try:
28+
with open(args.overlay, "r") as of:
29+
overlay_data = yaml.safe_load(of)
30+
except Exception as e:
31+
sys.exit(f"Error reading overlay file '{args.overlay}': {e}")
32+
33+
if "repositories" not in base_data:
34+
sys.exit(f"Base file '{args.base}' is missing the 'repositories' key")
35+
if overlay_data and "repositories" not in overlay_data:
36+
sys.exit(f"Overlay file '{args.overlay}' is missing the 'repositories' key")
37+
38+
# Merge: overlay entries override base entries
39+
merged_data = base_data.copy()
40+
merged_data["repositories"].update(overlay_data.get("repositories", {}))
41+
42+
try:
43+
with open(args.output, "w") as cf:
44+
yaml.dump(merged_data, cf, default_flow_style=False)
45+
except Exception as e:
46+
sys.exit(f"Error writing to output file '{args.output}': {e}")
47+
48+
print(f"Successfully merged into {args.output}")
49+
50+
51+
if __name__ == "__main__":
52+
main()

.github/sync-files.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
dest: .github/pull_request_template.md
1010
- source: .github/stale.yml
1111
- source: .github/workflows/cancel-previous-workflows.yaml
12-
- source: .github/workflows/check-build-depends.yaml
1312
- source: .github/workflows/clang-tidy-pr-comments.yaml
1413
- source: .github/workflows/clang-tidy-pr-comments-manually.yaml
1514
- source: .github/workflows/comment-on-pr.yaml

.github/workflows/build-and-test-daily-arm64.yaml

+9-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ jobs:
2424
include:
2525
- rosdistro: humble
2626
container: ghcr.io/autowarefoundation/autoware:universe-devel
27-
build-depends-repos: build_depends.repos
2827
steps:
2928
- name: Check out repository
3029
uses: actions/checkout@v4
@@ -54,13 +53,20 @@ jobs:
5453
echo "::notice::BUILD_TYPE_CUDA_STATE=$build_type_cuda_state"
5554
shell: bash
5655

56+
- name: Prepare build_depends.repos file
57+
uses: ./.github/actions/combine-repos-action
58+
with:
59+
base_file: build_depends_humble.repos
60+
overlay_file: build_depends_nightly.repos
61+
output_file: build_depends.repos
62+
5763
- name: Build
5864
if: ${{ steps.get-self-packages.outputs.self-packages != '' }}
5965
uses: autowarefoundation/autoware-github-actions/colcon-build@v1
6066
with:
6167
rosdistro: ${{ matrix.rosdistro }}
6268
target-packages: ${{ steps.get-self-packages.outputs.self-packages }}
63-
build-depends-repos: ${{ matrix.build-depends-repos }}
69+
build-depends-repos: build_depends.repos
6470
cache-key-element: ${{ env.BUILD_TYPE_CUDA_STATE }}
6571
build-pre-command: taskset --cpu-list 0-6
6672

@@ -71,7 +77,7 @@ jobs:
7177
with:
7278
rosdistro: ${{ matrix.rosdistro }}
7379
target-packages: ${{ steps.get-self-packages.outputs.self-packages }}
74-
build-depends-repos: ${{ matrix.build-depends-repos }}
80+
build-depends-repos: build_depends.repos
7581

7682
- name: Upload coverage to CodeCov
7783
if: ${{ steps.test.outputs.coverage-report-files != '' }}

.github/workflows/build-and-test-daily.yaml

+9-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ jobs:
2424
include:
2525
- rosdistro: humble
2626
container: ghcr.io/autowarefoundation/autoware:universe-devel
27-
build-depends-repos: build_depends.repos
2827
steps:
2928
- name: Check out repository
3029
uses: actions/checkout@v4
@@ -81,13 +80,20 @@ jobs:
8180
echo "::notice::BUILD_TYPE_CUDA_STATE=$build_type_cuda_state"
8281
shell: bash
8382

83+
- name: Prepare build_depends.repos file
84+
uses: ./.github/actions/combine-repos-action
85+
with:
86+
base_file: build_depends_humble.repos
87+
overlay_file: build_depends_nightly.repos
88+
output_file: build_depends.repos
89+
8490
- name: Build
8591
if: ${{ steps.get-self-packages.outputs.self-packages != '' }}
8692
uses: autowarefoundation/autoware-github-actions/colcon-build@v1
8793
with:
8894
rosdistro: ${{ matrix.rosdistro }}
8995
target-packages: ${{ steps.get-self-packages.outputs.self-packages }}
90-
build-depends-repos: ${{ matrix.build-depends-repos }}
96+
build-depends-repos: build_depends.repos
9197
cache-key-element: ${{ env.BUILD_TYPE_CUDA_STATE }}
9298

9399
- name: Show ccache stats after build
@@ -101,7 +107,7 @@ jobs:
101107
with:
102108
rosdistro: ${{ matrix.rosdistro }}
103109
target-packages: ${{ steps.get-self-packages.outputs.self-packages }}
104-
build-depends-repos: ${{ matrix.build-depends-repos }}
110+
build-depends-repos: build_depends.repos
105111

106112
- name: Upload coverage to CodeCov
107113
if: ${{ steps.test.outputs.coverage-report-files != '' }}

.github/workflows/build-and-test-differential-arm64.yaml

+15-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ jobs:
3434
include:
3535
- rosdistro: humble
3636
container: ghcr.io/autowarefoundation/autoware:universe-devel
37-
build-depends-repos: build_depends.repos
3837
steps:
3938
- name: Set PR fetch depth
4039
run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"
@@ -68,13 +67,26 @@ jobs:
6867
echo "::notice::BUILD_TYPE_CUDA_STATE=$build_type_cuda_state"
6968
shell: bash
7069

70+
- name: Prepare build_depends.repos file (main branch)
71+
if: ${{ github.event.pull_request.base.ref == 'main' }}
72+
uses: ./.github/actions/combine-repos-action
73+
with:
74+
base_file: build_depends_humble.repos
75+
overlay_file: build_depends_nightly.repos
76+
output_file: build_depends.repos
77+
78+
- name: Prepare build_depends.repos file (humble branch)
79+
if: ${{ github.event.pull_request.base.ref == 'humble' }}
80+
run: cp build_depends_humble.repos build_depends.repos
81+
shell: bash
82+
7183
- name: Build
7284
if: ${{ steps.get-modified-packages.outputs.modified-packages != '' }}
7385
uses: autowarefoundation/autoware-github-actions/colcon-build@v1
7486
with:
7587
rosdistro: ${{ matrix.rosdistro }}
7688
target-packages: ${{ steps.get-modified-packages.outputs.modified-packages }}
77-
build-depends-repos: ${{ matrix.build-depends-repos }}
89+
build-depends-repos: build_depends.repos
7890
cache-key-element: ${{ env.BUILD_TYPE_CUDA_STATE }}
7991
build-pre-command: taskset --cpu-list 0-5
8092

@@ -85,7 +97,7 @@ jobs:
8597
with:
8698
rosdistro: ${{ matrix.rosdistro }}
8799
target-packages: ${{ steps.get-modified-packages.outputs.modified-packages }}
88-
build-depends-repos: ${{ matrix.build-depends-repos }}
100+
build-depends-repos: build_depends.repos
89101

90102
- name: Upload coverage to CodeCov
91103
if: ${{ steps.test.outputs.coverage-report-files != '' }}

.github/workflows/build-and-test-differential.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,19 @@ jobs:
9292
echo "::notice::BUILD_TYPE_CUDA_STATE=$build_type_cuda_state"
9393
shell: bash
9494

95+
- name: Prepare build_depends.repos file (main branch)
96+
if: ${{ github.event.pull_request.base.ref == 'main' }}
97+
uses: ./.github/actions/combine-repos-action
98+
with:
99+
base_file: build_depends_humble.repos
100+
overlay_file: build_depends_nightly.repos
101+
output_file: build_depends.repos
102+
103+
- name: Prepare build_depends.repos file (humble branch)
104+
if: ${{ github.event.pull_request.base.ref == 'humble' }}
105+
run: cp build_depends_humble.repos build_depends.repos
106+
shell: bash
107+
95108
- name: Build
96109
if: ${{ steps.get-modified-packages.outputs.modified-packages != '' }}
97110
uses: autowarefoundation/autoware-github-actions/colcon-build@v1

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

+9-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ jobs:
2828
include:
2929
- rosdistro: humble
3030
container: ghcr.io/autowarefoundation/autoware:universe-devel
31-
build-depends-repos: build_depends.repos
3231
steps:
3332
- name: Check out repository
3433
uses: actions/checkout@v4
@@ -85,13 +84,20 @@ jobs:
8584
echo "::notice::BUILD_TYPE_CUDA_STATE=$build_type_cuda_state"
8685
shell: bash
8786

87+
- name: Prepare build_depends.repos file
88+
uses: ./.github/actions/combine-repos-action
89+
with:
90+
base_file: build_depends_humble.repos
91+
overlay_file: build_depends_nightly.repos
92+
output_file: build_depends.repos
93+
8894
- name: Build
8995
if: ${{ steps.get-self-packages.outputs.self-packages != '' }}
9096
uses: autowarefoundation/autoware-github-actions/colcon-build@v1
9197
with:
9298
rosdistro: ${{ matrix.rosdistro }}
9399
target-packages: ${{ steps.get-self-packages.outputs.self-packages }}
94-
build-depends-repos: ${{ matrix.build-depends-repos }}
100+
build-depends-repos: build_depends.repos
95101
cache-key-element: ${{ env.BUILD_TYPE_CUDA_STATE }}
96102
build-pre-command: taskset --cpu-list 0-5
97103

@@ -115,7 +121,7 @@ jobs:
115121
with:
116122
rosdistro: ${{ matrix.rosdistro }}
117123
target-packages: ${{ steps.get-self-packages.outputs.self-packages }}
118-
build-depends-repos: ${{ matrix.build-depends-repos }}
124+
build-depends-repos: build_depends.repos
119125

120126
- name: Upload coverage to CodeCov
121127
if: ${{ steps.test.outputs.coverage-report-files != '' }}

.github/workflows/check-build-depends.yaml

+14-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# This file is automatically synced from:
2-
# https://github.com/autowarefoundation/sync-file-templates
3-
# To make changes, update the source repository and follow the guidelines in its README.
4-
51
name: check-build-depends
62

73
on:
@@ -21,7 +17,6 @@ jobs:
2117
include:
2218
- rosdistro: humble
2319
container: ros:humble
24-
build-depends-repos: build_depends.repos
2520
steps:
2621
- name: Check out repository
2722
uses: actions/checkout@v4
@@ -33,9 +28,22 @@ jobs:
3328
id: get-self-packages
3429
uses: autowarefoundation/autoware-github-actions/get-self-packages@v1
3530

31+
- name: Prepare build_depends.repos file (main branch)
32+
if: ${{ github.event.pull_request.base.ref == 'main' }}
33+
uses: ./.github/actions/combine-repos-action
34+
with:
35+
base_file: build_depends_humble.repos
36+
overlay_file: build_depends_nightly.repos
37+
output_file: build_depends.repos
38+
39+
- name: Prepare build_depends.repos file (humble branch)
40+
if: ${{ github.event.pull_request.base.ref == 'humble' }}
41+
run: cp build_depends_humble.repos build_depends.repos
42+
shell: bash
43+
3644
- name: Build
3745
uses: autowarefoundation/autoware-github-actions/colcon-build@v1
3846
with:
3947
rosdistro: ${{ matrix.rosdistro }}
4048
target-packages: ${{ steps.get-self-packages.outputs.self-packages }}
41-
build-depends-repos: ${{ matrix.build-depends-repos }}
49+
build-depends-repos: build_depends.repos

0 commit comments

Comments
 (0)