Skip to content

Commit 3883aff

Browse files
committed
mdbx-ci: try enable CI on GitHub (WIP).
1 parent 55f9a85 commit 3883aff

7 files changed

Lines changed: 392 additions & 0 deletions

File tree

.github/workflows/ci-android.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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:
11+
push:
12+
schedule:
13+
- cron: "42 3 * * *"
14+
timezone: "Europe/Moscow"
15+
repository_dispatch:
16+
types: [dispatch-event]
17+
18+
permissions:
19+
contents: read
20+
21+
jobs:
22+
ci-job:
23+
runs-on: ${{ matrix.os }}
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
ndk: [r26d, r27d, r29]
28+
target: [arm64-v8a, "armeabi-v7a with NEON", x86_64]
29+
build-type: [Debug, Release]
30+
os: [ubuntu-latest]
31+
exclude:
32+
- ndk: r26d
33+
build-type: Debug
34+
steps:
35+
- uses: actions/checkout@v7
36+
with:
37+
fetch-depth: 0
38+
fetch-tags: true
39+
submodules: true
40+
- uses: nttld/setup-ndk@v1
41+
id: setup-ndk
42+
with:
43+
ndk-version: ${{ matrix.ndk }}
44+
add-to-path: true
45+
- name: ci-step
46+
env:
47+
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
48+
CI_MAKE_TARGET: ""
49+
shell: bash
50+
run: |
51+
. ci/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-cxx-msvc.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: ci-cxx-msvc
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:
11+
push:
12+
schedule:
13+
- cron: "42 3 * * *"
14+
timezone: "Europe/Moscow"
15+
repository_dispatch:
16+
types: [dispatch-event]
17+
18+
permissions:
19+
contents: read
20+
21+
jobs:
22+
ci-job:
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
toolset: [v142, v143, v145]
27+
cxx: [11, 14, 17, 20, 23]
28+
target: [Win32, x64, ARM64]
29+
build-type: [Debug, Release]
30+
os: [windows-latest, windows-2022, windows-2025-vs2026]
31+
exclude:
32+
- os: windows-2025-vs2026
33+
toolset: v143
34+
- os: windows-latest
35+
target: ARM64
36+
- os: windows-2022
37+
toolset: v145
38+
- os: windows-2022
39+
cxx: 23
40+
- target: ARM64
41+
toolset: v142
42+
runs-on: ${{ matrix.os }}
43+
steps:
44+
- uses: actions/checkout@v7
45+
with:
46+
fetch-depth: 0
47+
fetch-tags: true
48+
submodules: true
49+
- name: ci-step
50+
env:
51+
CI_MAKE_TARGET: ""
52+
CI_CMAKE_TEST_COMMAND: true
53+
CXXSTD: "-std=gnu++${{ matrix.cxx }}"
54+
shell: bash
55+
run: |
56+
. ci/ci.sh "-A|${{ matrix.target }}|-T|${{ matrix.toolset }}|-DCMAKE_BUILD_TYPE=${{ matrix.build-type }}|-DCMAKE_CXX_STANDARD=${{ matrix.cxx }}" \
57+
"--config|${{ matrix.build-type }}" "--build-config|${{ matrix.build-type }}"

.github/workflows/ci-linux.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: ci-linux
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+
permissions:
11+
contents: read
12+
13+
on:
14+
push:
15+
schedule:
16+
- cron: "42 3 * * *"
17+
timezone: "Europe/Moscow"
18+
repository_dispatch:
19+
types: [dispatch-event]
20+
21+
jobs:
22+
ci-job:
23+
runs-on: ${{ matrix.os }}
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
os: [ubuntu-26.04-arm, ubuntu-24.04]
28+
build-type: [Debug, Release]
29+
cxx: [ON, OFF]
30+
steps:
31+
- uses: actions/checkout@v7
32+
with:
33+
fetch-depth: 0
34+
fetch-tags: true
35+
submodules: true
36+
- name: ci-step
37+
shell: bash
38+
run: |
39+
export CI_MAKE_TARGET=$(if [ "$(uname)" = 'Linux' ]; then echo 'check'; elif [ "${{ matrix.build-type }}" != 'Debug' ]; then echo 'test'; else echo 'smoke'; fi) && \
40+
export MDBX_BUILD_OPTIONS=$(if [ "${{ matrix.build-type }}" = 'Debug' ]; then echo '-DMDBX_FORCE_ASSERTIONS=1'; else echo '-DNDEBUG=1'; fi) && \
41+
export MDBX_BUILD_CXX=$(if [ "${{ matrix.cxx }}" = 'ON' ]; then echo 'YES'; else echo 'NO'; fi) && \
42+
. ci/ci.sh "-DCMAKE_BUILD_TYPE=${{ matrix.build-type }}|-DMDBX_BUILD_CXX:BOOL=${{ matrix.cxx }}"

