-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
159 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
name: Detect ABI Diff | ||
on: | ||
workflow_call: | ||
inputs: | ||
os: | ||
type: string | ||
default: ubuntu-22.04 | ||
compiler: | ||
type: string | ||
default: clang-17 | ||
cmake-version: | ||
type: string | ||
default: 3.21.7 | ||
conan-version: | ||
type: string | ||
default: 1.62.0 | ||
|
||
# Branch to compare to | ||
base-branch: | ||
type: string | ||
default: develop | ||
|
||
# Glob for files to include in the diff (this is used like: git diff {base} -- {search-path}) | ||
search-path: | ||
type: string | ||
default: . | ||
|
||
# Path to the header-file the ABI version is defined in | ||
abi-version-header: | ||
type: string | ||
required: true | ||
|
||
# Name of the (char[]) constant the ABI version is defined in | ||
abi-version-const: | ||
type: string | ||
required: true | ||
|
||
secrets: | ||
CONAN_USER: | ||
required: true | ||
CONAN_PW: | ||
required: true | ||
|
||
jobs: | ||
detect-abi-diff: | ||
name: Detects potential ABI differences | ||
defaults: | ||
run: | ||
shell: bash | ||
runs-on: ${{ inputs.os }} | ||
steps: | ||
- name: Add Repos for for gcc-13 and clang-17 | ||
run: | | ||
# gcc-13 | ||
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y | ||
source /etc/os-release | ||
# clang-16 | ||
echo "deb http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME}-16 main" | sudo tee /etc/apt/sources.list.d/llvm-16.list | ||
# clang-17 | ||
echo "deb http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME}-17 main" | sudo tee /etc/apt/sources.list.d/llvm-17.list | ||
curl https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/llvm.gpg > /dev/null | ||
- name: Ensure stdlib version | ||
run: | | ||
sudo apt install libstdc++-13-dev -y | ||
- name: Get minimum cmake version | ||
uses: lukka/get-cmake@latest | ||
with: | ||
cmakeVersion: ${{ inputs.cmake-version }} | ||
|
||
- name: Install compiler | ||
id: install_cc | ||
uses: rlalik/[email protected] | ||
with: | ||
compiler: ${{ inputs.compiler }} | ||
|
||
- name: Configure conan | ||
run: | | ||
pip3 install conan==${{ inputs.conan-version }} | ||
conan profile new --detect default | ||
conan profile update settings.compiler.libcxx=libstdc++11 default | ||
conan remote add -f dice-group https://conan.dice-research.org/artifactory/api/conan/tentris | ||
- name: Cache conan data | ||
id: cache-conan | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.conan/data | ||
key: conan-${{ inputs.os }}-${{ inputs.compiler }}-abi-diff | ||
|
||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 # needed to check out all branches for this Action to work | ||
|
||
- name: Run diff | ||
id: diff | ||
run: | | ||
git diff remotes/origin/${{ inputs.base-branch }} -- ${{ inputs.search-path }} > /tmp/diff.txt | ||
diff_lines=$(cat /tmp/diff.txt | wc -l) | ||
echo "Diff has $diff_lines lines" | ||
echo "nlines=$diff_lines" >> "$GITHUB_OUTPUT" | ||
# Run cmake because the version file might be generated by it | ||
- name: Configure CMake | ||
env: | ||
CC: ${{ steps.install_cc.outputs.cc }} | ||
CXX: ${{ steps.install_cc.outputs.cxx }} | ||
run: | | ||
cmake -G Ninja -B build_dir | ||
- name: Create ABI version detection program | ||
run: | | ||
PROG=$(cat << EOF | ||
#include <iostream> | ||
#include <${{ inputs.abi-version-header }}> | ||
int main() { | ||
std::cout << ${{ inputs.abi-version-const }} << std::endl; | ||
} | ||
EOF | ||
) | ||
echo "$PROG" > /tmp/detect-abi-version.cpp | ||
- name: Fetch current ABI version | ||
id: current-abi-version | ||
run: | | ||
${{ steps.install_cc.outputs.cxx }} -I. -o /tmp/detect-abi-version-current /tmp/detect-abi-version.cpp | ||
abi_version=$(/tmp/detect-abi-version-current) | ||
echo "Current ABI version: $abi_version" | ||
echo "abi_version=$abi_version" >> "$GITHUB_OUTPUT" | ||
- name: Fetch base branch ABI version | ||
id: base-abi-version | ||
run: | | ||
git switch ${{ inputs.base-branch }} | ||
${{ steps.install_cc.outputs.cxx }} -I. -o /tmp/detect-abi-version-base /tmp/detect-abi-version.cpp | ||
abi_version=$(/tmp/detect-abi-version-base) | ||
echo "Base ABI version: $abi_version" | ||
echo "abi_version=$abi_version" >> "$GITHUB_OUTPUT" | ||
- name: Check missing ABI version bump | ||
if: ${{ steps.diff.outputs.nlines != 0 && steps.current-abi-version.outputs.abi_version == steps.base-abi-version.outputs.abi_version }} | ||
run: | | ||
echo "::error::Files changed but ABI version was not changed" | ||
exit 1 | ||
- name: Check erroneous ABI version bump | ||
if: ${{ steps.diff.outputs.nlines == 0 && steps.current-abi-version.outputs.abi_version != steps.base-abi-version.outputs.abi_version }} | ||
run: | | ||
echo "::error::Files did not change but ABI version was changed" | ||
exit 1 |