From 8c4be309aacadb0e96cf6838bea8132126261bb8 Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Sat, 7 Dec 2024 18:09:55 +0000 Subject: [PATCH] ci: flutter CI now compares produced images against references Automatically creates PR to store them --- .github/workflows/build.yml | 1 + .github/workflows/flutter-dev.yml | 37 ++++++++++++++++--- .github/workflows/flutter-ref-images-bump.yml | 34 +++++++++++++++++ .github/workflows/valgrind-leakcheck.yml | 8 +++- tests/reference-images | 2 +- 5 files changed, 74 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/flutter-ref-images-bump.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 712abb4e4..983db1c5b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,6 +11,7 @@ on: - src/flutter/** - tests/flutter/** - examples/flutter/** + - tests/reference-images/** branches: - main diff --git a/.github/workflows/flutter-dev.yml b/.github/workflows/flutter-dev.yml index 40aeeb997..e203101b7 100644 --- a/.github/workflows/flutter-dev.yml +++ b/.github/workflows/flutter-dev.yml @@ -2,8 +2,7 @@ # # SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only -# Builds the flutter frontend -# Doesn't run tests yet though +# Builds the flutter frontend and runs tests name: Flutter-dev @@ -40,6 +39,7 @@ jobs: uses: actions/checkout@v4 with: submodules: true + token: ${{ secrets.PAT_KDDW_REFERENCE_SCREENSHOTS }} - name: Install dependencies on Ubuntu run: | @@ -66,9 +66,36 @@ jobs: run: | cd ${{ github.workspace }}/src/flutter/dart flutter pub get - cd ${{ github.workspace }}/tests/flutter/ + flutter test + env: + KDDW_BINDINGS_LIB: ${{ github.workspace }}/build-dev-flutter/lib/libkddockwidgets.so + + - name: Setup git author name + run: | + git config --global user.email "kddw@actions" + git config --global user.name "KDDW Actions" + + # the reference is always latest main, as submodule sha1 might be lagging + # as it's updated nightly + - name: checkout latest main of ref images + run: | + cd tests/reference-images + git checkout main + + - name: Run integration tests + run: | + cd tests/flutter/ flutter pub get - cd ${{ github.workspace }}/build-dev-flutter/ - ctest --output-on-failure + xvfb-run flutter test -d linux integration_test/ui_test.dart env: KDDW_BINDINGS_LIB: ${{ github.workspace }}/build-dev-flutter/lib/libkddockwidgets.so + + - name: Compare against reference images + shell: bash + if: github.event_name == 'pull_request' + run: | + ./tests/reference-images/compare_images.sh + env: + PAT: ${{ secrets.PAT_KDDW_REFERENCE_SCREENSHOTS }} + GITHUB_EVENT_PATH: ${{ github.event_path }} + GH_TOKEN: ${{ github.token }} diff --git a/.github/workflows/flutter-ref-images-bump.yml b/.github/workflows/flutter-ref-images-bump.yml new file mode 100644 index 000000000..21ffa806f --- /dev/null +++ b/.github/workflows/flutter-ref-images-bump.yml @@ -0,0 +1,34 @@ +# SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +# +# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only +# +# +# +name: Nighly bump tests/reference-images submodule + +on: + schedule: + - cron: "0 3 * * *" + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + with: + submodules: true + + - name: bump submodule + run: | + cd tests/reference-images/ + git checkout main + cd ../.. + git add tests/reference-images/ + if [ -n "$(git status --porcelain)" ]; then + git commit -m "Bump tests/reference-images/" + gh pr create --base main --title "Bump tests/reference-images/" --body "Automatically created via GH actions." + fi + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/valgrind-leakcheck.yml b/.github/workflows/valgrind-leakcheck.yml index c3aa14798..0f6eb84f1 100644 --- a/.github/workflows/valgrind-leakcheck.yml +++ b/.github/workflows/valgrind-leakcheck.yml @@ -6,12 +6,16 @@ name: Valgrind qtwidgets_leak_test on: push: + paths-ignore: + # These are built by another workflow + - src/flutter/** + - tests/flutter/** + - examples/flutter/** + - tests/reference-images/** branches: - - 2.1 - main pull_request: branches: - - 2.1 - main jobs: diff --git a/tests/reference-images b/tests/reference-images index 944470420..30c963faf 160000 --- a/tests/reference-images +++ b/tests/reference-images @@ -1 +1 @@ -Subproject commit 944470420ccc054771f3d7b127ad5358e170c0f0 +Subproject commit 30c963faf630f7276bbc23d5325676c8adb4b4b0