Skip to content

Commit 4e84b0d

Browse files
committed
CI: do not require admin rights
1 parent f40ba97 commit 4e84b0d

File tree

6 files changed

+88
-40
lines changed

6 files changed

+88
-40
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ jobs:
2424
run: |
2525
echo "/host_usr_local/bin" >> $GITHUB_PATH
2626
script/ci_setup_linux.sh
27-
- name: Setup Dependencies
28-
run: script/ci_setup_dependencies.sh
29-
- name: Build
30-
run: script/ci_build.sh
27+
- name: Build and Test
28+
run: script/ci_run.sh run_tests
3129

3230

3331
build_clang:
@@ -62,10 +60,8 @@ jobs:
6260
apt-get install -y --no-install-recommends libunwind-${{ matrix.build_config.version }}-dev;
6361
fi
6462
echo "CXXFLAGS=-stdlib=libc++" >> $GITHUB_ENV
65-
- name: Setup Dependencies
66-
run: script/ci_setup_dependencies.sh
67-
- name: Build
68-
run: script/ci_build.sh
63+
- name: Build and Test
64+
run: script/ci_run.sh run_tests
6965

7066

7167
build_osx:
@@ -76,10 +72,8 @@ jobs:
7672
CXX: clang++
7773
steps:
7874
- uses: actions/checkout@main
79-
- name: Setup
80-
run: sudo script/ci_setup_dependencies.sh
81-
- name: Build
82-
run: script/ci_build.sh
75+
- name: Build and Test
76+
run: script/ci_run.sh run_tests
8377

8478

8579
build_windows_msvc:
@@ -93,12 +87,9 @@ jobs:
9387
steps:
9488
- uses: actions/checkout@main
9589
- uses: ilammy/msvc-dev-cmd@v1
96-
- name: Setup
97-
shell: bash
98-
run: script/ci_setup_dependencies.sh
99-
- name: Build
90+
- name: Build and Test
10091
shell: bash
101-
run: script/ci_build.sh
92+
run: script/ci_run.sh run_tests
10293

10394

10495
formatting-check:

.github/workflows/codeql.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,13 @@ jobs:
1616
steps:
1717
- name: Checkout
1818
uses: actions/checkout@main
19-
- name: Install dependencies
20-
run: sudo script/ci_setup_dependencies.sh
2119
- name: CodeQL Initialization
2220
uses: github/codeql-action/init@v3
2321
with:
2422
languages: cpp
2523
queries: +security-and-quality
2624
- name: Build
27-
run: |
28-
cmake -S test -B build
29-
cmake --build build -j 4
25+
shell: bash
26+
run: script/ci_run.sh run_build
3027
- name: CodeQL Analysis
3128
uses: github/codeql-action/analyze@v3

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ api_search/frontend/src/Database.elm
1212
.idea
1313
cmake-build-*/
1414
CMakeUserPresets.json
15+
doctest/

script/ci_build.sh

Lines changed: 0 additions & 10 deletions
This file was deleted.

script/ci_run.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/bash
2+
3+
#
4+
# Private Impl
5+
#
6+
7+
# Get the directory of the current script (this is bash's notion of poetry)
8+
THIS_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
9+
REPO_DIR="$THIS_DIR"/..
10+
11+
# Determine the install prefix based on the OS
12+
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
13+
# Windows path handling is a never ending source of ...
14+
INSTALL_PREFIX="$USERPROFILE\\.local"
15+
INSTALL_PREFIX=$(cygpath -u "$INSTALL_PREFIX") # Make CMake happy when using git bash under windows
16+
export CMAKE_PREFIX_PATH=$INSTALL_PREFIX;$CMAKE_PREFIX_PATH # Notice the ";" instead of ":"
17+
else
18+
INSTALL_PREFIX="$HOME/.local"
19+
export CMAKE_PREFIX_PATH=$INSTALL_PREFIX:$CMAKE_PREFIX_PATH
20+
fi
21+
22+
# Function to install doctest
23+
_install_doctest() {
24+
cd "$REPO_DIR"
25+
git clone --depth=1 --branch=v2.4.11 https://github.com/doctest/doctest
26+
cd doctest && mkdir -p build && cd build
27+
cmake .. -DDOCTEST_WITH_TESTS=OFF -DDOCTEST_WITH_MAIN_IN_STATIC_LIB=OFF -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX
28+
cmake --build . --config Release --target install
29+
}
30+
31+
# Function to build the project
32+
_build_impl() {
33+
cd "$REPO_DIR"
34+
JOBS=4
35+
BUILD_TYPE=Release
36+
cmake -S test -B build -D CMAKE_BUILD_TYPE=${BUILD_TYPE}
37+
cmake --build build --config ${BUILD_TYPE} -j ${JOBS}
38+
}
39+
40+
# Function to run tests
41+
_tests_impl() {
42+
cd "$REPO_DIR/build"
43+
JOBS=4
44+
BUILD_TYPE=Release
45+
ctest -C ${BUILD_TYPE} -j ${JOBS} --output-on-failure
46+
}
47+
48+
#
49+
# API
50+
#
51+
52+
# API function to run tests
53+
run_tests() {
54+
_install_doctest
55+
_build_impl
56+
_tests_impl
57+
}
58+
59+
# API function to build the project
60+
run_build() {
61+
_install_doctest
62+
_build_impl
63+
}
64+
65+
# Main script logic
66+
case "$1" in
67+
run_build)
68+
run_build
69+
;;
70+
run_tests)
71+
run_tests
72+
;;
73+
*)
74+
echo "Usage: $0 {run_build|run_tests}"
75+
exit 1
76+
;;
77+
esac

script/ci_setup_dependencies.sh

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)