From 4f5c2e22c2f02d869e1a715d6b62f37484e01b09 Mon Sep 17 00:00:00 2001 From: Lars Toenning Date: Sun, 28 Jun 2026 18:22:12 +0200 Subject: [PATCH] ci: Restructure CI --- .../{build.yml => check_and_build.yml} | 104 ++++-------------- .github/workflows/main.yml | 48 ++++++++ .github/workflows/pr.yml | 66 +++++++++++ .github/workflows/release.yml | 79 +++++++++++++ .github/workflows/reusable_checks.yml | 40 +++++++ .github/workflows/reusable_doxygen.yml | 44 ++++++++ 6 files changed, 298 insertions(+), 83 deletions(-) rename .github/workflows/{build.yml => check_and_build.yml} (86%) create mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/pr.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/reusable_checks.yml create mode 100644 .github/workflows/reusable_doxygen.yml diff --git a/.github/workflows/build.yml b/.github/workflows/check_and_build.yml similarity index 86% rename from .github/workflows/build.yml rename to .github/workflows/check_and_build.yml index deb10da03..a2991f2ab 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/check_and_build.yml @@ -4,22 +4,17 @@ name: Build swift on: - push: - branches-ignore: - - stable/** - - nobuild/** - pull_request: + merge_group: + branches: [main] + workflow_dispatch: # manually triggered concurrency: - group: ${{ github.ref }} + group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true env: - do_vatsim_key: ${{ github.event_name == 'push' }} - do_symbols: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - do_doxygen: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - do_static_analysis: ${{ github.event_name == 'push' && github.ref != 'refs/heads/main' }} - qt_version: 6.11.1 + do_symbols: ${{ github.event_name == 'merge_group' }} + qt_version: &qt_version 6.11.1 bitrock_version: qt-professional-25.10.1 bitrock_url: https://releases.installbuilder.com/installbuilder installbuilder_hash_win: f92b1741c78b8f024473f55057b26107c8ed9cc1ca583eb9323d0023a8024e00 @@ -27,13 +22,11 @@ env: installbuilder_hash_macos: bffa8b2663c6e9aaaa1ed7cdb41a874d34ff89f22adfab419e172915f8f4ce57 externals: swift-project/externals externals_sha: e1f1743ba159e11b0c065ea8f1ae1a0e91e3bf39 - use_externals: ${{ secrets.EXTERNALS_PAT != '' }} jobs: preBuild: runs-on: ubuntu-24.04 - if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository }} outputs: version: ${{ steps.version.outputs.value }} @@ -58,57 +51,21 @@ jobs: warnIfNotFound: false checks: - runs-on: ubuntu-22.04 - needs: preBuild + uses: ./.github/workflows/reusable_checks.yml + doxygen: + uses: ./.github/workflows/reusable_doxygen.yml + with: + qt_version: *qt_version + upload_doxygen: false + + clang-tidy: + runs-on: ubuntu-22.04 steps: - name: Checkout repository uses: actions/checkout@v6 with: fetch-depth: '0' - - name: Install gitlint - run: | - pip install gitlint==0.19.1 - - name: Run gitlint - run: gitlint --commits d789f61044e63e1a00d8e9f1d4d49c8d9ffc42a9..HEAD - - name: Install REUSE - run: | - pip install reuse==4.0.3 - - name: Run REUSE lint - run: reuse lint - - name: Run clang-format - run: | - scripts/run_clang_format.py - - uses: swift-project/setup-cpp@swift - - name: Run cppcheck - run: | - sudo apt-get -y install cppcheck - cppcheck --template=gcc --inline-suppr --std=c++17 --enable=style,unusedFunction \ - -i src/plugins/weatherdata/gfs/g2clib -DCPPCHECK --force --suppressions-list=cppcheck.supp \ - --library=qt.cfg --library=posix.cfg . - - name: Install Qt docs - if: ${{ env.do_doxygen == 'true' }} - uses: jurplel/install-qt-action@v4 - with: - version: ${{ env.qt_version }} - no-qt-binaries: true - aqtsource: 'git+https://github.com/miurahr/aqtinstall.git@8c3695d4a4e1ceabf6a74dc6c79681656dc6b74b' - documentation: true - cache: true - - name: Run doxygen - if: ${{ env.do_doxygen == 'true' }} - working-directory: docs - run: | - sudo apt-get -y install doxygen graphviz - doxygen Doxyfile - env: - DOXY_SRC_ROOT: .. - DOXY_TAGFILES: ${{ runner.workspace }}/Qt/Docs/Qt-${{ env.qt_version }} - - name: Upload doxygen - if: ${{ env.do_doxygen == 'true' }} - uses: actions/upload-pages-artifact@v3 - with: - path: docs/html/ - name: Check if clang-tidy analysis is required id: check_need_clang_tidy run: | @@ -137,7 +94,7 @@ jobs: sudo apt-get -y install dbus-x11 libglu1-mesa-dev libpulse-dev libdbus-1-dev ninja-build pip3 install requests conan==2.29.1 - name: Checkout externals - if: ${{ env.use_externals == 'true' && steps.check_need_clang_tidy.outputs.should_run_clang_tidy == 'true' }} + if: ${{ steps.check_need_clang_tidy.outputs.should_run_clang_tidy == 'true' }} uses: actions/checkout@v6 env: EXTERNALS_PAT: ${{ secrets.EXTERNALS_PAT }} @@ -168,7 +125,7 @@ jobs: buildLinux: runs-on: ubuntu-24.04 - needs: [preBuild, checks] + needs: [preBuild, checks, clang-tidy, doxygen] env: BACKTRACE_SYMBOL_TOKEN: ${{ secrets.BACKTRACE_SYMBOL_TOKEN }} BACKTRACE_MINIDUMP_TOKEN: ${{ secrets.BACKTRACE_MINIDUMP_TOKEN }} @@ -212,7 +169,6 @@ jobs: submodules: true fetch-depth: 0 - name: Checkout externals - if: ${{ env.use_externals == 'true' }} uses: actions/checkout@v6 env: EXTERNALS_PAT: ${{ secrets.EXTERNALS_PAT }} @@ -237,7 +193,6 @@ jobs: eval $(cat session.sh) echo "DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS" >>$GITHUB_ENV - name: Create Vatsim key file - if: ${{ env.do_vatsim_key == 'true' }} run: | cat >vatsim.json <vatsim.json @" { "vatsim": { "id": "$env:VATSIM_ID", "key": "$env:VATSIM_KEY" } } @@ -386,7 +339,7 @@ jobs: buildMacOS: runs-on: macos-26 - needs: [preBuild, checks] + needs: [preBuild, checks, clang-tidy, doxygen] env: BACKTRACE_SYMBOL_TOKEN: ${{ secrets.BACKTRACE_SYMBOL_TOKEN }} BACKTRACE_MINIDUMP_TOKEN: ${{ secrets.BACKTRACE_MINIDUMP_TOKEN }} @@ -435,7 +388,6 @@ jobs: submodules: true fetch-depth: 0 - name: Checkout externals - if: ${{ env.use_externals == 'true' }} uses: actions/checkout@v6 env: EXTERNALS_PAT: ${{ secrets.EXTERNALS_PAT }} @@ -460,7 +412,6 @@ jobs: # https://doc.qt.io/qt-6/macos-issues.html#d-bus-and-macos conan install --requires=dbus/1.15.8 --output-folder build_conan_dbus_shared --deployer=full_deploy -o "dbus/*:shared=True" -o "dbus/*:message_bus=True" -pr:h=ci/profile_mac -pr:b=ci/profile_mac_arm - name: Create Vatsim key file - if: ${{ env.do_vatsim_key == 'true' }} run: | cat >vatsim.json <> $GITHUB_OUTPUT + + - name: Find merge queue build for this commit + id: find_run + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + for i in $(seq 1 10); do + RUN_ID=$(gh api \ + "/repos/${{ github.repository }}/actions/runs" \ + -f head_sha=${{ github.sha }} \ + -f workflow_file_name=check_and_build.yml \ + -f status=success \ + --jq '.workflow_runs[0].id // empty') + if [ -n "$RUN_ID" ]; then + echo "run_id=$RUN_ID" >> $GITHUB_OUTPUT + exit 0 + fi + echo "Attempt $i: Artifact not found yet, retrying in 30s..." + sleep 30 + done + echo "::error::No successful build found for SHA ${{ github.sha }}" + exit 1 + + - name: Download artifacts + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh api \ + "/repos/${{ github.repository }}/actions/runs/${{ steps.find_run.outputs.run_id }}/artifacts" \ + --jq '.artifacts[] | .name + " " + .archive_download_url' \ + | while read name url; do + gh api "$url" > "${name}.zip" + unzip -o "${name}.zip" -d "${name}" + done + - name: Flatten directories + run: | + mv swiftinstaller-*/* . + mv xswiftbus-*/* . + mkdir swiftsymbols + mv swiftsymbols-*/* swiftsymbols + - name: Create release + uses: swift-project/github-release@2.0-connreset-retry + id: create + with: + token: ${{ secrets.GITHUB_TOKEN }} + tag: v${{ steps.version.outputs.version }} + commitish: ${{ github.sha }} + body: Version ${{ steps.version.outputs.version }} + draft: true + prerelease: true + gzip: folders + files: > + swiftinstaller-linux-64-${{ steps.version.outputs.version }}.run + swiftinstaller-windows-64-${{ steps.version.outputs.version }}.exe + swiftinstaller-macos-64-${{ steps.version.outputs.version }}.dmg + xswiftbus-fat-allos-${{ steps.version.outputs.version }}.zip + swiftsymbols-allos-${{ steps.version.outputs.version }}:swiftsymbols diff --git a/.github/workflows/reusable_checks.yml b/.github/workflows/reusable_checks.yml new file mode 100644 index 000000000..ccc4e88d6 --- /dev/null +++ b/.github/workflows/reusable_checks.yml @@ -0,0 +1,40 @@ +# SPDX-FileCopyrightText: Copyright (C) swift Project Community / Contributors +# SPDX-License-Identifier: CC0-1.0 + +name: Checks + +on: + workflow_call: + +jobs: + checks: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Install gitlint + run: pip install gitlint==0.19.1 + + - name: Run gitlint + run: gitlint --commits d789f61044e63e1a00d8e9f1d4d49c8d9ffc42a9..HEAD + + - name: Install REUSE + run: pip install reuse==4.0.3 + + - name: Run REUSE lint + run: reuse lint + + - name: Run clang-format + run: scripts/run_clang_format.py + - uses: swift-project/setup-cpp@df5d21a5dd12577254a9748fddf23e075a4a7ddc + - name: Run cppcheck + run: | + sudo apt-get -y install cppcheck + cppcheck --template=gcc --inline-suppr --std=c++17 \ + --enable=style,unusedFunction \ + -i src/plugins/weatherdata/gfs/g2clib \ + -DCPPCHECK --force \ + --suppressions-list=cppcheck.supp \ + --library=qt.cfg --library=posix.cfg . diff --git a/.github/workflows/reusable_doxygen.yml b/.github/workflows/reusable_doxygen.yml new file mode 100644 index 000000000..ea381aadb --- /dev/null +++ b/.github/workflows/reusable_doxygen.yml @@ -0,0 +1,44 @@ +# SPDX-FileCopyrightText: Copyright (C) swift Project Community / Contributors +# SPDX-License-Identifier: CC0-1.0 + +name: Doxygen + +on: + workflow_call: + inputs: + upload_doxygen: + type: boolean + default: false + qt_version: + type: string + required: true + +jobs: + build_doxygen: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + - name: Install Qt docs + uses: jurplel/install-qt-action@v4 + with: + version: ${{ inputs.qt_version }} + no-qt-binaries: true + documentation: true + cache: true + - name: Run doxygen + working-directory: docs + run: | + sudo apt-get -y install doxygen graphviz + doxygen Doxyfile + env: + DOXY_SRC_ROOT: .. + DOXY_TAGFILES: ${{ runner.workspace }}/Qt/Docs/Qt-${{ inputs.qt_version }} + + - uses: actions/upload-artifact@v4 + if: inputs.upload_doxygen + with: + name: doxygen + path: docs/html/ + retention-days: 1