|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +env: |
| 11 | + BUILD_TYPE: Release |
| 12 | + TEST_BUILD_TYPE: Debug |
| 13 | + NON_INTERACTIVE_TESTS: | |
| 14 | + TestApiProviderOption |
| 15 | + TestBase64 |
| 16 | + TestBruteForceLimiter |
| 17 | + TestCache |
| 18 | + TestChaCha20Poly1305 |
| 19 | + TestCounter |
| 20 | + TestCryptoKdfHkdfSha256 |
| 21 | + TestDatabase /tmp/tui-test.db |
| 22 | + TestEcdhePsk |
| 23 | + TestEd25519 |
| 24 | + TestFakeCredentialGenerator |
| 25 | + TestHttpClient |
| 26 | + TestHttpStreamResponseParser |
| 27 | + TestRegister username password |
| 28 | + TestResourceVersionManager |
| 29 | + TestRpcServer |
| 30 | + TestSecureSession |
| 31 | + TestSpake2p |
| 32 | + TestSqlite /tmp/tui-test.db |
| 33 | + TestStreamBatcher |
| 34 | + TestTevInjectionQueue |
| 35 | + TestTlv |
| 36 | + TestUtf8 |
| 37 | + TestUuid |
| 38 | + TestWorkerThread |
| 39 | +
|
| 40 | +jobs: |
| 41 | + build-and-test: |
| 42 | + runs-on: ubuntu-24.04 |
| 43 | + steps: |
| 44 | + - name: Checkout repository |
| 45 | + uses: actions/checkout@v4 |
| 46 | + |
| 47 | + - name: Install base packages |
| 48 | + run: | |
| 49 | + sudo apt-get update |
| 50 | + sudo apt-get install -y \ |
| 51 | + build-essential \ |
| 52 | + cmake \ |
| 53 | + ninja-build \ |
| 54 | + pkg-config \ |
| 55 | + curl \ |
| 56 | + git \ |
| 57 | + libcurl4-openssl-dev \ |
| 58 | + libwebsockets-dev \ |
| 59 | + libsqlite3-dev \ |
| 60 | + uuid-dev \ |
| 61 | + nlohmann-json3-dev \ |
| 62 | + libssl-dev \ |
| 63 | + valgrind |
| 64 | +
|
| 65 | + - name: Install libsodium (>=1.0.19) from source |
| 66 | + run: | |
| 67 | + set -euo pipefail |
| 68 | + curl -L https://download.libsodium.org/libsodium/releases/libsodium-1.0.20-stable.tar.gz -o /tmp/libsodium.tar.gz |
| 69 | + tar -xf /tmp/libsodium.tar.gz -C /tmp |
| 70 | + pushd /tmp/libsodium-stable |
| 71 | + ./configure --enable-shared |
| 72 | + make -j"$(nproc)" |
| 73 | + sudo make install |
| 74 | + sudo ldconfig |
| 75 | + popd |
| 76 | +
|
| 77 | + - name: Install libtev-cpp from source |
| 78 | + run: | |
| 79 | + set -euo pipefail |
| 80 | + git clone --depth=1 https://github.com/chemwolf6922/tiny-event-loop-cpp /tmp/tev-cpp |
| 81 | + cmake -S /tmp/tev-cpp -B /tmp/tev-cpp/build -DCMAKE_BUILD_TYPE="$BUILD_TYPE" -DCMAKE_POSITION_INDEPENDENT_CODE=ON |
| 82 | + cmake --build /tmp/tev-cpp/build --parallel |
| 83 | + sudo cmake --install /tmp/tev-cpp/build |
| 84 | + sudo ldconfig |
| 85 | +
|
| 86 | + - name: Install js-style-co-routine from source |
| 87 | + run: | |
| 88 | + set -euo pipefail |
| 89 | + git clone --depth=1 https://github.com/chemwolf6922/js-style-co-routine /tmp/js-style-co-routine |
| 90 | + cmake -S /tmp/js-style-co-routine -B /tmp/js-style-co-routine/build -DCMAKE_BUILD_TYPE="$BUILD_TYPE" -DCMAKE_POSITION_INDEPENDENT_CODE=ON |
| 91 | + cmake --build /tmp/js-style-co-routine/build --parallel |
| 92 | + sudo cmake --install /tmp/js-style-co-routine/build |
| 93 | + sudo ldconfig |
| 94 | +
|
| 95 | + - name: Configure main build |
| 96 | + run: cmake -S . -B build -DCMAKE_BUILD_TYPE="$BUILD_TYPE" |
| 97 | + |
| 98 | + - name: Build binaries |
| 99 | + run: cmake --build build --parallel |
| 100 | + |
| 101 | + - name: Configure tests |
| 102 | + run: cmake -S test -B test/build -DCMAKE_BUILD_TYPE="$TEST_BUILD_TYPE" |
| 103 | + |
| 104 | + - name: Build tests |
| 105 | + run: cmake --build test/build --parallel |
| 106 | + |
| 107 | + - name: Run selected non-interactive tests with valgrind |
| 108 | + if: env.NON_INTERACTIVE_TESTS != '' |
| 109 | + run: | |
| 110 | + set -euo pipefail |
| 111 | + mapfile -t tests < <(printf '%s\n' "$NON_INTERACTIVE_TESTS" | sed '/^$/d' | sed '/^#/d') |
| 112 | + pushd test/build |
| 113 | + for line in "${tests[@]}"; do |
| 114 | + set -- $line |
| 115 | + bin="$1" |
| 116 | + shift || true |
| 117 | + if [[ -z "$bin" ]]; then |
| 118 | + continue |
| 119 | + fi |
| 120 | + if [[ ! -x "$bin" ]]; then |
| 121 | + echo "Missing test binary: $PWD/$bin" >&2 |
| 122 | + exit 1 |
| 123 | + fi |
| 124 | + echo "::group::valgrind $bin $*" |
| 125 | + valgrind --leak-check=full --errors-for-leak-kinds=definite,possible --error-exitcode=42 "./$bin" "$@" |
| 126 | + echo "::endgroup::" |
| 127 | + done |
| 128 | + popd |
0 commit comments