Skip to content

Commit 4e8a812

Browse files
committed
mdbx: add public-visible CI on Github.
1 parent c9f6859 commit 4e8a812

File tree

6 files changed

+271
-0
lines changed

6 files changed

+271
-0
lines changed

.github/workflows/ci-android.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: ci-android
2+
3+
env:
4+
CI: GITHUB
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
8+
cancel-in-progress: true
9+
10+
on: [push]
11+
12+
jobs:
13+
ci-job:
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
ndk: [r26d, r27c]
19+
target: [arm64-v8a, "armeabi-v7a with NEON", x86_64]
20+
build-type: [Debug, Release]
21+
os: [ubuntu-latest]
22+
exclude:
23+
- ndk: r26d
24+
build-type: Debug
25+
steps:
26+
- uses: actions/checkout@v4
27+
- uses: nttld/setup-ndk@v1
28+
id: setup-ndk
29+
with:
30+
ndk-version: ${{ matrix.ndk }}
31+
add-to-path: true
32+
- name: ci-step
33+
env:
34+
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
35+
CI_MAKE_TARGET: ""
36+
shell: bash
37+
run: |
38+
. ci.sh "-DANDROID_ABI=${{ matrix.target }}|-DCMAKE_TOOLCHAIN_FILE:PATH=${{ steps.setup-ndk.outputs.ndk-path }}/build/cmake/android.toolchain.cmake|-DCMAKE_BUILD_TYPE=${{ matrix.build-type }}"

.github/workflows/ci-mingw.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: ci-mingw
2+
3+
env:
4+
CI: GITHUB
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
8+
cancel-in-progress: true
9+
10+
on: [push]
11+
12+
jobs:
13+
ci-job:
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
build-type: [Debug, Release]
19+
dll: [ON, OFF]
20+
without_crt: [ON, OFF]
21+
os: [windows-latest]
22+
exclude:
23+
- build-type: Debug
24+
dll: OFF
25+
- build-type: Release
26+
without_crt: ON
27+
steps:
28+
- uses: actions/checkout@v4
29+
# - name: Update mingw64
30+
# run: choco upgrade mingw -y --no-progress
31+
- name: ci-step
32+
shell: bash
33+
env:
34+
CI_MAKE_TARGET: smoke
35+
run: |
36+
echo "initial-PATH=$PATH" && \
37+
export "PATH=/c/mingw64/bin:/c/programdata/mingw64/mingw64/bin:$PATH" && \
38+
export MDBX_BUILD_OPTIONS=$(if [ "${{ matrix.build-type }}" = 'Debug' ]; then echo '-DMDBX_FORCE_ASSERTIONS=1'; else echo '-DNDEBUG=1'; fi) && \
39+
export MDBX_BUILD_CXX=$(if [ "${{ matrix.without_crt }}" = 'OFF' ]; then echo 'YES'; else echo 'NO'; fi) && \
40+
. ci.sh "-G|MinGW Makefiles|-DCMAKE_BUILD_TYPE=${{ matrix.build-type }}|-DMDBX_BUILD_SHARED_LIBRARY:BOOL=${{ matrix.dll }}|-DMDBX_WITHOUT_MSVC_CRT:BOOL=${{ matrix.without_crt }}"

.github/workflows/ci-posix.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: ci-posix
2+
3+
env:
4+
CI: GITHUB
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
8+
cancel-in-progress: true
9+
10+
on: [push]
11+
12+
jobs:
13+
ci-job:
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
os: [ubuntu-24.04, macos-14, macos-26]
19+
build-type: [Debug, Release]
20+
# alloy: [ON, OFF]
21+
cxx: [ON, OFF]
22+
# exclude:
23+
# - os: macos-14
24+
# cxx: OFF
25+
# alloy: ON
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: ci-step
29+
shell: bash
30+
run: |
31+
export CI_MAKE_TARGET=$(if [ "$(uname)" = 'Linux' ]; then echo 'check'; elif [ "${{ matrix.build-type }}" != 'Debug' ]; then echo 'test'; else echo 'smoke'; fi) && \
32+
export MDBX_BUILD_OPTIONS=$(if [ "${{ matrix.build-type }}" = 'Debug' ]; then echo '-DMDBX_FORCE_ASSERTIONS=1'; else echo '-DNDEBUG=1'; fi) && \
33+
export MDBX_BUILD_CXX=$(if [ "${{ matrix.cxx }}" = 'ON' ]; then echo 'YES'; else echo 'NO'; fi) && \
34+
. ci.sh "-DCMAKE_BUILD_TYPE=${{ matrix.build-type }}|-DMDBX_BUILD_CXX:BOOL=${{ matrix.cxx }}"