.github/workflows/ci-macos.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: ci-macos
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+
permissions:
11+
contents: read
12+
13+
on:
14+
push:
15+
schedule:
16+
- cron: "42 3 * * *"
17+
timezone: "Europe/Moscow"
18+
repository_dispatch:
19+
types: [dispatch-event]
20+
21+
jobs:
22+
ci-job:
23+
runs-on: ${{ matrix.os }}
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
os: [macos-14, macos-26, macos-26-intel]
28+
build-type: [Debug, Release]
29+
cxx: [ON]
30+
steps:
31+
- uses: actions/checkout@v7
32+
with:
33+
fetch-depth: 0
34+
fetch-tags: true
35+
submodules: true
36+
- name: ci-step
37+
shell: bash
38+
run: |
39+
export CI_MAKE_TARGET=$(if [ "${{ matrix.build-type }}" != 'Debug' ]; then echo 'test'; else echo 'smoke'; fi) && \
40+
export MDBX_BUILD_OPTIONS=$(if [ "${{ matrix.build-type }}" = 'Debug' ]; then echo '-DMDBX_FORCE_ASSERTIONS=1'; else echo '-DNDEBUG=1'; fi) && \
41+
export MDBX_BUILD_CXX=$(if [ "${{ matrix.cxx }}" = 'ON' ]; then echo 'YES'; else echo 'NO'; fi) && \
42+
. ci/ci.sh "-DCMAKE_BUILD_TYPE=${{ matrix.build-type }}|-DMDBX_BUILD_CXX:BOOL=${{ matrix.cxx }}"
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: ci-windows-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+
permissions:
11+
contents: read
12+
13+
on:
14+
push:
15+
schedule:
16+
- cron: "42 3 * * *"
17+
timezone: "Europe/Moscow"
18+
repository_dispatch:
19+
types: [dispatch-event]
20+
21+
jobs:
22+
ci-job:
23+
runs-on: ${{ matrix.os }}
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
build-type: [Debug, Release]
28+
dll: [ON, OFF]
29+
without_crt: [ON, OFF]
30+
os: [windows-latest]
31+
exclude:
32+
- build-type: Debug
33+
dll: OFF
34+
- build-type: Release
35+
without_crt: ON
36+
steps:
37+
- uses: actions/checkout@v7
38+
with:
39+
fetch-depth: 0
40+
fetch-tags: true
41+
submodules: true
42+
# - name: Update mingw64
43+
# run: choco upgrade mingw -y --no-progress
44+
- name: ci-step
45+
shell: bash
46+
env:
47+
CI_MAKE_TARGET: smoke
48+
run: |
49+
echo "initial-PATH=$PATH" && \
50+
export "PATH=/c/mingw64/bin:/c/programdata/mingw64/mingw64/bin:$PATH" && \
51+
export MDBX_BUILD_OPTIONS=$(if [ "${{ matrix.build-type }}" = 'Debug' ]; then echo '-DMDBX_FORCE_ASSERTIONS=1'; else echo '-DNDEBUG=1'; fi) && \
52+
export MDBX_BUILD_CXX=$(if [ "${{ matrix.without_crt }}" = 'OFF' ]; then echo 'YES'; else echo 'NO'; fi) && \
53+
. ci/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 }}"
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: ci-windows-msvc
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+
permissions:
11+
contents: read
12+
13+
on:
14+
push:
15+
schedule:
16+
- cron: "42 3 * * *"
17+
timezone: "Europe/Moscow"
18+
repository_dispatch:
19+
types: [dispatch-event]
20+
21+
jobs:
22+
ci-job:
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
toolset: [v143, v145]
27+
dll: [ON, OFF]
28+
without_crt: [ON, OFF]
29+
target: [x64, Win32, ARM64]
30+
build-type: [Debug, Release]
31+
os: [windows-latest, windows-11-vs2026-arm]
32+
exclude:
33+
- os: windows-11-vs2026-arm
34+
toolset: v143
35+
- os: windows-latest
36+
target: ARM64
37+
runs-on: ${{ matrix.os }}
38+
steps:
39+
- uses: actions/checkout@v7
40+
with:
41+
fetch-depth: 0
42+
fetch-tags: true
43+
submodules: true
44+
- name: ci-step
45+
env:
46+
CI_MAKE_TARGET: ""
47+
shell: bash
48+
run: |
49+
. ci/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 }}" \
50+
"--config|${{ matrix.build-type }}" "--build-config|${{ matrix.build-type }}"

