From 4dab6715240337a019ca2fe03db8adaa9a26f345 Mon Sep 17 00:00:00 2001 From: Oscar Vestlie Date: Tue, 20 Feb 2024 15:38:26 -0800 Subject: [PATCH 1/2] Only run main workflow if PR is open (#2457) b/326121096 --- .github/workflows/main.yaml | 1 + .github/workflows/main_win.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index b9b94ab8b1ba..e7f6f0981993 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -63,6 +63,7 @@ jobs: GITHUB_EVENT_NUMBER: ${{ github.event.number }} if: | github.event.action != 'labeled' || + github.event.pull_request.merged == false && ( github.event.action == 'labeled' && github.event.label.name == 'runtest' || diff --git a/.github/workflows/main_win.yaml b/.github/workflows/main_win.yaml index 77f55e7e87e0..146424bc2b74 100644 --- a/.github/workflows/main_win.yaml +++ b/.github/workflows/main_win.yaml @@ -55,6 +55,7 @@ jobs: # All triggers except draft PRs, unless PR is labeled with runtest if: | github.event.action != 'labeled' || + github.event.pull_request.merged == false && ( github.event.action == 'labeled' && github.event.label.name == 'runtest' || From e53d95b317bc49249cff0db3c3c6d16179725b6a Mon Sep 17 00:00:00 2001 From: Dana Dahlstrom Date: Tue, 20 Feb 2024 20:00:01 -0800 Subject: [PATCH 2/2] Check version against git-subtree-split trailer Issue: 150775273 Reviewed-on: https://github.com/youtube/cobalt/pull/2459 --- tools/metadata/validate.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/metadata/validate.py b/tools/metadata/validate.py index b048d81678dc..4eda21ad1aa9 100644 --- a/tools/metadata/validate.py +++ b/tools/metadata/validate.py @@ -50,6 +50,17 @@ def validate_content(textproto_content, if warn_deprecations and len(third_party.url) > 0: log.warning('"url" field is deprecated, please use "identifier" instead') + git_id = next((id for id in third_party.identifier if id.type == 'Git'), None) + if git_id: + subtree_dir = os.path.dirname(metadata_file_path).replace(os.sep, '/') + pattern = f'^git-subtree-dir: {subtree_dir}/*$' + log_format = '%(trailers:key=git-subtree-split,valueonly)' + args = ['git', 'log', '-1', f'--grep={pattern}', f'--pretty={log_format}'] + p = subprocess.run(args, capture_output=True, text=True, check=True) + split = p.stdout.strip() + if split and git_id.version != split: + raise RuntimeError(f'{git_id.version} does not match {split}') + def validate_file(metadata_file_path, warn_deprecations=False): logging.info('Validating %s', metadata_file_path)