From 02aec26703d5cbcd76f823a87b4d5ce31a0c6a02 Mon Sep 17 00:00:00 2001 From: Littlegnal <8847263+littleGnAl@users.noreply.github.com> Date: Thu, 11 Apr 2024 14:27:36 +0800 Subject: [PATCH] [ci][rendering_test] Always collect debug screenshot to help debugging (#1699) --- .github/workflows/build.yml | 24 +++++++++++++++---- .../common/screenshot_matcher_ext.dart | 6 +++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1e309680d..629626ecb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -396,6 +396,12 @@ jobs: disk-size: 8192M script: bash ci/rendering_test_android.sh + - uses: actions/upload-artifact@v3 + if: always() + with: + name: android-debug-golden-files + path: test_shard/rendering_test/screenshot/*.debug.png + rendering_test_ios: name: Run Flutter iOS Rendering Tests if: ${{ !contains(github.event.pull_request.labels.*.name, 'ci:skip') }} @@ -439,9 +445,9 @@ jobs: - run: bash ci/rendering_test_ios.sh - uses: actions/upload-artifact@v3 - if: failure() + if: always() with: - name: debug-golden-files-ios + name: ios-debug-golden-files path: test_shard/rendering_test/screenshot/*.debug.png rendering_test_macos: @@ -493,6 +499,11 @@ jobs: run: | export SAVE_DEBUG_GOLDEN="true" bash ci/rendering_test_macos.sh + - uses: actions/upload-artifact@v3 + if: always() + with: + name: macos-debug-golden-files + path: test_shard/rendering_test/screenshot/*.debug.png rendering_test_windows: name: Run Flutter Windows Rendering Tests @@ -542,6 +553,11 @@ jobs: export SAVE_DEBUG_GOLDEN="true" bash ci/rendering_test_windows.sh + - uses: actions/upload-artifact@v3 + if: always() + with: + name: windows-debug-golden-files + path: test_shard/rendering_test/screenshot/*.debug.png rendering_test_web: name: Run Flutter Web Rendering Tests @@ -570,7 +586,7 @@ jobs: bash ci/run_rendering_test.sh web - uses: actions/upload-artifact@v3 - if: failure() + if: always() with: - name: debug-golden-files + name: web-debug-golden-files path: test_shard/rendering_test/screenshot/*.debug.png diff --git a/test_shard/rendering_test/integration_test/common/screenshot_matcher_ext.dart b/test_shard/rendering_test/integration_test/common/screenshot_matcher_ext.dart index 54279d1e3..48f0c42f4 100644 --- a/test_shard/rendering_test/integration_test/common/screenshot_matcher_ext.dart +++ b/test_shard/rendering_test/integration_test/common/screenshot_matcher_ext.dart @@ -65,6 +65,12 @@ Future matchScreenShotDesktop( if (updateGolden == 'true') { imageFile.writeAsBytesSync(imageBytes); } else { + if ((Platform.environment['SAVE_DEBUG_GOLDEN'] ?? 'false') == 'true') { + final File debugGoldenFile = + File('screenshot/$screenshotName.debug.png'); + debugGoldenFile.writeAsBytesSync(imageBytes); + } + final expectedImage = decodePng(imageFile.readAsBytesSync()); double tolerance = 0.3;