-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add composite action to add vendordeps and make a PR #60
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: 'Add Vendordep' | ||
description: 'Adds a vendordep to the repository and creates a pull request the upstream repo' | ||
|
||
inputs: | ||
token: | ||
description: 'Build Buddy API token' | ||
required: true | ||
vendordep_file: | ||
description: 'Path to the vendordep file to upload' | ||
Comment on lines
+8
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this need to be absolute (since it's used inside the vendor-json-repo directory)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes |
||
required: true | ||
pr_title: | ||
description: 'The contents used as the PR title when opening the pull request' | ||
required: true | ||
pr_branch: | ||
description: 'The name of the branch to use when creating the pull request' | ||
required: true | ||
is_beta: | ||
description: "If true, this will be added to the years beta files" | ||
default: false | ||
required: false | ||
|
||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
repository: 'wpilibsuite/vendor-json-repo' | ||
fetch-depth: 0 # Fetch all history so we can use git diff | ||
path: "vendor-json-repo" | ||
ref: "main" | ||
|
||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.12' | ||
|
||
- name: Add vendordep | ||
shell: bash | ||
run: python add_vendordep.py --vendordep_file=$VENDORDEP_FILE --is_beta=$IS_BETA | ||
working-directory: vendor-json-repo | ||
env: | ||
VENDORDEP_FILE: ${{ inputs.vendordep_file }} | ||
IS_BETA: ${{ inputs.is_beta }} | ||
|
||
- name: Debug | ||
shell: bash | ||
run: git --no-pager diff | ||
working-directory: vendor-json-repo | ||
|
||
- name: Create Gentool Pull Request | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
path: vendor-json-repo | ||
base: main | ||
branch: ${{ inputs.pr_branch }} | ||
token: ${{ inputs.token }} | ||
title: ${{ inputs.pr_title }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to put There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would just add that as an input and let the downstream user decide |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import json | ||
import argparse | ||
from pathlib import Path | ||
import shutil | ||
|
||
|
||
def add_vendordep(vendordep_filename, is_beta): | ||
vendordep_contents = json.loads(vendordep_filename.read_bytes()) | ||
year = vendordep_contents['frcYear'] + "beta" if is_beta else "" | ||
|
||
year_filename = Path(f"{year}.json") | ||
year_contents = json.loads(year_filename.read_bytes()) | ||
|
||
metadata_filename = Path(f"{year}_metadata.json") | ||
metadata_contents = json.loads(metadata_filename.read_bytes()) | ||
|
||
for metadata_lib in metadata_contents: | ||
if metadata_lib["uuid"] == vendordep_contents["uuid"]: | ||
break | ||
else: | ||
raise Exception("This appears to be a new library that does not have metadata associated with it. Can not automatically update") | ||
|
||
vendordep_destination = Path(f"{year}/{vendordep_filename.name}") | ||
|
||
year_contents.append(dict( | ||
path=str(vendordep_destination), | ||
name=metadata_lib["name"], | ||
version=vendordep_contents["version"], | ||
uuid=metadata_lib["uuid"], | ||
description=metadata_lib["description"], | ||
website=metadata_lib["website"], | ||
)) | ||
Comment on lines
+25
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. YEAR.json is generated as an artifact automatically now, adding the json to the directory is all that's necessary There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where does this happen? If that happens I feel like there should be a gen-is-the-same test or these files can be removed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok so it happens in I think either these files should be generated and checked, or removed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They will be removed, but removing them will break beta 1 & 2 VS Code extensions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We've already broken them. I'm working on removing all the obsolete stuff and documenting the new process |
||
|
||
year_filename.write_text(json.dumps(year_contents, indent=2)) | ||
shutil.copy(vendordep_filename, vendordep_destination) | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser( | ||
"Generates one or more vendordep repository bundles for publication" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. needs changed |
||
) | ||
parser.add_argument( | ||
"--vendordep_file", | ||
type=Path | ||
) | ||
parser.add_argument( | ||
"--is_beta", | ||
type=bool | ||
) | ||
args = parser.parse_args() | ||
|
||
add_vendordep(args.vendordep_file, args.is_beta) | ||
|
||
|
||
|
||
|
||
if __name__ == "__main__": | ||
main() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.