forked from autowarefoundation/autoware.universe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(build-depends.repos): separate repos for humble and nightly (autow…
…arefoundation#10148) Signed-off-by: Mete Fatih Cırıt <[email protected]>
- Loading branch information
Showing
12 changed files
with
241 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# combine-repos-action | ||
|
||
## Description | ||
|
||
**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. | ||
|
||
## Usage | ||
|
||
Below is an example of how to include it in your workflow: | ||
|
||
```yaml | ||
jobs: | ||
combine: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Combine Repos Files | ||
uses: ./.github/actions/combine-repos-action | ||
with: | ||
base_file: build_depends_humble.repos | ||
overlay_file: build_depends_nightly.repos | ||
output_file: build_depends.repos | ||
``` | ||
In this example: | ||
- The action reads the `build_depends_humble.repos` file and the `build_depends_nightly.repos` file. | ||
- It merges them with overlay file taking precedence. | ||
- The resulting file is saved as `build_depends.repos` (or a custom filename if specified). | ||
|
||
## Inputs | ||
|
||
| Input | Description | Required | Default | | ||
| -------------- | --------------------------------- | -------- | ---------------- | | ||
| `base_file` | Path to the base `.repos` file | Yes | - | | ||
| `overlay_file` | Path to the overlay `.repos` file | Yes | - | | ||
| `output_file` | Path for the combined output file | No | `combined.repos` | | ||
|
||
## Outputs | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Combine Repos Action | ||
description: Merge base and overlay .repos files, with overlay entries taking precedence. | ||
inputs: | ||
base_file: | ||
description: Path to the base .repos file | ||
required: true | ||
overlay_file: | ||
description: Path to the overlay .repos file | ||
required: true | ||
output_file: | ||
description: Path for the combined output file | ||
required: false | ||
default: combined.repos | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Install python3-pip | ||
run: | | ||
sudo apt-get -yqq update | ||
sudo apt-get -yqq install python3-pip python-is-python3 | ||
shell: bash | ||
|
||
- name: Display Python version | ||
run: | | ||
python --version | ||
which pip | ||
pip --version | ||
shell: bash | ||
|
||
- name: Install PyYAML dependency | ||
run: pip install pyyaml | ||
shell: bash | ||
|
||
- name: Combine repos files | ||
run: | | ||
python "${GITHUB_ACTION_PATH}/combine-repos.py" \ | ||
--base "${{ inputs.base_file }}" \ | ||
--overlay "${{ inputs.overlay_file }}" \ | ||
--output "${{ inputs.output_file }}" | ||
shell: bash | ||
|
||
- name: Display combined repos file | ||
run: | | ||
echo "=== Combined .repos File Content ===" | ||
cat "${{ inputs.output_file }}" | ||
echo "====================================" | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env python3 | ||
import argparse | ||
import sys | ||
|
||
import yaml | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser( | ||
description="Merge base and overlay .repos files with overlay taking precedence." | ||
) | ||
parser.add_argument("--base", required=True, help="Path to the base .repos file") | ||
parser.add_argument("--overlay", required=True, help="Path to the overlay .repos file") | ||
parser.add_argument( | ||
"--output", | ||
default="combined.repos", | ||
help="Path for the combined output file (default: combined.repos)", | ||
) | ||
args = parser.parse_args() | ||
|
||
try: | ||
with open(args.base, "r") as bf: | ||
base_data = yaml.safe_load(bf) | ||
except Exception as e: | ||
sys.exit(f"Error reading base file '{args.base}': {e}") | ||
|
||
try: | ||
with open(args.overlay, "r") as of: | ||
overlay_data = yaml.safe_load(of) | ||
except Exception as e: | ||
sys.exit(f"Error reading overlay file '{args.overlay}': {e}") | ||
|
||
if "repositories" not in base_data: | ||
sys.exit(f"Base file '{args.base}' is missing the 'repositories' key") | ||
if overlay_data and "repositories" not in overlay_data: | ||
sys.exit(f"Overlay file '{args.overlay}' is missing the 'repositories' key") | ||
|
||
# Merge: overlay entries override base entries | ||
merged_data = base_data.copy() | ||
merged_data["repositories"].update(overlay_data.get("repositories", {})) | ||
|
||
try: | ||
with open(args.output, "w") as cf: | ||
yaml.dump(merged_data, cf, default_flow_style=False) | ||
except Exception as e: | ||
sys.exit(f"Error writing to output file '{args.output}': {e}") | ||
|
||
print(f"Successfully merged into {args.output}") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.