|
| 1 | +# ---------------------------------------------------------------------------------------------------------------------- |
| 2 | +# VJE 2.0 -- Continuous Integration |
| 3 | +# |
| 4 | +# Builds and tests the single source tree on a Windows + Linux matrix from Phase 5 onward. Linux CI was planned from Phase 0 but |
| 5 | +# stood up here, at the first Qt Widgets phase, where portability drift becomes |
| 6 | +# likely). Each job installs Qt 6, GCC 13 (MinGW-w64 on Windows, matched to the Qt MinGW build), Ninja, and CMake, then |
| 7 | +# configures / builds / tests through the per-toolchain presets with warnings-as-errors on (the CI contract). |
| 8 | +# |
| 9 | +# Note: Qt / MinGW tool archive names track Qt releases; bump the `qt-version` / `mingw` inputs together when moving Qt. |
| 10 | +# ---------------------------------------------------------------------------------------------------------------------- |
| 11 | + |
| 12 | +name: CI |
| 13 | + |
| 14 | +on: |
| 15 | + push: |
| 16 | + branches: [ main ] |
| 17 | + pull_request: |
| 18 | + branches: [ main ] |
| 19 | + workflow_dispatch: # allow a manual run from the Actions tab / `gh workflow run` |
| 20 | + |
| 21 | +# Cancel superseded runs on the same ref to save minutes. |
| 22 | +concurrency: |
| 23 | + group: ci-${{ github.ref }} |
| 24 | + cancel-in-progress: true |
| 25 | + |
| 26 | +jobs: |
| 27 | + build-and-test: |
| 28 | + name: ${{ matrix.name }} |
| 29 | + runs-on: ${{ matrix.os }} |
| 30 | + |
| 31 | + strategy: |
| 32 | + fail-fast: false |
| 33 | + matrix: |
| 34 | + include: |
| 35 | + - name: Windows (MinGW GCC) |
| 36 | + os: windows-latest |
| 37 | + configure-preset: windows-release |
| 38 | + build-preset: windows-release |
| 39 | + test-preset: windows-release |
| 40 | + qt-arch: win64_mingw |
| 41 | + qt-tools: tools_mingw1310 |
| 42 | + qt-tools-bin: mingw1310_64/bin |
| 43 | + - name: Linux (GCC 13) |
| 44 | + os: ubuntu-latest |
| 45 | + configure-preset: linux-release |
| 46 | + build-preset: linux-release |
| 47 | + test-preset: linux-release |
| 48 | + qt-arch: linux_gcc_64 |
| 49 | + qt-tools: "" |
| 50 | + qt-tools-bin: "" |
| 51 | + |
| 52 | + steps: |
| 53 | + - name: Checkout |
| 54 | + uses: actions/checkout@v4 |
| 55 | + |
| 56 | + - name: Install GCC 13 and Ninja (Linux) |
| 57 | + if: runner.os == 'Linux' |
| 58 | + run: | |
| 59 | + sudo apt-get update |
| 60 | + sudo apt-get install -y g++-13 ninja-build |
| 61 | +
|
| 62 | + - name: Install Ninja (Windows) |
| 63 | + if: runner.os == 'Windows' |
| 64 | + uses: seanmiddleditch/gha-setup-ninja@v5 |
| 65 | + |
| 66 | + # Qt SVG (required by src/vje_app/services/IconLibrary) needs NO `modules:` entry: it is part of the base |
| 67 | + # aqtinstall archive this action wraps. Verified against an aqt linux_gcc_64 6.8.3 install, which ships |
| 68 | + # libQt6Svg.so, the Qt6Svg CMake package, and the qsvg image plugin. Only MSYS2 splits it into a separate |
| 69 | + # package. |
| 70 | + |
| 71 | + - name: Install Qt 6 |
| 72 | + uses: jurplel/install-qt-action@v4 |
| 73 | + with: |
| 74 | + version: 6.8.3 |
| 75 | + arch: ${{ matrix.qt-arch }} |
| 76 | + tools: ${{ matrix.qt-tools }} |
| 77 | + cache: true |
| 78 | + |
| 79 | + - name: Add MinGW to PATH (Windows) |
| 80 | + if: runner.os == 'Windows' |
| 81 | + shell: bash |
| 82 | + run: echo "${IQTA_TOOLS}/${{ matrix.qt-tools-bin }}" >> "$GITHUB_PATH" |
| 83 | + |
| 84 | + - name: Configure |
| 85 | + run: cmake --preset ${{ matrix.configure-preset }} -DVJE_WARNINGS_AS_ERRORS=ON |
| 86 | + |
| 87 | + - name: Build |
| 88 | + run: cmake --build --preset ${{ matrix.build-preset }} |
| 89 | + |
| 90 | + # --output-on-failure is not optional here. Without it a red CI run names the failing suite and nothing else, so |
| 91 | + # a failure that does not reproduce locally -- exactly the kind CI exists to catch -- costs a full round-trip just |
| 92 | + # to learn which assertion broke. Qt Test already prints the actual/expected pair; this is what lets it be seen. |
| 93 | + |
| 94 | + - name: Test |
| 95 | + run: ctest --preset ${{ matrix.test-preset }} --output-on-failure |
| 96 | + |
| 97 | + # A test that dies BEFORE Qt Test prints its banner -- a missing DLL, a crash in widget construction -- produces |
| 98 | + # no output at all, so --output-on-failure has nothing to show and the log names the suite and stops. That is |
| 99 | + # exactly what the first red run on this matrix looked like. Re-running the failed test alone under -VV surfaces |
| 100 | + # the invocation, the environment and the exit code, which is what distinguishes "it crashed" from "it failed". |
| 101 | + |
| 102 | + - name: Diagnose a failing test |
| 103 | + if: failure() |
| 104 | + shell: bash |
| 105 | + run: | |
| 106 | + # set +e is load-bearing. GitHub runs `shell: bash` with -e, so the FIRST binary that exits non-zero aborts |
| 107 | + # this whole script -- which is precisely the binary being investigated, and the reason the previous version |
| 108 | + # of this step reported nothing at all. |
| 109 | +
|
| 110 | + set +e |
| 111 | +
|
| 112 | + ctest --preset ${{ matrix.test-preset }} --rerun-failed --extra-verbose |
| 113 | +
|
| 114 | + # THE EXIT CODE IS THE DATUM. A test that dies before Qt Test prints its banner loses its buffered stdout |
| 115 | + # entirely, so ctest shows nothing however verbose it is asked to be. The raw code separates cases that |
| 116 | + # otherwise look identical: 0xC0000135 (3221225781) is a DLL that failed to load, 0xC0000005 (3221225477) an |
| 117 | + # access violation, and a small number an ordinary count of failed assertions. |
| 118 | +
|
| 119 | + echo "=== direct run of each test binary (non-zero exits only) ===" |
| 120 | +
|
| 121 | + # The "no dot in the name" arm is how the Linux binaries are matched without also matching *.o / *.cpp.obj. |
| 122 | +
|
| 123 | + find build -type f \( -name 'tst_*.exe' -o \( -name 'tst_*' ! -name '*.*' \) \) | while read -r binary; do |
| 124 | +
|
| 125 | + output=$( QT_QPA_PLATFORM=offscreen "$binary" 2>&1 ) |
| 126 | + code=$? |
| 127 | +
|
| 128 | + if [ "$code" -ne 0 ]; then |
| 129 | + echo "--- $binary -> exit $code" |
| 130 | + echo "$output" | tail -40 |
| 131 | +
|
| 132 | + # Qt Test's own FILE output, because stdout has proved unreliable here: a binary returning 1 (which is |
| 133 | + # its count of failed test functions, so it definitely reported) produced not one byte on stdout or |
| 134 | + # stderr, through both ctest --extra-verbose and a direct capture. -o bypasses the stream entirely. |
| 135 | +
|
| 136 | + echo "--- re-run via QTest file output ---" |
| 137 | + QT_QPA_PLATFORM=offscreen "$binary" -o "qtest-report.txt,txt" > /dev/null 2>&1 |
| 138 | + cat "qtest-report.txt" 2>/dev/null | tail -40 |
| 139 | + rm -f "qtest-report.txt" |
| 140 | + fi |
| 141 | + done |
| 142 | +
|
| 143 | + # Diagnostic only: the Test step above already failed the job, and this step failing too would just obscure it. |
| 144 | +
|
| 145 | + exit 0 |
0 commit comments