diff --git a/.github/actions/save-build-log/action.yml b/.github/actions/save-build-log/action.yml new file mode 100644 index 0000000..4a113e6 --- /dev/null +++ b/.github/actions/save-build-log/action.yml @@ -0,0 +1,34 @@ +name: Save build log +description: > + Upload build.log (from the workspace root) as a "build-log-" artifact, together with + the platform title and the workspace path, for the warnings report in ci.yml. + +inputs: + id: + description: Unique artifact suffix + required: true + title: + description: Platform / compiler name shown in the report + required: true + +runs: + using: composite + steps: + - name: Collect build log + shell: bash + env: + TITLE: ${{ inputs.title }} + run: | + mkdir -p build-log-artifact + if [ -f build.log ]; then mv build.log build-log-artifact/; fi + printf '%s\n' "$TITLE" > build-log-artifact/title.txt + # Path as printed by the compiler (D:/a/... on Windows). + ws="$GITHUB_WORKSPACE" + if command -v cygpath > /dev/null; then ws=$(cygpath -m "$ws"); fi + printf '%s\n' "$ws" > build-log-artifact/workspace.txt + + - uses: actions/upload-artifact@v7 + with: + name: build-log-${{ inputs.id }} + path: build-log-artifact/ + retention-days: 7 diff --git a/.github/scripts/warnings_report.py b/.github/scripts/warnings_report.py index 4627ca2..e0079cb 100644 --- a/.github/scripts/warnings_report.py +++ b/.github/scripts/warnings_report.py @@ -6,31 +6,38 @@ ############################################################################### """ -Generate a Markdown report of compiler / clang-tidy warnings from build logs. +Generate a Markdown report of compiler / clang-tidy warnings from CI build logs. + +Each build log directory (as saved by .github/actions/save-build-log) contains: + build.log - Build output. + title.txt - Platform / compiler name shown in the report. + workspace.txt - Source root path, as printed by the compiler on that platform. Warnings are deduplicated (the same header warning is printed once per -translation unit), restricted to project files (dependencies, system headers -and generated files are skipped), and split into "in changed files" and "total". +translation unit, and the same warning may be reported by several platforms), +restricted to project files (dependencies, system headers and generated files +are skipped), and split into "in changed files" and "total". Usage: - warnings_report.py --workspace DIR [--changed-files FILE] [--build-dir NAME] - --log "Title=path/to/build.log" [--log ...] > report.md + warnings_report.py --logs-dir DIR [--changed-files FILE] > report.md """ import argparse import collections +import pathlib import posixpath import re import sys # file:line:col: warning: message [flag-or-check] +# The file may start with a Windows drive letter (D:/a/...). WARNING_RE = re.compile( - r"^(?P[^\s:][^:]*):(?P\d+):(?P\d+): warning: (?P.*?)(?: \[(?P[^\]]+)\])?$") + r"^(?P(?:[A-Za-z]:)?[^\s:][^:]*):(?P\d+):(?P\d+): warning: (?P.*?)(?: \[(?P[^\]]+)\])?$") -# Paths (relative to the workspace) whose warnings are not ours. -EXCLUDED_PREFIXES = ("dependencies/",) +# Repository paths whose warnings are not ours. +EXCLUDED_PREFIXES = ("dependencies/", "build/") -# Maximum number of warnings listed per section, to keep the comment within GitHub's size limit. +# Maximum number of warnings listed, to keep the comment within GitHub's size limit. MAX_LISTED = 150 MARKER = "" @@ -39,95 +46,119 @@ MARKER = "" Warning = collections.namedtuple("Warning", "file line col msg flag") -def parse_log(path, workspace, build_dirs): - """Return a sorted list of unique project warnings found in the log.""" - found = set() - try: - with open(path, encoding="utf-8", errors="replace") as f: - lines = f.readlines() - except FileNotFoundError: - return None +def normalize_path(path): + path = path.replace("\\", "/") + if re.match(r"^[A-Za-z]:/", path): + path = path[0].lower() + path[1:] + elif re.match(r"^/[A-Za-z]/", path): # msys-style /d/a/... -> d:/a/... + path = path[1].lower() + ":" + path[2:] + return posixpath.normpath(path) - for raw in lines: - m = WARNING_RE.match(raw.rstrip("\r\n")) + +def to_repo_path(file, workspace): + """Return the path relative to the repository root, or None if outside it.""" + file = normalize_path(file) + if workspace and (file == workspace or file.startswith(workspace + "/")): + return file[len(workspace) + 1:] + if file.startswith("/") or re.match(r"^[a-z]:/", file) or file.startswith("../"): + return None # system headers, etc. + return file + + +def parse_log(log_dir): + """Return (title, set of warnings), or (title, None) if the log is missing.""" + title = log_dir.name.removeprefix("build-log-") + title_file = log_dir / "title.txt" + if title_file.exists(): + title = title_file.read_text(encoding="utf-8").strip() or title + workspace_file = log_dir / "workspace.txt" + workspace = normalize_path(workspace_file.read_text(encoding="utf-8").strip()) if workspace_file.exists() else "" + + log_file = log_dir / "build.log" + if not log_file.exists(): + return title, None + + found = set() + for raw in log_file.read_text(encoding="utf-8", errors="replace").splitlines(): + m = WARNING_RE.match(raw.rstrip()) if not m: continue - file = posixpath.normpath(m.group("file")) - if posixpath.isabs(file): - file = posixpath.relpath(file, workspace) - if file.startswith("../") or file.startswith(EXCLUDED_PREFIXES): - continue # system headers, dependencies - if any(file == d or file.startswith(d + "/") for d in build_dirs): - continue # generated files - found.add(Warning(file, int(m.group("line")), int(m.group("col")), - m.group("msg").strip(), (m.group("flag") or "").replace(",-warnings-as-errors", ""))) - - return sorted(found) + file = to_repo_path(m.group("file"), workspace) + if file is None or file.startswith(EXCLUDED_PREFIXES): + continue + flag = (m.group("flag") or "").replace(",-warnings-as-errors", "") + found.add(Warning(file, int(m.group("line")), int(m.group("col")), m.group("msg").strip(), flag)) + return title, found -def format_list(warnings): - out = [] - for w in warnings[:MAX_LISTED]: - flag = f" `[{w.flag}]`" if w.flag else "" - msg = w.msg.replace("|", "\\|").replace("`", "'") - out.append(f"- `{w.file}:{w.line}:{w.col}`: {msg}{flag}") - if len(warnings) > MAX_LISTED: - out.append(f"- ... and {len(warnings) - MAX_LISTED} more") - return "\n".join(out) - - -def format_top_flags(warnings, count=15): - counter = collections.Counter(w.flag or "(no flag)" for w in warnings) - rows = ["| Warning | Count |", "|---|---:|"] - rows += [f"| `{flag}` | {n} |" for flag, n in counter.most_common(count)] - return "\n".join(rows) +def escape(text): + return text.replace("|", "\\|").replace("`", "'").replace("<", "<") def main(): parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) - parser.add_argument("--workspace", required=True, help="Source root; warnings are reported relative to it") - parser.add_argument("--build-dir", action="append", default=[], help="Build directory (relative), skipped") + parser.add_argument("--logs-dir", required=True, help="Directory with one subdirectory per build log") parser.add_argument("--changed-files", help="File with one changed path (relative) per line") - parser.add_argument("--log", action="append", required=True, help="Title=path of a build log") args = parser.parse_args() - workspace = posixpath.abspath(args.workspace) changed = None if args.changed_files: with open(args.changed_files, encoding="utf-8") as f: changed = {line.strip() for line in f if line.strip()} - reports = [] - for spec in args.log: - title, _, path = spec.partition("=") - reports.append((title, parse_log(path, workspace, args.build_dir))) + reports = [parse_log(d) for d in pathlib.Path(args.logs_dir).iterdir() if d.is_dir()] + reports.sort(key=lambda r: r[0].lower()) + + # Unique warnings across all platforms, with the platforms that reported each. + platforms_by_warning = collections.defaultdict(list) + for title, warnings in reports: + for w in warnings or (): + platforms_by_warning[w].append(title) + all_warnings = sorted(platforms_by_warning) + + def in_changed(warnings): + return [w for w in warnings if w.file in changed] out = [MARKER, "## Warnings report", ""] - header = "| | " + " | ".join(title for title, _ in reports) + " |" - out += [header, "|---" + "|---:" * len(reports) + "|"] if changed is not None: - cells = [] - for _, warnings in reports: - cells.append("n/a" if warnings is None else str(sum(1 for w in warnings if w.file in changed))) - out.append("| In changed files | " + " | ".join(cells) + " |") - cells = ["build log missing" if w is None else str(len(w)) for _, w in reports] - out.append("| Total (deduplicated) | " + " | ".join(cells) + " |") + out += ["| Platform | In changed files | Total |", "|---|---:|---:|"] + else: + out += ["| Platform | Total |", "|---|---:|"] + for title, warnings in reports: + if warnings is None: + cells = ["n/a", "build log missing"] if changed is not None else ["build log missing"] + elif changed is not None: + cells = [str(len(in_changed(warnings))), str(len(warnings))] + else: + cells = [str(len(warnings))] + out.append(f"| {escape(title)} | " + " | ".join(cells) + " |") + if changed is not None: + out.append(f"| **All platforms (unique)** | **{len(in_changed(all_warnings))}** | **{len(all_warnings)}** |") + else: + out.append(f"| **All platforms (unique)** | **{len(all_warnings)}** |") out.append("") - for title, warnings in reports: - if not warnings: - continue - if changed is not None: - in_changed = [w for w in warnings if w.file in changed] - if in_changed: - out += [f"
{title}: {len(in_changed)} in changed files", "", - format_list(in_changed), "", "
", ""] - out += [f"
{title}: all {len(warnings)} warnings by type", "", - format_top_flags(warnings), "", "
", ""] + listed = in_changed(all_warnings) if changed is not None else [] + if listed: + out += [f"
Warnings in changed files ({len(listed)})", ""] + for w in listed[:MAX_LISTED]: + flag = f" `[{w.flag}]`" if w.flag else "" + out.append(f"- `{w.file}:{w.line}:{w.col}`: {escape(w.msg)}{flag}" + f" ({escape(', '.join(platforms_by_warning[w]))})") + if len(listed) > MAX_LISTED: + out.append(f"- ... and {len(listed) - MAX_LISTED} more") + out += ["", "
", ""] - out.append("Warnings in `dependencies/`, system headers and generated files are excluded. " - "Updated automatically on each push.") + if all_warnings: + counter = collections.Counter(w.flag or "(no flag)" for w in all_warnings) + out += [f"
All warnings by type ({len(all_warnings)})", "", + "| Warning | Count |", "|---|---:|"] + out += [f"| `{flag}` | {n} |" for flag, n in counter.most_common(25)] + out += ["", "
", ""] + + out.append("Deduplicated across translation units and platforms. Warnings in `dependencies/`, " + "system headers and generated files are excluded. Updated automatically on each push.") print("\n".join(out)) return 0 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..1eb98d3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,86 @@ +name: CI + +# Runs all builds, then posts a deduplicated warnings report from all of them +# (compilers on every platform, and clang-tidy) as a PR comment, updated on each push. + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +permissions: + contents: read + +# Cancel superseded runs of the same PR (pushes to main always run to completion). +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + + tier1: + uses: ./.github/workflows/cmake-tier1.yml + + tier2: + uses: ./.github/workflows/cmake-tier2.yml + + sanitizers: + uses: ./.github/workflows/sanitizers.yml + + clang-tidy: + uses: ./.github/workflows/clang-tidy.yml + + + warnings-report: + needs: [ tier1, tier2, sanitizers, clang-tidy ] + if: ${{ !cancelled() }} + runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: + contents: read + pull-requests: write + + steps: + - uses: actions/checkout@v7 + + - name: Download build logs + uses: actions/download-artifact@v8 + with: + pattern: build-log-* + path: logs + + - name: Get changed files + if: ${{ github.event_name == 'pull_request' }} + env: + GH_TOKEN: ${{ github.token }} + PR_NUMBER: ${{ github.event.pull_request.number }} + run: > + gh api --paginate "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/files" -q '.[].filename' + > changed-files.txt + + - name: Generate report + run: | + mkdir -p logs + changed=() + if [ -f changed-files.txt ]; then changed=(--changed-files changed-files.txt); fi + python3 .github/scripts/warnings_report.py --logs-dir logs "${changed[@]}" > report.md + cat report.md >> "$GITHUB_STEP_SUMMARY" + + # The token is read-only for PRs from forks, so there the report is only in the job summary. + - name: Post or update PR comment + if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository }} + env: + GH_TOKEN: ${{ github.token }} + PR_NUMBER: ${{ github.event.pull_request.number }} + run: | + marker='' + comment_id=$(gh api --paginate "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" \ + -q ".[] | select(.user.login == \"github-actions[bot]\" and (.body | startswith(\"$marker\"))) | .id" | head -n 1) + if [ -n "$comment_id" ]; then + gh api -X PATCH "repos/$GITHUB_REPOSITORY/issues/comments/$comment_id" -F body=@report.md > /dev/null + else + gh api -X POST "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" -F body=@report.md > /dev/null + fi diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml new file mode 100644 index 0000000..ab8bdd9 --- /dev/null +++ b/.github/workflows/clang-tidy.yml @@ -0,0 +1,55 @@ +name: clang-tidy + +# Builds with clang-tidy enabled (using the checks in .clang-tidy). +# clang-tidy warnings do not fail the build; they are included in the warnings report (see ci.yml). +# Called from ci.yml (on push / pull request), or run manually from the Actions tab. + +on: + workflow_call: + workflow_dispatch: + +permissions: + contents: read + +env: + # Keep in sync with the job name below. + LLVM_VERSION: 22 + +jobs: + + clang-tidy: + name: clang-tidy (clang-22) + runs-on: ubuntu-26.04 + timeout-minutes: 90 + + steps: + - uses: actions/checkout@v7 + + - name: Install Dependencies + run: | + sudo apt-get update + sudo apt-get install libgtkmm-3.0-dev gettext + + # toolchains/linux-dev-with-tidy.cmake hardcodes an unversioned "clang-tidy", + # so we use linux-dev.cmake and pass the versioned binary. + - name: Configure CMake + env: + CC: clang-${{ env.LLVM_VERSION }} + CXX: clang++-${{ env.LLVM_VERSION }} + run: > + cmake -B build -S "$GITHUB_WORKSPACE" + -DCMAKE_BUILD_TYPE=Debug + -DCMAKE_TOOLCHAIN_FILE="$GITHUB_WORKSPACE/toolchains/linux-dev.cmake" + -DCMAKE_CXX_CLANG_TIDY="clang-tidy-${LLVM_VERSION}" + + - name: Build with clang-tidy + run: | + set -o pipefail + cmake --build build --parallel "$(nproc)" 2>&1 | tee build.log + + - name: Save build log + if: ${{ always() }} + uses: ./.github/actions/save-build-log + with: + id: clang-tidy-${{ env.LLVM_VERSION }} + title: clang-tidy ${{ env.LLVM_VERSION }} diff --git a/.github/workflows/cmake-tier1.yml b/.github/workflows/cmake-tier1.yml index 50286cb..2967a09 100644 --- a/.github/workflows/cmake-tier1.yml +++ b/.github/workflows/cmake-tier1.yml @@ -1,23 +1,14 @@ name: Build (Tier 1 platforms) +# Called from ci.yml (on push / pull request), or run manually from the Actions tab. on: - # Triggers the workflow on push or pull request events but only for the main branch - push: - branches: [ main ] - pull_request: - branches: [ main ] - # Allows you to run this workflow manually from the Actions tab + workflow_call: workflow_dispatch: permissions: contents: read -# Cancel superseded runs of the same PR (pushes to main always run to completion). -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{ github.event_name == 'pull_request' }} - env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) @@ -42,38 +33,37 @@ jobs: steps: - uses: actions/checkout@v7 - - name: Update Package Database - run: sudo apt-get update - - name: Install Dependencies - run: sudo apt-get install libgtkmm-3.0-dev gettext - - - name: Create Build Directory - run: cmake -E make_directory build + run: | + sudo apt-get update + sudo apt-get install libgtkmm-3.0-dev gettext - name: Configure CMake - shell: bash - working-directory: ${{github.workspace}}/build env: CC: gcc-${{ matrix.gcc }} CXX: g++-${{ matrix.gcc }} run: > - cmake $GITHUB_WORKSPACE + cmake -B build -S "$GITHUB_WORKSPACE" -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_TOOLCHAIN_FILE="$GITHUB_WORKSPACE/toolchains/linux-dev.cmake" - name: Build - shell: bash - working-directory: ${{github.workspace}}/build - run: cmake --build . --config $BUILD_TYPE + run: | + set -o pipefail + cmake --build build --config $BUILD_TYPE 2>&1 | tee build.log + + - name: Save build log + if: ${{ always() }} + uses: ./.github/actions/save-build-log + with: + id: linux-ubuntu-${{ matrix.os }}-gcc-${{ matrix.gcc }} + title: Ubuntu ${{ matrix.os }} (GCC ${{ matrix.gcc }}) - name: Test working-directory: ${{github.workspace}}/build - shell: bash run: ctest -C $BUILD_TYPE --rerun-failed --output-on-failure - name: Pack (cmake install and make binary package) - shell: bash working-directory: ${{github.workspace}}/build run: cpack -G TBZ2 diff --git a/.github/workflows/cmake-tier2.yml b/.github/workflows/cmake-tier2.yml index f5b6431..53bdc3d 100644 --- a/.github/workflows/cmake-tier2.yml +++ b/.github/workflows/cmake-tier2.yml @@ -1,23 +1,14 @@ name: Build (Tier 2 platforms) +# Called from ci.yml (on push / pull request), or run manually from the Actions tab. on: - # Triggers the workflow on push or pull request events but only for the main branch - push: - branches: [ main ] - pull_request: - branches: [ main ] - # Allows you to run this workflow manually from the Actions tab + workflow_call: workflow_dispatch: permissions: contents: read -# Cancel superseded runs of the same PR (pushes to main always run to completion). -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{ github.event_name == 'pull_request' }} - env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) @@ -33,7 +24,10 @@ jobs: strategy: fail-fast: false matrix: - compiler: [ apple-clang, llvm ] + include: [ + { compiler: apple-clang, title: "macOS (Apple Clang)" }, + { compiler: llvm, title: "macOS (Homebrew LLVM 20)" }, + ] env: LLVM_VERSION: 20 @@ -59,8 +53,16 @@ jobs: -DAPP_COMPILER_ENABLE_WARNINGS=ON - name: Build - working-directory: ${{github.workspace}}/build - run: cmake --build . --config $BUILD_TYPE + run: | + set -o pipefail + cmake --build build --config $BUILD_TYPE 2>&1 | tee build.log + + - name: Save build log + if: ${{ always() }} + uses: ./.github/actions/save-build-log + with: + id: macos-${{ matrix.compiler }} + title: ${{ matrix.title }} - name: Test working-directory: ${{github.workspace}}/build @@ -97,8 +99,16 @@ jobs: -DCMAKE_TOOLCHAIN_FILE="$GITHUB_WORKSPACE/toolchains/linux-dev.cmake" - name: Build - working-directory: ${{github.workspace}}/build - run: cmake --build . --config $BUILD_TYPE + run: | + set -o pipefail + cmake --build build --config $BUILD_TYPE 2>&1 | tee build.log + + - name: Save build log + if: ${{ always() }} + uses: ./.github/actions/save-build-log + with: + id: linux-ubuntu-${{ matrix.os }}-clang-${{ matrix.clang }} + title: Ubuntu ${{ matrix.os }} (Clang ${{ matrix.clang }}) - name: Test working-directory: ${{github.workspace}}/build diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.yml index bc4e89a..461ec57 100644 --- a/.github/workflows/sanitizers.yml +++ b/.github/workflows/sanitizers.yml @@ -1,21 +1,15 @@ name: Sanitizers # Debug build with AddressSanitizer and UndefinedBehaviorSanitizer, running the tests. +# Called from ci.yml (on push / pull request), or run manually from the Actions tab. on: - push: - branches: [ main ] - pull_request: - branches: [ main ] + workflow_call: workflow_dispatch: permissions: contents: read -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{ github.event_name == 'pull_request' }} - env: # Keep in sync with the job name below. LLVM_VERSION: 22 @@ -50,7 +44,16 @@ jobs: -DCMAKE_SHARED_LINKER_FLAGS="$SANITIZER_FLAGS" - name: Build - run: cmake --build build --parallel "$(nproc)" + run: | + set -o pipefail + cmake --build build --parallel "$(nproc)" 2>&1 | tee build.log + + - name: Save build log + if: ${{ always() }} + uses: ./.github/actions/save-build-log + with: + id: asan-ubsan-clang-${{ env.LLVM_VERSION }} + title: Ubuntu 26.04 (Clang ${{ env.LLVM_VERSION }}, ASan + UBSan) - name: Test working-directory: ${{github.workspace}}/build diff --git a/.github/workflows/warnings-report.yml b/.github/workflows/warnings-report.yml deleted file mode 100644 index ced1ab6..0000000 --- a/.github/workflows/warnings-report.yml +++ /dev/null @@ -1,122 +0,0 @@ -name: Warnings Report - -# Builds with clang-tidy (checks from .clang-tidy) and with GCC (project warning flags), -# then posts a deduplicated warnings report as a PR comment (updated on each push). -# Warnings do not fail the build. - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - workflow_dispatch: - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{ github.event_name == 'pull_request' }} - -jobs: - - build: - name: ${{ matrix.name }} - runs-on: ubuntu-26.04 - timeout-minutes: 90 - strategy: - fail-fast: false - matrix: - include: [ - { name: "clang-tidy (clang-22)", id: clang-tidy, cc: clang-22, cxx: clang++-22, tidy: clang-tidy-22 }, - { name: "gcc-15 warnings", id: gcc, cc: gcc-15, cxx: g++-15, tidy: "" }, - ] - - steps: - - uses: actions/checkout@v7 - - - name: Install Dependencies - run: | - sudo apt-get update - sudo apt-get install libgtkmm-3.0-dev gettext - - # toolchains/linux-dev-with-tidy.cmake hardcodes an unversioned "clang-tidy", - # so we use linux-dev.cmake and pass the versioned binary. - - name: Configure CMake - env: - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - run: > - cmake -B build -S "$GITHUB_WORKSPACE" - -DCMAKE_BUILD_TYPE=Debug - -DCMAKE_TOOLCHAIN_FILE="$GITHUB_WORKSPACE/toolchains/linux-dev.cmake" - -DCMAKE_CXX_CLANG_TIDY="${{ matrix.tidy }}" - - - name: Build - run: | - set -o pipefail - cmake --build build --parallel "$(nproc)" 2>&1 | tee build.log - - - name: Upload build log - if: ${{ always() }} - uses: actions/upload-artifact@v7 - with: - name: build-log-${{ matrix.id }} - path: build.log - if-no-files-found: ignore - retention-days: 7 - - - report: - needs: build - if: ${{ always() }} - runs-on: ubuntu-latest - timeout-minutes: 10 - permissions: - contents: read - pull-requests: write - - steps: - - uses: actions/checkout@v7 - - - name: Download build logs - uses: actions/download-artifact@v8 - with: - pattern: build-log-* - path: logs - - - name: Get changed files - if: ${{ github.event_name == 'pull_request' }} - env: - GH_TOKEN: ${{ github.token }} - PR_NUMBER: ${{ github.event.pull_request.number }} - run: > - gh api --paginate "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/files" -q '.[].filename' - > changed-files.txt - - - name: Generate report - run: | - changed=() - if [ -f changed-files.txt ]; then changed=(--changed-files changed-files.txt); fi - python3 .github/scripts/warnings_report.py \ - --workspace "$GITHUB_WORKSPACE" --build-dir build "${changed[@]}" \ - --log "clang-tidy (clang-22)=logs/build-log-clang-tidy/build.log" \ - --log "GCC 15=logs/build-log-gcc/build.log" \ - > report.md - cat report.md >> "$GITHUB_STEP_SUMMARY" - - # The token is read-only for PRs from forks, so the report is only in the job summary there. - - name: Post or update PR comment - if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository }} - env: - GH_TOKEN: ${{ github.token }} - PR_NUMBER: ${{ github.event.pull_request.number }} - run: | - marker='' - comment_id=$(gh api --paginate "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" \ - -q ".[] | select(.user.login == \"github-actions[bot]\" and (.body | startswith(\"$marker\"))) | .id" | head -n 1) - if [ -n "$comment_id" ]; then - gh api -X PATCH "repos/$GITHUB_REPOSITORY/issues/comments/$comment_id" -F body=@report.md > /dev/null - else - gh api -X POST "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" -F body=@report.md > /dev/null - fi diff --git a/.github/workflows/windows-msys2.yml b/.github/workflows/windows-msys2.yml index 354f704..a1c89f4 100644 --- a/.github/workflows/windows-msys2.yml +++ b/.github/workflows/windows-msys2.yml @@ -83,8 +83,16 @@ jobs: -DCMAKE_TOOLCHAIN_FILE="$GITHUB_WORKSPACE/toolchains/win64-mingw-msys2.cmake" - name: Build - working-directory: ${{github.workspace}}/build - run: cmake --build . --config $BUILD_TYPE + run: | + set -o pipefail + cmake --build build --config $BUILD_TYPE 2>&1 | tee build.log + + - name: Save build log + if: ${{ always() }} + uses: ./.github/actions/save-build-log + with: + id: windows-ucrt64-${{ inputs.build-type }} + title: Windows UCRT64 (GCC) - name: Test working-directory: ${{github.workspace}}/build