test: add screenshots #267
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| name: CI | |
| permissions: | |
| contents: read | |
| on: | |
| pull_request: | |
| branches: | |
| - master | |
| types: | |
| - opened | |
| - synchronize | |
| - reopened | |
| push: | |
| branches: | |
| - master | |
| concurrency: | |
| group: "${{ github.workflow }}-${{ github.ref }}" | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| name: Build (${{ matrix.os }} - ${{ matrix.appindicator || 'default' }}) | |
| defaults: | |
| run: | |
| shell: ${{ matrix.shell }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: macos-latest | |
| shell: "bash" | |
| - os: ubuntu-latest | |
| appindicator: "libayatana-appindicator3-dev" | |
| shell: "bash" | |
| - os: ubuntu-latest | |
| appindicator: "libappindicator3-dev" | |
| shell: "bash" | |
| - os: windows-latest | |
| shell: "msys2 {0}" | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| submodules: recursive | |
| - name: Setup Dependencies Linux | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| build-essential \ | |
| cmake \ | |
| ${{ matrix.appindicator }} \ | |
| dbus-x11 \ | |
| libglib2.0-dev \ | |
| libnotify-dev \ | |
| ninja-build \ | |
| xfce4-panel \ | |
| openbox \ | |
| imagemagick \ | |
| gnome-screenshot \ | |
| xvfb | |
| - name: Setup Dependencies macOS | |
| if: runner.os == 'macOS' | |
| run: | | |
| brew update | |
| brew install \ | |
| cmake \ | |
| doxygen \ | |
| graphviz \ | |
| imagemagick \ | |
| ninja \ | |
| node | |
| - name: Setup Dependencies Windows | |
| if: runner.os == 'Windows' | |
| uses: msys2/setup-msys2@4f806de0a5a7294ffabaff804b38a9b435a73bda # v2.30.0 | |
| with: | |
| msystem: ucrt64 | |
| update: true | |
| install: >- | |
| doxygen | |
| mingw-w64-ucrt-x86_64-binutils | |
| mingw-w64-ucrt-x86_64-cmake | |
| mingw-w64-ucrt-x86_64-graphviz | |
| mingw-w64-ucrt-x86_64-imagemagick | |
| mingw-w64-ucrt-x86_64-ninja | |
| mingw-w64-ucrt-x86_64-nodejs | |
| mingw-w64-ucrt-x86_64-toolchain | |
| - name: Setup python | |
| id: setup-python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.11' | |
| - name: Python Path | |
| id: python-path | |
| run: | | |
| if [ "${{ runner.os }}" = "Windows" ]; then | |
| # replace backslashes with double backslashes | |
| python_path=$(echo "${{ steps.setup-python.outputs.python-path }}" | sed 's/\\/\\\\/g') | |
| else | |
| python_path=${{ steps.setup-python.outputs.python-path }} | |
| fi | |
| # step output | |
| echo "python-path=${python_path}" | |
| echo "python-path=${python_path}" >> "${GITHUB_OUTPUT}" | |
| - name: Build | |
| run: | | |
| mkdir -p build | |
| if [ "${{ runner.os }}" = "Linux" ]; then | |
| # Doxygen from Ubuntu is too old, need Doxygen >= 1.10 | |
| DOCS=OFF | |
| else | |
| DOCS=ON | |
| fi | |
| cmake \ | |
| -DBUILD_DOCS=${DOCS} \ | |
| -DCMAKE_BUILD_TYPE:STRING=Debug \ | |
| -B build \ | |
| -G Ninja \ | |
| -S . | |
| ninja -C build | |
| - name: Init tray icon (Windows) | |
| if: runner.os == 'Windows' | |
| working-directory: build/tests | |
| run: ./test_tray --gtest_color=yes --gtest_filter=TrayTest.TestTrayInit | |
| - name: Configure Windows | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| # Enable all tray icons | |
| Invoke-WebRequest ` | |
| -Uri "https://raw.githubusercontent.com/paulmann/windows-show-all-tray-icons/main/Enable-AllTrayIcons.ps1" ` | |
| -OutFile "Enable-AllTrayIcons.ps1" | |
| .\Enable-AllTrayIcons.ps1 -Action Enable -Force # Enable with comprehensive method (resets ALL icon settings) | |
| # Disable Do Not Disturb, using AutoItX | |
| # Download and install AutoIt (includes AutoItX) | |
| Invoke-WebRequest ` | |
| -Uri "https://www.autoitscript.com/files/autoit3/autoit-v3-setup.exe" ` | |
| -OutFile "autoit-v3-setup.exe" | |
| Start-Process ` | |
| -FilePath ".\autoit-v3-setup.exe" ` | |
| -ArgumentList "/S" -Wait | |
| # Import the AutoItX PowerShell module | |
| Import-Module "C:\Program Files (x86)\AutoIt3\AutoItX\AutoItX.psd1" | |
| # Send Win+N, then Enter after a short delay | |
| Initialize-AU3 | |
| Send-AU3Key -Key "{LWINDOWN}n{LWINUP}" -Mode 0 | |
| Start-Sleep -Milliseconds 200 | |
| Send-AU3Key -Key "{ENTER}" -Mode 0 | |
| # Minimize all windows | |
| $shell = New-Object -ComObject Shell.Application | |
| $shell.MinimizeAll() | |
| - name: Run tests | |
| id: test | |
| # TODO: tests randomly hang on Linux, https://github.com/LizardByte/tray/issues/45 | |
| timeout-minutes: 3 | |
| working-directory: build/tests | |
| run: | | |
| if [ "${{ runner.os }}" = "Linux" ]; then | |
| export DISPLAY=:1 | |
| Xvfb ${DISPLAY} -screen 0 1920x1080x24 & | |
| XVFB_PID=$! | |
| sleep 2 | |
| dbus-run-session -- bash -c ' | |
| openbox --config-file /etc/xdg/openbox/rc.xml & | |
| WM_PID=$! | |
| xfce4-panel --disable-wm-check & | |
| PANEL_PID=$! | |
| sleep 8 | |
| ./test_tray --gtest_color=yes --gtest_output=xml:test_results.xml | |
| status=$? | |
| kill ${PANEL_PID} ${WM_PID} >/dev/null 2>&1 || true | |
| exit ${status} | |
| ' | |
| status=$? | |
| kill ${XVFB_PID} >/dev/null 2>&1 || true | |
| exit ${status} | |
| else | |
| ./test_tray --gtest_color=yes --gtest_output=xml:test_results.xml | |
| fi | |
| - name: Upload screenshots | |
| if: >- | |
| always() && | |
| (steps.test.outcome == 'success' || steps.test.outcome == 'failure') | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: tray-screenshots-${{ runner.os }}${{ matrix.appindicator && format('-{0}', matrix.appindicator) || '' }} | |
| path: build/tests/screenshots | |
| if-no-files-found: error | |
| - name: Generate gcov report | |
| id: test_report | |
| # any except canceled or skipped | |
| if: >- | |
| always() && | |
| (steps.test.outcome == 'success' || steps.test.outcome == 'failure') | |
| working-directory: build | |
| run: | | |
| ${{ steps.python-path.outputs.python-path }} -m pip install gcovr | |
| ${{ steps.python-path.outputs.python-path }} -m gcovr . -r ../src \ | |
| --exclude-noncode-lines \ | |
| --exclude-throw-branches \ | |
| --exclude-unreachable-branches \ | |
| --verbose \ | |
| --xml-pretty \ | |
| -o coverage.xml | |
| - name: Debug coverage file | |
| run: cat build/coverage.xml | |
| - name: Set codecov flags | |
| id: codecov_flags | |
| run: | | |
| flags="${{ runner.os }}" | |
| if [ -n "${{ matrix.appindicator }}" ]; then | |
| flags="${flags},${{ matrix.appindicator }}" | |
| fi | |
| echo "flags=${flags}" >> "${GITHUB_OUTPUT}" | |
| - name: Upload coverage | |
| # any except canceled or skipped | |
| if: >- | |
| always() && | |
| steps.test_report.outcome == 'success' && | |
| startsWith(github.repository, 'LizardByte/') | |
| uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 | |
| with: | |
| disable_search: true | |
| fail_ci_if_error: true | |
| files: ./build/coverage.xml | |
| flags: "${{ steps.codecov_flags.outputs.flags }}" | |
| report_type: coverage | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| verbose: true | |
| - name: Upload test results | |
| # any except canceled or skipped | |
| if: >- | |
| always() && | |
| (steps.test.outcome == 'success' || steps.test.outcome == 'failure') && | |
| startsWith(github.repository, 'LizardByte/') | |
| uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 | |
| with: | |
| disable_search: true | |
| fail_ci_if_error: true | |
| files: ./build/tests/test_results.xml | |
| flags: "${{ steps.codecov_flags.outputs.flags }}" | |
| report_type: test_results | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| verbose: true |