-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Make CI only build/test modules with any changes #10323
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
Changes from all commits
54f1931
1d81b4f
b5433e4
c56f778
9d5784d
70130f3
fb2e708
5f27804
f6ace6f
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,78 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| import argparse | ||
| import yaml | ||
| import json | ||
| import logging | ||
| import sys | ||
|
|
||
|
|
||
| def main(): | ||
| parser = argparse.ArgumentParser( | ||
| description="Filter test matrix modules using list of impacted modules." | ||
| ) | ||
| parser.add_argument( | ||
| "-m", | ||
| "--matrix", | ||
| type=argparse.FileType("r"), | ||
| default=".github/test-matrix.yaml", | ||
| help="A YAML file with the test matrix", | ||
| ) | ||
| parser.add_argument( | ||
| "-i", | ||
| "--impacted", | ||
| type=argparse.FileType("r"), | ||
| default="gib-impacted.log", | ||
| help="File containing list of impacted modules, one per line, " | ||
| "as paths, not artifact ids", | ||
| ) | ||
| parser.add_argument( | ||
| "-o", | ||
| "--output", | ||
| type=argparse.FileType("w"), | ||
| default=sys.stdout, | ||
| help="Filename to write impacted modules matrix JSON to", | ||
| ) | ||
| parser.add_argument( | ||
| "-v", | ||
| "--verbose", | ||
| action="store_const", | ||
| dest="loglevel", | ||
| const=logging.INFO, | ||
| default=logging.WARNING, | ||
| help="Print info level logs", | ||
| ) | ||
|
|
||
| args = parser.parse_args() | ||
| logging.basicConfig(level=args.loglevel) | ||
| build(args.matrix, args.impacted, args.output) | ||
|
|
||
|
|
||
| def build(matrix_file, impacted_file, output_file): | ||
|
Member
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'd propose (as a follow-up) to move this to a
Member
Author
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. Sure, I'm still waiting for some confirmation the whole idea is ok.
Member
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. bump, let's create follow-up issues to track |
||
| matrix = yaml.load(matrix_file, Loader=yaml.Loader) | ||
| impacted = list(filter(None, [line.strip() for line in impacted_file.readlines()])) | ||
| logging.info("Read matrix: %s", matrix) | ||
| logging.info("Read impacted: %s", impacted) | ||
| include = [] | ||
| for item in matrix.get("include", []): | ||
| modules = item.get("modules", []) | ||
| if isinstance(modules, str): | ||
| modules = [modules] | ||
| if not any(module in impacted for module in modules): | ||
| logging.info("Excluding matrix section: %s", item) | ||
| continue | ||
|
nineinchnick marked this conversation as resolved.
Outdated
|
||
| include.append( | ||
| { | ||
| # concatenate because matrix values should be primitives | ||
| "modules": ",".join(modules), | ||
| "profile": item.get("profile", ""), | ||
| } | ||
| ) | ||
| if include: | ||
| matrix["include"] = include | ||
| json.dump(matrix, output_file) | ||
| output_file.write("\n") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| #!/bin/bash | ||
|
hashhar marked this conversation as resolved.
Outdated
|
||
|
|
||
| set -euo pipefail | ||
|
|
||
| if [ -z "${GITHUB_BASE_REF:-}" ] || [ "$GITHUB_BASE_REF" == master ]; then | ||
| echo >&2 "GITHUB_BASE_REF is not set or is master, not fetching it" | ||
| exit 0 | ||
| fi | ||
|
|
||
| git fetch --no-tags --prune origin "$GITHUB_BASE_REF" | ||
Uh oh!
There was an error while loading. Please reload this page.