.github/workflows/ci-wincxx.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: ci-wincxx
2+
3+
env:
4+
CI: GITHUB
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
8+
cancel-in-progress: true
9+
10+
on: [push]
11+
12+
jobs:
13+
ci-job:
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
toolset: [v142, v143]
18+
cxx: [11, 14, 17, 20]
19+
target: [Win32, x64, ARM64]
20+
build-type: [Debug, Release]
21+
os: [windows-latest, windows-2022]
22+
exclude:
23+
- os: windows-latest
24+
toolset: v142
25+
- os: windows-latest
26+
cxx: 11
27+
- os: windows-2022
28+
toolset: v143
29+
- os: windows-2022
30+
cxx: 20
31+
# - target: x64
32+
# build-type: Debug
33+
- target: ARM64
34+
toolset: v142
35+
runs-on: ${{ matrix.os }}
36+
steps:
37+
- uses: actions/checkout@v4
38+
- name: ci-step
39+
env:
40+
CI_MAKE_TARGET: ""
41+
CXXSTD: "-std=gnu++${{ matrix.cxx }}"
42+
shell: bash
43+
run: |
44+
. ci.sh "-A|${{ matrix.target }}|-T|${{ matrix.toolset }}|-DCMAKE_BUILD_TYPE=${{ matrix.build-type }}|-DCMAKE_CXX_STANDARD=${{ matrix.cxx }}" \
45+
"--config|${{ matrix.build-type }}" "--build-config|${{ matrix.build-type }}"

.github/workflows/ci-windows.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: ci-windows
2+
3+
env:
4+
CI: GITHUB
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
8+
cancel-in-progress: true
9+
10+
on: [push]
11+
12+
jobs:
13+
ci-job:
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
toolset: [v143]
18+
dll: [ON, OFF]
19+
without_crt: [ON, OFF]
20+
target: [x64, Win32]
21+
build-type: [Debug, Release]
22+
os: [windows-latest]
23+
runs-on: ${{ matrix.os }}
24+
steps:
25+
- uses: actions/checkout@v4
26+
- name: ci-step
27+
env:
28+
CI_MAKE_TARGET: ""
29+
shell: bash
30+
run: |
31+
. ci.sh "-A|${{ matrix.target }}|-T|${{ matrix.toolset }}|-DCMAKE_BUILD_TYPE=${{ matrix.build-type }}|-DMDBX_BUILD_SHARED_LIBRARY:BOOL=${{ matrix.dll }}|-DMDBX_WITHOUT_MSVC_CRT:BOOL=${{ matrix.without_crt }}" \
32+
"--config|${{ matrix.build-type }}" "--build-config|${{ matrix.build-type }}"

