Skip to content

Commit

Permalink
CI: do not require admin rights
Browse files Browse the repository at this point in the history
  • Loading branch information
pthom authored and Dobiasd committed Jun 12, 2024
1 parent 34c88e3 commit 624b97a
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 40 deletions.
25 changes: 8 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ jobs:
run: |
echo "/host_usr_local/bin" >> $GITHUB_PATH
script/ci_setup_linux.sh
- name: Setup Dependencies
run: script/ci_setup_dependencies.sh
- name: Build
run: script/ci_build.sh
- name: Build and Test
run: script/ci.sh run_tests


build_clang:
Expand Down Expand Up @@ -62,10 +60,8 @@ jobs:
apt-get install -y --no-install-recommends libunwind-${{ matrix.build_config.version }}-dev;
fi
echo "CXXFLAGS=-stdlib=libc++" >> $GITHUB_ENV
- name: Setup Dependencies
run: script/ci_setup_dependencies.sh
- name: Build
run: script/ci_build.sh
- name: Build and Test
run: script/ci.sh run_tests


build_osx:
Expand All @@ -76,10 +72,8 @@ jobs:
CXX: clang++
steps:
- uses: actions/checkout@main
- name: Setup
run: sudo script/ci_setup_dependencies.sh
- name: Build
run: script/ci_build.sh
- name: Build and Test
run: script/ci.sh run_tests


build_windows_msvc:
Expand All @@ -93,12 +87,9 @@ jobs:
steps:
- uses: actions/checkout@main
- uses: ilammy/msvc-dev-cmd@v1
- name: Setup
shell: bash
run: script/ci_setup_dependencies.sh
- name: Build
- name: Build and Test
shell: bash
run: script/ci_build.sh
run: script/ci.sh run_tests


formatting-check:
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,13 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@main
- name: Install dependencies
run: sudo script/ci_setup_dependencies.sh
- name: CodeQL Initialization
uses: github/codeql-action/init@v3
with:
languages: cpp
queries: +security-and-quality
- name: Build
run: |
cmake -S test -B build
cmake --build build -j 4
shell: bash
run: script/ci.sh run_build
- name: CodeQL Analysis
uses: github/codeql-action/analyze@v3
81 changes: 81 additions & 0 deletions script/ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash

# Central script called by the CI
# Usage:
# ci.sh {run_build|run_tests}

#
# Private Impl
#

# Get the directory of the current script (this is bash's notion of poetry)
THIS_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
REPO_DIR="$THIS_DIR"/..

# Determine the install prefix based on the OS
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
# Windows path handling is a never ending source of ...
INSTALL_PREFIX="$USERPROFILE\\.local"
INSTALL_PREFIX=$(cygpath -u "$INSTALL_PREFIX") # Make CMake happy when using git bash under windows
export CMAKE_PREFIX_PATH=$INSTALL_PREFIX;$CMAKE_PREFIX_PATH # Notice the ";" instead of ":"
else
INSTALL_PREFIX="$HOME/.local"
export CMAKE_PREFIX_PATH=$INSTALL_PREFIX:$CMAKE_PREFIX_PATH
fi

# Function to install doctest
_install_doctest() {
cd "$REPO_DIR"
git clone --depth=1 --branch=v2.4.11 https://github.com/doctest/doctest
cd doctest && mkdir -p build && cd build
cmake .. -DDOCTEST_WITH_TESTS=OFF -DDOCTEST_WITH_MAIN_IN_STATIC_LIB=OFF -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX
cmake --build . --config Release --target install
}

# Function to build the project
_build_impl() {
cd "$REPO_DIR"
JOBS=4
BUILD_TYPE=Release
cmake -S test -B build -D CMAKE_BUILD_TYPE=${BUILD_TYPE}
cmake --build build --config ${BUILD_TYPE} -j ${JOBS}
}

# Function to run tests
_tests_impl() {
cd "$REPO_DIR/build"
JOBS=4
BUILD_TYPE=Release
ctest -C ${BUILD_TYPE} -j ${JOBS} --output-on-failure
}

#
# API
#

# API function to run tests
run_tests() {
_install_doctest
_build_impl
_tests_impl
}

# API function to build the project
run_build() {
_install_doctest
_build_impl
}

# Main script logic
case "$1" in
run_build)
run_build
;;
run_tests)
run_tests
;;
*)
echo "Usage: $0 {run_build|run_tests}"
exit 1
;;
esac
10 changes: 0 additions & 10 deletions script/ci_build.sh

This file was deleted.

8 changes: 0 additions & 8 deletions script/ci_setup_dependencies.sh

This file was deleted.

0 comments on commit 624b97a

Please sign in to comment.