Skip to content

Commit 4c6755a

Browse files
committed
Add regenerate example files mode
1 parent c3fc9f9 commit 4c6755a

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

.github/workflows/main.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434

3535
env:
3636
PATH: /bin:/usr/bin:/usr/local/bin:/home/runner/.local/bin
37+
REGENERATE_EXAMPLES: true
3738

3839
steps:
3940
- name: GitHub event
@@ -115,7 +116,10 @@ jobs:
115116
NODE_OPTIONS: --openssl-legacy-provider
116117
if: github.event_name != 'pull_request_target'
117118
- run: make check-examples-checker
118-
if: github.event_name != 'pull_request_target'
119+
if: |
120+
github.event_name != 'pull_request_target'
121+
&& env.REGENERATE_EXAMPLES == 'false'
122+
119123
# Cypress tests
120124
- run: make serve-gmf-apps &
121125
if: github.event_name != 'pull_request_target'
@@ -140,6 +144,7 @@ jobs:
140144
if-no-files-found: ignore
141145
retention-days: 5
142146
if: always()
147+
- run: '[ ${REGENERATE_EXAMPLES} == false ]'
143148
- uses: actions/upload-artifact@v4
144149
with:
145150
name: GMF Examples
@@ -154,6 +159,8 @@ jobs:
154159
if-no-files-found: ignore
155160
retention-days: 5
156161
if: always()
162+
- run: find .build/examples-hosted ! -name *-ref.png -type f -exec rm {};
163+
if: env.REGENERATE_EXAMPLES == 'true'
157164
- uses: actions/upload-artifact@v4
158165
with:
159166
name: Examples hosted

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,8 @@ contribs/dist: .build/build-dll.timestamp
303303
mkdir -p $(dir $@)
304304
CI=true LANGUAGE=en_US buildtools/retry node buildtools/check-example.js \
305305
.build/examples-hosted/error.html
306-
! buildtools/check-example .build/examples-hosted/error.html.png examples/error-ref.png
306+
# Only if REGENERATE_EXAMPLES is not true
307+
! ( [ ${REGENERATE_EXAMPLES} != true ] && buildtools/check-example .build/examples-hosted/error.html.png examples/error-ref.png )
307308
touch $@
308309

309310
# Add --generate as argument to buildtools/check-example to regenerate the reference images

buildtools/check-example

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,15 @@ def main():
8585
)
8686
result = float(result.stdout.decode().splitlines()[-1].split()[1])
8787
if result > 0.01:
88-
print(f"{result} > 0.01 => {diff}")
89-
sys.exit(1)
88+
if os.environ.get("REGENERATE_EXAMPLES") == "true":
89+
shutil.copyfile(current, old_ref)
90+
print("Regenerate the ref image: " + old_ref)
91+
92+
else:
93+
print(f"{result} > 0.01 => {diff}")
94+
sys.exit(1)
95+
elif os.environ.get("REGENERATE_EXAMPLES") == "true":
96+
os.remove(old_ref)
9097

9198

9299
if __name__ == "__main__":

0 commit comments

Comments
 (0)