Skip to content

Commit

Permalink
Add regenerate example files mode
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Oct 30, 2024
1 parent c3fc9f9 commit 64e36bc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:

env:
PATH: /bin:/usr/bin:/usr/local/bin:/home/runner/.local/bin
REGENERATE_EXAMPLES: true

steps:
- name: GitHub event
Expand Down Expand Up @@ -115,7 +116,10 @@ jobs:
NODE_OPTIONS: --openssl-legacy-provider
if: github.event_name != 'pull_request_target'
- run: make check-examples-checker
if: github.event_name != 'pull_request_target'
if: |
github.event_name != 'pull_request_target'
&& env.REGENERATE_EXAMPLES == 'false'
# Cypress tests
- run: make serve-gmf-apps &
if: github.event_name != 'pull_request_target'
Expand All @@ -140,6 +144,7 @@ jobs:
if-no-files-found: ignore
retention-days: 5
if: always()
- run: '[ ${REGENERATE_EXAMPLES} == false ]'
- uses: actions/upload-artifact@v4
with:
name: GMF Examples
Expand All @@ -154,6 +159,8 @@ jobs:
if-no-files-found: ignore
retention-days: 5
if: always()
- run: find .build/examples-hosted ! -name *-ref.png -type f -exec rm {};
if: env.REGENERATE_EXAMPLES == 'true'
- uses: actions/upload-artifact@v4
with:
name: Examples hosted
Expand Down
11 changes: 9 additions & 2 deletions buildtools/check-example
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,15 @@ def main():
)
result = float(result.stdout.decode().splitlines()[-1].split()[1])
if result > 0.01:
print(f"{result} > 0.01 => {diff}")
sys.exit(1)
if os.environ.get("REGENERATE_EXAMPLES") == "true":
shutil.copyfile(current, old_ref)
print("Regenerate the ref image: " + old_ref)

else:
print(f"{result} > 0.01 => {diff}")
sys.exit(1)
elif os.environ.get("REGENERATE_EXAMPLES") == "true":
os.remove(old_ref)


if __name__ == "__main__":
Expand Down

0 comments on commit 64e36bc

Please sign in to comment.