Skip to content

Commit 624b97a

Browse files
pthomDobiasd
authored andcommitted
CI: do not require admin rights
1 parent 34c88e3 commit 624b97a

File tree

5 files changed

+91
-40
lines changed

5 files changed

+91
-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.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.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.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.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.sh run_build
3027
- name: CodeQL Analysis
3128
uses: github/codeql-action/analyze@v3

script/ci.sh

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

script/ci_build.sh

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

script/ci_setup_dependencies.sh

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

0 commit comments

Comments
 (0)