ci.sh

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/usr/bin/env bash
2+
3+
function failure() {
4+
echo "Oops, $* failed ;(" >&2
5+
exit 2
6+
}
7+
8+
export ci_script_recursion="$((++ci_script_recursion))"
9+
if [ $ci_script_recursion -gt 3 ]; then
10+
failure "WTF: ci_script_recursion = $ci_script_recursion ?"
11+
fi
12+
13+
IFS='|' read -r -a config_args <<< "${1:-}"
14+
IFS='|' read -r -a build_args <<< "${2:-}"
15+
IFS='|' read -r -a test_args <<< "${3:-}"
16+
set -euxo pipefail
17+
18+
function provide_toolchain {
19+
set +ex
20+
export CC="$((which ${CC:-cc} || which gcc || which clang || which true) 2>/dev/null)"
21+
export CXX="$((which ${CXX:-c++} || which g++ || which clang++ || which true) 2>/dev/null)"
22+
echo "CC: ${CC} => $($CC --version | head -1)"
23+
echo "CXX: ${CXX} => $($CXX --version | head -1)"
24+
CMAKE="$(which cmake 2>/dev/null)"
25+
if [ -z "${CMAKE}" -o -z "$(which ninja 2>/dev/null)" ]; then
26+
SUDO=$(which sudo 2>&-)
27+
if [ -n "$(which apt 2>/dev/null)" ]; then
28+
${SUDO} apt update && sudo apt install -y cmake ninja-build libgtest-dev
29+
elif [ -n "$(which dnf 2>/dev/null)" ]; then
30+
${SUDO} dnf install -y cmake ninja-build gtest-devel
31+
elif [ -n "$(which yum 2>/dev/null)" ]; then
32+
${SUDO} yum install -y cmake ninja-build gtest-devel
33+
fi
34+
CMAKE="$(which cmake 2>/dev/null) | echo false"
35+
fi
36+
CMAKE_VERSION=$(eval expr $("${CMAKE}" --version | sed -n 's/cmake version \([0-9]\{1,\}\)\.\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)/\10000 + \200 + \3/p' || echo '00000'))
37+
echo "CMAKE: ${CMAKE} => $(${CMAKE} --version | head -1) ($CMAKE_VERSION)"
38+
set -euxo pipefail
39+
}
40+
41+
function default_test {
42+
GTEST_SHUFFLE=1 GTEST_RUNTIME_LIMIT=99 MALLOC_CHECK_=7 MALLOC_PERTURB_=42 \
43+
ctest --output-on-failure --parallel 3 --schedule-random --no-tests=error \
44+
"${test_args[@]+"${test_args[@]}"}"
45+
}
46+
47+
function default_build {
48+
local cmake_use_ninja=""
49+
if "${CMAKE}" --help | grep -iq ninja && [ -n "$(which ninja 2>/dev/null)" ] && echo " ${config_args[@]+"${config_args[@]}"}" | grep -qv -e ' -[GTA] '; then
50+
echo "NINJA: $(which ninja 2>/dev/null) => $(ninja --version | head -1)"
51+
cmake_use_ninja="-G Ninja"
52+
fi
53+
"${CMAKE}" ${cmake_use_ninja} "${config_args[@]+"${config_args[@]}"}" .. && "${CMAKE}" --build . "${build_args[@]+"${build_args[@]}"}"
54+
}
55+
56+
function default_ci {
57+
provide_toolchain
58+
local skipped=true
59+
local ok=true
60+
if [ -e CMakeLists.txt -a $CMAKE_VERSION -ge 30002 ]; then
61+
skipped=false
62+
mkdir @build && (cd @build && default_build && default_test && echo "Done (cmake)") || ok=false
63+
fi
64+
if [ -n "$CC" -a -n "${CI_MAKE_TARGET=test}" ] && [ -e GNUmakefile -o -e Makefile -o -e makefile ]; then
65+
skipped=false
66+
make -j2 all && make ${CI_MAKE_TARGET} && echo "Done (make)" || ok=false
67+
fi
68+
if [ $skipped = "true" ]; then
69+
echo "Skipped since CMAKE_VERSION ($CMAKE_VERSION) < 3.0.2 and no Makefile"
70+
elif [ $ok != "true" ]; then
71+
exit 1
72+
fi
73+
}
74+
75+
git clean -x -f -d || echo "ignore 'git clean' error"
76+
git describe --tags || git show --oneline -s
77+
78+
if [ -z "${CI_ACTION:-}" ]; then
79+
CI_ACTION=default_ci
80+
fi
81+
82+
$CI_ACTION || failure $CI_ACTION

0 commit comments

Comments
 (0)