Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 128 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

env:
BUILD_TYPE: Release
TEST_BUILD_TYPE: Debug
NON_INTERACTIVE_TESTS: |
TestApiProviderOption
TestBase64
TestBruteForceLimiter
TestCache
TestChaCha20Poly1305
TestCounter
TestCryptoKdfHkdfSha256
TestDatabase /tmp/tui-test.db
TestEcdhePsk
TestEd25519
TestFakeCredentialGenerator
TestHttpClient
TestHttpStreamResponseParser
TestRegister username password
TestResourceVersionManager
TestRpcServer
TestSecureSession
TestSpake2p
TestSqlite /tmp/tui-test.db
TestStreamBatcher
TestTevInjectionQueue
TestTlv
TestUtf8
TestUuid
TestWorkerThread

jobs:
build-and-test:
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install base packages
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
cmake \
ninja-build \
pkg-config \
curl \
git \
libcurl4-openssl-dev \
libwebsockets-dev \
libsqlite3-dev \
uuid-dev \
nlohmann-json3-dev \
libssl-dev \
valgrind

- name: Install libsodium (>=1.0.19) from source
run: |
set -euo pipefail
curl -L https://download.libsodium.org/libsodium/releases/libsodium-1.0.20-stable.tar.gz -o /tmp/libsodium.tar.gz
tar -xf /tmp/libsodium.tar.gz -C /tmp
pushd /tmp/libsodium-stable
./configure --enable-shared
make -j"$(nproc)"
sudo make install
sudo ldconfig
popd

- name: Install libtev-cpp from source
run: |
set -euo pipefail
git clone --depth=1 https://github.com/chemwolf6922/tiny-event-loop-cpp /tmp/tev-cpp
cmake -S /tmp/tev-cpp -B /tmp/tev-cpp/build -DCMAKE_BUILD_TYPE="$BUILD_TYPE" -DCMAKE_POSITION_INDEPENDENT_CODE=ON
cmake --build /tmp/tev-cpp/build --parallel
sudo cmake --install /tmp/tev-cpp/build
sudo ldconfig

- name: Install js-style-co-routine from source
run: |
set -euo pipefail
git clone --depth=1 https://github.com/chemwolf6922/js-style-co-routine /tmp/js-style-co-routine
cmake -S /tmp/js-style-co-routine -B /tmp/js-style-co-routine/build -DCMAKE_BUILD_TYPE="$BUILD_TYPE" -DCMAKE_POSITION_INDEPENDENT_CODE=ON
cmake --build /tmp/js-style-co-routine/build --parallel
sudo cmake --install /tmp/js-style-co-routine/build
sudo ldconfig

- name: Configure main build
run: cmake -S . -B build -DCMAKE_BUILD_TYPE="$BUILD_TYPE"

- name: Build binaries
run: cmake --build build --parallel

- name: Configure tests
run: cmake -S test -B test/build -DCMAKE_BUILD_TYPE="$TEST_BUILD_TYPE"

- name: Build tests
run: cmake --build test/build --parallel

- name: Run selected non-interactive tests with valgrind
if: env.NON_INTERACTIVE_TESTS != ''
run: |
set -euo pipefail
mapfile -t tests < <(printf '%s\n' "$NON_INTERACTIVE_TESTS" | sed '/^$/d' | sed '/^#/d')
pushd test/build
for line in "${tests[@]}"; do
set -- $line
bin="$1"
shift || true
if [[ -z "$bin" ]]; then
continue
fi
if [[ ! -x "$bin" ]]; then
echo "Missing test binary: $PWD/$bin" >&2
exit 1
fi
echo "::group::valgrind $bin $*"
valgrind --leak-check=full --errors-for-leak-kinds=definite,possible --error-exitcode=42 "./$bin" "$@"
echo "::endgroup::"
done
popd
2 changes: 1 addition & 1 deletion test/TestBase64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int main(int argc, char const *argv[])
std::optional<std::vector<uint8_t>> decoded;
try
{
for (int i = 0; i < 100000; i++)
for (int i = 0; i < 1000; i++)
{
data.reset();
encoded.reset();
Expand Down