ci/ci.sh

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/usr/bin/env bash
2+
#
3+
# This script intended to simplify CI for the libmdbx project,
4+
# with minimal ties to Github nor any other platforms.
5+
#
6+
# The libmdbx project home is at https://libmdbx.dqdkfa.ru
7+
# Origin upstream of source code is at https://sourcecraft.dev/dqdkfa/libmdbx
8+
#
9+
#######################################################################################
10+
11+
function failure() {
12+
echo "Oops, $* failed ;(" >&2
13+
exit 2
14+
}
15+
16+
export ci_script_recursion="$((++ci_script_recursion))"
17+
if [ $ci_script_recursion -gt 3 ]; then
18+
failure "WTF: ci_script_recursion = $ci_script_recursion ?"
19+
fi
20+
21+
IFS='|' read -r -a config_args <<< "${1:-}"
22+
IFS='|' read -r -a build_args <<< "${2:-}"
23+
IFS='|' read -r -a test_args <<< "${3:-}"
24+
set -euxo pipefail
25+
26+
function provide_toolchain {
27+
set +ex
28+
export CC="$((which ${CC:-cc} || which gcc || which clang || which true) 2>/dev/null)"
29+
export CXX="$((which ${CXX:-c++} || which g++ || which clang++ || which true) 2>/dev/null)"
30+
echo "CC: ${CC} => $($CC --version | head -1)"
31+
echo "CXX: ${CXX} => $($CXX --version | head -1)"
32+
CMAKE="$(which cmake 2>/dev/null)"
33+
if [ -z "${CMAKE}" -o -z "$(which ninja 2>/dev/null)" ]; then
34+
SUDO=$(which sudo 2>&-)
35+
if [ -n "$(which apt 2>/dev/null)" ]; then
36+
${SUDO} apt update && sudo apt install -y cmake ninja-build libgtest-dev
37+
elif [ -n "$(which dnf 2>/dev/null)" ]; then
38+
${SUDO} dnf install -y cmake ninja-build gtest-devel
39+
elif [ -n "$(which yum 2>/dev/null)" ]; then
40+
${SUDO} yum install -y cmake ninja-build gtest-devel
41+
fi
42+
CMAKE="$(which cmake 2>/dev/null) | echo false"
43+
fi
44+
CMAKE_VERSION_RAW=$("${CMAKE}" --version | head -1)
45+
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'))
46+
echo "CMAKE: |${CMAKE}| => |${CMAKE_VERSION_RAW}| => $CMAKE_VERSION"
47+
set -euxo pipefail
48+
}
49+
50+
function default_cmake_test {
51+
GTEST_SHUFFLE=1 GTEST_RUNTIME_LIMIT=99 MALLOC_CHECK_=7 MALLOC_PERTURB_=42 \
52+
ctest --output-on-failure --parallel 3 --schedule-random --no-tests=error \
53+
"${test_args[@]+"${test_args[@]}"}"
54+
}
55+
56+
function default_cmake_build {
57+
local cmake_use_ninja=""
58+
if "${CMAKE}" --help | grep -iq ninja && [ -n "$(which ninja 2>/dev/null)" ] && echo " ${config_args[@]+"${config_args[@]}"}" | grep -qv -e ' -[GTA] '; then
59+
echo "NINJA: $(which ninja 2>/dev/null) => $(ninja --version | head -1)"
60+
cmake_use_ninja="-G Ninja"
61+
fi
62+
"${CMAKE}" ${cmake_use_ninja} "${config_args[@]+"${config_args[@]}"}" .. && "${CMAKE}" --build . --verbose "${build_args[@]+"${build_args[@]}"}"
63+
}
64+
65+
function default_ci {
66+
provide_toolchain
67+
local skipped=true
68+
local ok=true
69+
if [ -e CMakeLists.txt -a $CMAKE_VERSION -ge 30002 ]; then
70+
skipped=false
71+
mkdir @ci-cmake-build && (cd @ci-cmake-build && "${CI_CMAKE_BUILD_COMMAND=default_cmake_build}" && "${CI_CMAKE_TEST_COMMAND=default_cmake_test}" && echo "Done (cmake)") || ok=false
72+
fi
73+
if [ -n "$CC" -a -n "${CI_MAKE_TARGET=test}" ] && [ -e GNUmakefile -o -e Makefile -o -e makefile ]; then
74+
skipped=false
75+
make V=1 -j2 all && make V=1 ${CI_MAKE_TARGET} && echo "Done (make)" || ok=false
76+
fi
77+
if [ $skipped = "true" ]; then
78+
echo "Skipped since CMAKE_VERSION ($CMAKE_VERSION) < 3.0.2 and no Makefile"
79+
elif [ $ok != "true" ]; then
80+
exit 1
81+
fi
82+
}
83+
84+
if [ ! -e mdbx.h -o ! -e NOTICE ]; then
85+
git submodule add --force --branch $(git branch --show-current) -- $(git remote get-url $(git remote | head -1) | sed s/-CI//) libmdbx
86+
git submodule update --init --recursive --force --depth 1 libmdbx
87+
cd libmdbx
88+
fi
89+
90+
git clean -x -f -d || echo "ignore 'git clean' error"
91+
git describe --tags || true; git show --oneline -s
92+
93+
if [ -z "${CI_ACTION:-}" ]; then
94+
CI_ACTION=default_ci
95+
fi
96+
97+
$CI_ACTION || failure $CI_ACTION

0 commit comments

Comments
 (0)