-
Notifications
You must be signed in to change notification settings - Fork 0
199 lines (167 loc) · 6.31 KB
/
abi-diff.yml
File metadata and controls
199 lines (167 loc) · 6.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
name: Detect ABI Diff
on:
workflow_call:
inputs:
os:
type: string
default: ubuntu-22.04
cc:
type: string
default: clang-20
cxx:
type: string
default: clang++-20
cmake-version:
type: string
default: 3.21.7
conan-version:
type: string
default: 2.23.0
setup_tools:
type: boolean
default: false
# 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: .
# Optionally, the cmake target needed to generate the version file
abi-version-cmake-target:
type: string
required: false
# 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-16,17
if: inputs.setup_tools
uses: dice-group/cpp-conan-release-reusable-workflow/.github/actions/setup_apt@main
- name: Get minimum cmake version
if: inputs.setup_tools
uses: lukka/get-cmake@v3.29.6
with:
cmakeVersion: ${{ inputs.cmake-version }}
- name: Install compiler
if: inputs.setup_tools
id: install_cc
uses: rlalik/setup-cpp-compiler@v1.2
with:
compiler: ${{ inputs.cc }}
- name: Set compiler env installed
if: inputs.setup_tools
run: |
echo "CC=${{ steps.install_cc.outputs.cc }}" >> $GITHUB_ENV
echo "CXX=${{ steps.install_cc.outputs.cxx }}" >> $GITHUB_ENV
- name: Set compiler env preinstalled
if: inputs.setup_tools == false
run: |
echo "CC=${{ inputs.cc }}" >> $GITHUB_ENV
echo "CXX=${{ inputs.cxx }}" >> $GITHUB_ENV
- name: Install conan
if: inputs.setup_tools
uses: dice-group/cpp-conan-release-reusable-workflow/.github/actions/configure_conan@main
with:
conan-version: ${{ inputs.conan-version }}
- name: Add conan remotes
if: inputs.setup_tools
run: |
conan remote add dice-group https://conan.dice-research.org/artifactory/api/conan/tentris
conan remote add tentris-private https://conan.dice-research.org/artifactory/api/conan/tentris-private
- name: Conan login
run: |
conan remote login -p "${{ secrets.CONAN_PW }}" tentris-private "${{ secrets.CONAN_USER }}"
- name: Cache conan data
id: cache-conan
uses: actions/cache@v4
with:
path: ~/.conan2/p
key: conan2-${{ inputs.os }}-${{ inputs.compiler }}-abi-diff
- uses: actions/checkout@v4
with:
fetch-depth: 0 # needed to check out all branches for this Action to work
- name: Get dependency provider
uses: dice-group/cpp-conan-release-reusable-workflow/.github/actions/add_conan_provider@main
- 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
# Diff this branch vs the base branch
- name: Run diff
id: diff
run: |
# this is a workaround, if I put the github expansions directly into
# the line below these two it doesn't work
base_branch="${{ inputs.base-branch }}"
search_path="${{ inputs.search-path }}"
diff_lines=$(git diff "remotes/origin/$base_branch" -- $search_path | wc -l)
echo "Diff has $diff_lines lines"
echo "nlines=$diff_lines" >> "$GITHUB_OUTPUT"
- name: Generate version file on feature branch
uses: dice-group/cpp-conan-release-reusable-workflow/.github/actions/generate_version_file@main
with:
cc: ${{ env.CC }}
cxx: ${{ env.CXX }}
build-dir: build_dir
target: ${{ inputs.abi-version-cmake-target }}
- name: Fetch current ABI version
id: current-abi-version
run: |
${{ env.CXX }} -std=c++20 -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: Switch to base branch
run: |
rm -rf build_dir
git switch ${{ inputs.base-branch }}
- name: Regenerate version file for base branch
uses: dice-group/cpp-conan-release-reusable-workflow/.github/actions/generate_version_file@main
with:
cc: ${{ env.CC }}
cxx: ${{ env.CXX }}
build-dir: build_dir
target: ${{ inputs.abi-version-cmake-target }}
- name: Fetch base branch ABI version
id: base-abi-version
run: |
${{ env.CXX }} -std=c++20 -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