Skip to content

Commit 8e45b34

Browse files
committed
Merge branch '13-build-fix-stdfloat-support-across-ci-toolchains' into staging
2 parents 189b3a2 + eb662c4 commit 8e45b34

2 files changed

Lines changed: 181 additions & 124 deletions

File tree

.github/workflows/ci.yml

Lines changed: 174 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ name: CI
22

33
on:
44
push:
5-
branches: [ release, staging ]
5+
branches: [release, staging]
66
pull_request:
7-
branches: [ release, staging ]
7+
branches: [release, staging]
8+
89
env:
910
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
10-
11+
1112
jobs:
1213
build:
1314
name: ${{ matrix.os }} / ${{ matrix.compiler }}
@@ -33,122 +34,166 @@ jobs:
3334
compiler-version: 19
3435
- compiler: clang-20
3536
compiler-version: 20
37+
3638
steps:
37-
- name: Set badge output directory
38-
id: path
39-
run: |
40-
if [[ "${GITHUB_REF##*/}" == "staging" ]]; then
41-
echo "dir=status-staging" >> $GITHUB_OUTPUT
42-
else
43-
echo "dir=status" >> $GITHUB_OUTPUT
44-
fi
45-
46-
- name: Check skip list
47-
id: skip_check
48-
run: |
49-
skip_list=(
50-
"ubuntu-22.04:gcc-14"
51-
"ubuntu-22.04:gcc-15"
52-
"ubuntu-24.04:gcc-15"
53-
"ubuntu-24.04:clang-17"
54-
"macos-13:gcc-13"
55-
"macos-13:gcc-14"
56-
"macos-13:gcc-15"
39+
- name: Set badge output directory
40+
id: path
41+
shell: bash
42+
run: |
43+
if [[ "${GITHUB_REF##*/}" == "staging" ]]; then
44+
echo "dir=status-staging" >> "$GITHUB_OUTPUT"
45+
else
46+
echo "dir=status" >> "$GITHUB_OUTPUT"
47+
fi
48+
49+
- name: Check skip list
50+
id: skip_check
51+
shell: bash
52+
run: |
53+
skip_list=(
54+
"ubuntu-22.04:gcc-14"
55+
"ubuntu-22.04:gcc-15"
56+
"ubuntu-24.04:gcc-15"
57+
"ubuntu-24.04:clang-17"
5758
)
5859
59-
combo="${{ matrix.os }}:${{ matrix.compiler }}"
60-
echo "Checking combination: $combo"
61-
for skip in "${skip_list[@]}"; do
62-
if [[ "$combo" == "$skip" ]]; then
63-
echo "SKIP_COMPILE=true" >> "$GITHUB_ENV"
64-
exit 0
65-
fi
66-
done
60+
combo="${{ matrix.os }}:${{ matrix.compiler }}"
61+
echo "Checking combination: $combo"
62+
63+
for skip in "${skip_list[@]}"; do
64+
if [[ "$combo" == "$skip" ]]; then
65+
echo "SKIP_COMPILE=true" >> "$GITHUB_ENV"
66+
exit 0
67+
fi
68+
done
69+
6770
echo "SKIP_COMPILE=false" >> "$GITHUB_ENV"
6871
69-
- name: Setup compiler on macOS
70-
if: ${{ env.SKIP_COMPILE == 'false' && runner.os == 'macOS' }}
71-
run: |
72-
brew install llvm@${{ matrix.compiler-version }}
73-
echo "CC=$(brew --prefix llvm@${{ matrix.compiler-version }})/bin/clang" >> $GITHUB_ENV
74-
echo "CXX=$(brew --prefix llvm@${{ matrix.compiler-version }})/bin/clang++" >> $GITHUB_ENV
72+
- name: Checkout
73+
if: env.SKIP_COMPILE == 'false'
74+
uses: actions/checkout@v5
75+
with:
76+
fetch-depth: 0
77+
78+
- name: Install base dependencies
79+
if: env.SKIP_COMPILE == 'false'
80+
shell: bash
81+
run: |
82+
sudo apt-get update
83+
sudo apt-get install -y \
84+
cmake \
85+
ninja-build \
86+
wget \
87+
gnupg \
88+
lsb-release \
89+
software-properties-common
90+
91+
- name: Setup GCC
92+
if: env.SKIP_COMPILE == 'false' && startsWith(matrix.compiler, 'gcc-')
93+
shell: bash
94+
run: |
95+
version="${{ matrix.compiler-version }}"
7596
76-
- name: Setup compiler on Linux
77-
if: ${{ env.SKIP_COMPILE == 'false' && runner.os == 'Linux' }}
78-
run: |
79-
compiler="${{ matrix.compiler }}"
80-
version="${{ matrix.compiler-version }}"
97+
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
98+
sudo apt-get update
99+
sudo apt-get install -y gcc-"$version" g++-"$version"
100+
101+
echo "CC=$(command -v gcc-$version)" >> "$GITHUB_ENV"
102+
echo "CXX=$(command -v g++-$version)" >> "$GITHUB_ENV"
103+
echo "CFLAGS=" >> "$GITHUB_ENV"
104+
echo "CXXFLAGS=" >> "$GITHUB_ENV"
105+
echo "LDFLAGS=" >> "$GITHUB_ENV"
81106
82-
if [[ "$compiler" == clang-* ]]; then
107+
- name: Setup Clang with GCC-13 libstdc++
108+
if: env.SKIP_COMPILE == 'false' && startsWith(matrix.compiler, 'clang-')
109+
shell: bash
110+
run: |
111+
clang_version="${{ matrix.compiler-version }}"
112+
113+
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
83114
sudo apt-get update
84-
sudo apt-get install -y wget gnupg lsb-release software-properties-common
115+
sudo apt-get install -y gcc-13 g++-13
116+
85117
wget https://apt.llvm.org/llvm.sh
86118
chmod +x llvm.sh
87119
codename="$(. /etc/os-release && echo "$VERSION_CODENAME")"
88-
sudo DISTRIB_CODENAME="$codename" ./llvm.sh "$version" all
89-
CXX="clang++-$version"
90-
elif [[ "$compiler" == gcc-* ]]; then
91-
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
92-
sudo apt-get update
93-
sudo apt-get install -y g++-"$version"
94-
CXX="g++-$version"
95-
else
96-
CXX="g++"
97-
fi
98-
99-
which "$CXX" || { echo "$CXX not found in PATH"; exit 1; }
100-
echo "CXX=$(which $CXX)" >> "$GITHUB_ENV"
101-
102-
- name: Checkout
103-
uses: actions/checkout@v5
104-
with:
105-
fetch-depth: 0
106-
107-
- name: Install system dependencies on macOS
108-
if: ${{ env.SKIP_COMPILE == 'false' && runner.os == 'macOS' }}
109-
run: |
110-
brew update
111-
112-
- name: Install system dependencies on Linux
113-
if: ${{ env.SKIP_COMPILE == 'false' && runner.os == 'Linux' }}
114-
run: |
115-
sudo apt-get update
116-
sudo apt-get install -y cmake ninja-build
117-
118-
- name: Configure
119-
if: env.SKIP_COMPILE == 'false'
120-
run: cmake -B build -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_CXX_STANDARD=23 -DCMAKE_BUILD_TYPE=Release
121-
122-
- name: Build
123-
if: env.SKIP_COMPILE == 'false'
124-
run: cmake --build build --parallel
125-
126-
- name: Test
127-
if: env.SKIP_COMPILE == 'false'
128-
run: ctest --test-dir build --output-on-failure
129-
130-
- name: Record Badge Status
131-
if: always()
132-
run: |
133-
mkdir -p badge-status
134-
status="skipped"
135-
if [[ "$SKIP_COMPILE" == "false" ]]; then
136-
status="${{ job.status }}"
137-
fi
138-
139-
cat <<EOF > badge-status/status-${{ matrix.os }}-${{ matrix.compiler }}.json
140-
{
141-
"os": "${{ matrix.os }}",
142-
"compiler": "${{ matrix.compiler }}",
143-
"status": "$status"
144-
}
145-
EOF
146-
- name: Upload Status Artifact
147-
if: always()
148-
uses: actions/upload-artifact@v6
149-
with:
150-
name: status-${{ matrix.os }}-${{ matrix.compiler }}
151-
path: badge-status/status-${{ matrix.os }}-${{ matrix.compiler }}.json
120+
sudo DISTRIB_CODENAME="$codename" ./llvm.sh "$clang_version" all
121+
122+
cc_bin="$(command -v clang-$clang_version)"
123+
cxx_bin="$(command -v clang++-$clang_version)"
124+
gxx13_bin="$(readlink -f "$(command -v g++-13)")"
125+
gcc_root="$(dirname "$(dirname "$gxx13_bin")")"
126+
127+
test -n "$cc_bin"
128+
test -n "$cxx_bin"
129+
test -n "$gcc_root"
130+
131+
echo "CC=$cc_bin" >> "$GITHUB_ENV"
132+
echo "CXX=$cxx_bin" >> "$GITHUB_ENV"
133+
echo "CFLAGS=--gcc-toolchain=$gcc_root" >> "$GITHUB_ENV"
134+
echo "CXXFLAGS=--gcc-toolchain=$gcc_root -stdlib=libstdc++" >> "$GITHUB_ENV"
135+
echo "LDFLAGS=--gcc-toolchain=$gcc_root -stdlib=libstdc++" >> "$GITHUB_ENV"
136+
137+
- name: Show compiler environment
138+
if: env.SKIP_COMPILE == 'false'
139+
shell: bash
140+
run: |
141+
echo "CC=$CC"
142+
echo "CXX=$CXX"
143+
echo "CFLAGS=$CFLAGS"
144+
echo "CXXFLAGS=$CXXFLAGS"
145+
echo "LDFLAGS=$LDFLAGS"
146+
"$CC" --version
147+
"$CXX" --version
148+
149+
- name: Configure
150+
if: env.SKIP_COMPILE == 'false'
151+
shell: bash
152+
run: |
153+
cmake -B build -G Ninja \
154+
-DCMAKE_BUILD_TYPE=Release \
155+
-DCMAKE_C_STANDARD=17 \
156+
-DCMAKE_CXX_STANDARD=23 \
157+
-DCMAKE_C_COMPILER="$CC" \
158+
-DCMAKE_CXX_COMPILER="$CXX" \
159+
-DCMAKE_C_FLAGS="$CFLAGS" \
160+
-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
161+
-DCMAKE_EXE_LINKER_FLAGS="$LDFLAGS" \
162+
-DCMAKE_SHARED_LINKER_FLAGS="$LDFLAGS"
163+
164+
- name: Build
165+
if: env.SKIP_COMPILE == 'false'
166+
run: cmake --build build --parallel
167+
168+
- name: Test
169+
if: env.SKIP_COMPILE == 'false'
170+
run: ctest --test-dir build --output-on-failure
171+
172+
- name: Record Badge Status
173+
if: always()
174+
shell: bash
175+
run: |
176+
mkdir -p badge-status
177+
status="skipped"
178+
179+
if [[ "${SKIP_COMPILE:-false}" == "false" ]]; then
180+
status="${{ job.status }}"
181+
fi
182+
183+
cat > "badge-status/status-${{ matrix.os }}-${{ matrix.compiler }}.json" <<EOF
184+
{
185+
"os": "${{ matrix.os }}",
186+
"compiler": "${{ matrix.compiler }}",
187+
"status": "${status}"
188+
}
189+
EOF
190+
191+
- name: Upload Status Artifact
192+
if: always()
193+
uses: actions/upload-artifact@v4
194+
with:
195+
name: status-${{ matrix.os }}-${{ matrix.compiler }}
196+
path: badge-status/status-${{ matrix.os }}-${{ matrix.compiler }}.json
152197

153198
generate-badges:
154199
name: Generate SVG Badges
@@ -159,50 +204,56 @@ jobs:
159204
steps:
160205
- name: Determine badge target directory
161206
id: badge_dir
207+
shell: bash
162208
run: |
163209
if [[ "${GITHUB_REF##*/}" == "staging" ]]; then
164-
echo "dir=badges-staging" >> $GITHUB_OUTPUT
210+
echo "dir=badges-staging" >> "$GITHUB_OUTPUT"
165211
else
166-
echo "dir=badges" >> $GITHUB_OUTPUT
212+
echo "dir=badges" >> "$GITHUB_OUTPUT"
167213
fi
168214
169215
- name: Install jq
170-
run: sudo apt-get update && sudo apt-get install -y jq
216+
shell: bash
217+
run: |
218+
sudo apt-get update
219+
sudo apt-get install -y jq curl
171220
172221
- name: Download all badge status artifacts
173-
uses: actions/download-artifact@v7
222+
uses: actions/download-artifact@v4
174223
with:
175224
path: badge-status
176225
pattern: status-*
177226
merge-multiple: true
178227

179-
- name: Generate SVG Badges
228+
- name: Generate SVG badges
229+
shell: bash
180230
run: |
181-
mkdir -p ${{ steps.badge_dir.outputs.dir }}
231+
mkdir -p "${{ steps.badge_dir.outputs.dir }}"
232+
182233
for f in badge-status/*.json; do
183-
echo "file name: $f"
184234
[[ ! -f "$f" ]] && continue
185-
os=$(jq -r .os "$f")
186-
compiler=$(jq -r .compiler "$f")
187-
status=$(jq -r .status "$f")
235+
236+
os="$(jq -r .os "$f")"
237+
compiler="$(jq -r .compiler "$f")"
238+
status="$(jq -r .status "$f")"
188239
189240
color="gray"
190241
symbol="□"
191242
prefix="unknown"
192243
193244
[[ "$status" == "success" ]] && { symbol="✔"; color="green"; prefix="ok"; }
194-
[[ "$status" == "skipped" ]] && { symbol="○"; color="gray"; prefix="na"; }
195-
[[ "$status" == "failure" ]] && { symbol="✘"; color="red"; prefix="failed"; }
245+
[[ "$status" == "skipped" ]] && { symbol="○"; color="gray"; prefix="na"; }
246+
[[ "$status" == "failure" ]] && { symbol="✘"; color="red"; prefix="failed"; }
196247
197248
label="${os}-${compiler}"
198249
badge="${{ steps.badge_dir.outputs.dir }}/${label}.svg"
199-
echo "https://img.shields.io/badge/${prefix}-${symbol}-${color}.svg $badge"
200-
curl -s "https://img.shields.io/badge/${prefix}-${symbol}-${color}.svg" -o "$badge"
250+
251+
curl -fsSL "https://img.shields.io/badge/${prefix}-${symbol}-${color}.svg" -o "$badge"
201252
done
202253
203254
- name: Upload badge folder to GitHub Pages
204255
uses: peaceiris/actions-gh-pages@v4
205256
with:
206257
github_token: ${{ secrets.GITHUB_TOKEN }}
207258
publish_dir: ./${{ steps.badge_dir.outputs.dir }}
208-
destination_dir: ${{ steps.badge_dir.outputs.dir }}
259+
destination_dir: ${{ steps.badge_dir.outputs.dir }}

test/decimal.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@
55
#include <stdint.h>
66
#include <doctest/all>
77
#include <decimal.hpp>
8-
#include <stdfloat>
8+
9+
#if __has_include(<stdfloat>)
10+
#include <stdfloat>
11+
#define LIBDECIMAL_HAS_STDFLOAT 1
12+
#else
13+
#define LIBDECIMAL_HAS_STDFLOAT 0
14+
#endif
915

1016
#define TRACE std::cerr
1117
#define uint128_t __uint128_t

0 commit comments

Comments
 (0)