ci: automate renderdiff golden image updates (#9740)
- Introduces the `RDIFF_ACCEPT_NEW_GOLDENS` commit message tag. - Conditionally skip the `test-renderdiff` presubmit comparison if this tag is present. - Extracts renderdiff generation into a reusable `.github/actions/renderdiff-generate` composite action. - Modifies `postsubmit-main.yml` to automatically generate new goldens and push them to a temporary `accept-goldens-<short-hash>` branch before merging them into `main` when the tag is found.
This commit is contained in:
@@ -114,6 +114,24 @@ Doing the above has multiple effects:
|
||||
- If the PR is merged, then there is another workflow that will merge `my-pr-branch-golden`
|
||||
to the `main` branch of the golden repo.
|
||||
|
||||
### Automated update via commit message
|
||||
|
||||
Alternatively, if you are confident in your changes and want the CI to handle the update
|
||||
for you, you can use the following tag in your commit message:
|
||||
|
||||
- In the commit message of your working branch on `filament`, add the following line:
|
||||
```
|
||||
RDIFF_ACCEPT_NEW_GOLDENS
|
||||
```
|
||||
|
||||
This has the following effects:
|
||||
- The presubmit test `test-renderdiff` will be bypassed (it will not perform rendering or
|
||||
comparison).
|
||||
- When the PR is merged, the postsubmit CI will automatically:
|
||||
1. Build Filament and generate the new images.
|
||||
2. Upload them to a temporary branch in `filament-assets`.
|
||||
3. Merge that branch into `main`.
|
||||
|
||||
## Viewing test results
|
||||
|
||||
We provide a viewer for looking at the result of a test run. The viewer is a webapp that can
|
||||
|
||||
@@ -18,6 +18,7 @@ import re
|
||||
from utils import execute, ArgParseImpl
|
||||
|
||||
RDIFF_UPDATE_GOLDEN_STR = 'RDIFF_BRANCH'
|
||||
RDIFF_ACCEPT_NEW_GOLDENS_STR = 'RDIFF_ACCEPT_NEW_GOLDENS'
|
||||
|
||||
def _parse_commit(commit_str):
|
||||
lines = commit_str.split('\n')
|
||||
@@ -42,9 +43,11 @@ def _parse_commit(commit_str):
|
||||
|
||||
if __name__ == "__main__":
|
||||
RE_STR = rf"{RDIFF_UPDATE_GOLDEN_STR}(?:\s)?\=(?:\s)?([a-zA-Z0-9\s\-\/]+)"
|
||||
RE_ACCEPT = rf"^{RDIFF_ACCEPT_NEW_GOLDENS_STR}$"
|
||||
|
||||
parser = ArgParseImpl()
|
||||
parser.add_argument('--file', help='A file containing the commit message')
|
||||
parser.add_argument('--mode', choices=['branch', 'accept_new_goldens'], default='branch', help='Mode of operation')
|
||||
args, _ = parser.parse_known_args(sys.argv[1:])
|
||||
|
||||
if not args.file:
|
||||
@@ -53,14 +56,21 @@ if __name__ == "__main__":
|
||||
with open(args.file, 'r') as f:
|
||||
msg = f.read()
|
||||
|
||||
to_update = []
|
||||
commit, title, description = _parse_commit(msg)
|
||||
|
||||
if args.mode == 'accept_new_goldens':
|
||||
for line in description:
|
||||
if re.match(RE_ACCEPT, line):
|
||||
sys.exit(0)
|
||||
sys.exit(1)
|
||||
|
||||
# args.mode == 'branch'
|
||||
for line in description:
|
||||
m = re.match(RE_STR, line)
|
||||
if not m:
|
||||
continue
|
||||
print(m.group(1))
|
||||
exit(0)
|
||||
sys.exit(0)
|
||||
|
||||
# Always default to the main branch
|
||||
print('main')
|
||||
|
||||
Reference in New Issue
Block a user