From bfa2f735f290fe30b3fddd6b9b7d8d96f557ca29 Mon Sep 17 00:00:00 2001
From: Andrea Pappacoda <andrea@pappacoda.it>
Date: Fri, 14 Feb 2025 20:06:35 +0100
Subject: [PATCH] ci: add abidiff workflow (#2054)

This CI workflow checks ABI compatibility between the pushed commit and
the latest tagged release, helping preventing accidental ABI breaks.

Helps with https://github.com/yhirose/cpp-httplib/issues/2043
---
 .github/workflows/abidiff.yaml | 64 ++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)
 create mode 100644 .github/workflows/abidiff.yaml

diff --git a/.github/workflows/abidiff.yaml b/.github/workflows/abidiff.yaml
new file mode 100644
index 0000000..e914a06
--- /dev/null
+++ b/.github/workflows/abidiff.yaml
@@ -0,0 +1,64 @@
+# SPDX-FileCopyrightText: 2025 Andrea Pappacoda <andrea@pappacoda.it>
+# SPDX-License-Identifier: MIT
+
+name: abidiff
+
+on: [push, pull_request]
+
+defaults:
+  run:
+    shell: sh
+
+jobs:
+  abi:
+    runs-on: ubuntu-latest
+    container:
+      image: debian:testing
+
+    steps:
+    - name: Install dependencies
+      run: apt -y --update install --no-install-recommends
+        abigail-tools
+        ca-certificates
+        g++
+        git
+        libbrotli-dev
+        libssl-dev
+        meson
+        pkg-config
+        python3
+        zlib1g-dev
+
+    - uses: actions/checkout@v4
+      with:
+        path: current
+
+    - uses: actions/checkout@v4
+      with:
+        path: previous
+        fetch-depth: 0
+
+    - name: Checkout previous
+      working-directory: previous
+      run: |
+        git switch master
+        git describe --tags --abbrev=0 master | xargs git checkout
+
+    - name: Build current
+      working-directory: current
+      run: |
+        meson setup --buildtype=debug -Dcpp-httplib_compile=true build
+        ninja -C build
+
+    - name: Build previous
+      working-directory: previous
+      run: |
+        meson setup --buildtype=debug -Dcpp-httplib_compile=true build
+        ninja -C build
+
+    - name: Run abidiff
+      run: abidiff
+        --headers-dir1 previous/build
+        --headers-dir2 current/build
+        previous/build/libcpp-httplib.so
+        current/build/libcpp-httplib.so