Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI: do not require admin rights
Browse files Browse the repository at this point in the history
pthom committed Jun 12, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent f40ba97 commit 14fd722
Showing 6 changed files with 88 additions and 40 deletions.
25 changes: 8 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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_run.sh run_tests


build_clang:
@@ -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_run.sh run_tests


build_osx:
@@ -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_run.sh run_tests


build_windows_msvc:
@@ -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_run.sh run_tests


formatting-check:
7 changes: 2 additions & 5 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -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_run.sh run_build
- name: CodeQL Analysis
uses: github/codeql-action/analyze@v3
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -12,3 +12,4 @@ api_search/frontend/src/Database.elm
.idea
cmake-build-*/
CMakeUserPresets.json
doctest/
10 changes: 0 additions & 10 deletions script/ci_build.sh

This file was deleted.

77 changes: 77 additions & 0 deletions script/ci_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash

#
# 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
8 changes: 0 additions & 8 deletions script/ci_setup_dependencies.sh

This file was deleted.

0 comments on commit 14fd722

Please sign in to comment.