From 773e0e89ad7ae6e425f1c81498cb1d768f56243e Mon Sep 17 00:00:00 2001 From: Anubhav Rawal Date: Mon, 8 Dec 2025 18:55:04 +0000 Subject: [PATCH 01/18] Add support for release artifact --- .github/workflows/build-release.yml | 150 ++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 .github/workflows/build-release.yml diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml new file mode 100644 index 0000000..f09dafd --- /dev/null +++ b/.github/workflows/build-release.yml @@ -0,0 +1,150 @@ +name: Build Multi-Platform Binaries + +on: + push: + branches: + - main + tags: + - 'v*' + pull_request: + workflow_dispatch: + +permissions: + contents: write + +jobs: + build-linux: + permissions: + contents: read + strategy: + matrix: + include: + - arch: x86_64 + runner: ubuntu-24.04 + boost_version: 1.87.0 + - arch: aarch64 + runner: ubuntu-24.04-arm + boost_version: 1.87.0 + runs-on: ${{ matrix.runner }} + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Install dependencies + run: | + BOOST_VER_UNDERSCORE=$(echo ${{ matrix.boost_version }} | tr . _) + sudo apt-get update && sudo apt-get install -y build-essential cmake wget git libssl-dev zlib1g-dev + mkdir -p dependencies && cd dependencies + wget -q https://archives.boost.io/release/${{ matrix.boost_version }}/source/boost_${BOOST_VER_UNDERSCORE}.tar.gz -O boost.tar.gz + tar xzf boost.tar.gz && cd boost_${BOOST_VER_UNDERSCORE} && ./bootstrap.sh && sudo ./b2 install link=static -j$(nproc) + cd .. && wget -q https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protobuf-all-3.17.3.tar.gz -O protobuf.tar.gz + tar xzf protobuf.tar.gz && cd protobuf-3.17.3 && mkdir -p build && cd build && cmake ../cmake && make -j$(nproc) && sudo make install + + - name: Build + run: | + mkdir -p build && cd build && cmake .. && make -j$(nproc) + + - name: Upload artifact + uses: actions/upload-artifact@v5 + with: + name: localproxy-linux-${{ matrix.arch }} + path: build/bin/localproxy + + build-macos: + permissions: + contents: read + runs-on: macos-26 + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Install system dependencies + run: brew install cmake openssl@3 zlib + + - name: Install Boost + run: | + mkdir -p $HOME/dependencies + cd $HOME/dependencies + wget -q https://archives.boost.io/release/1.87.0/source/boost_1_87_0.tar.gz -O boost.tar.gz + tar xzf boost.tar.gz + cd boost_1_87_0 + ./bootstrap.sh + sudo ./b2 install link=static -j$(sysctl -n hw.ncpu) + + - name: Install Protobuf + run: | + cd $HOME/dependencies + wget -q https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protobuf-all-3.17.3.tar.gz -O protobuf.tar.gz + tar xzf protobuf.tar.gz + cd protobuf-3.17.3 + mkdir -p build + cd build + cmake ../cmake -DCMAKE_PREFIX_PATH=$(brew --prefix openssl@3) + make -j$(sysctl -n hw.ncpu) + sudo make install + + - name: Build + run: | + mkdir -p build + cd build + cmake .. -DCMAKE_PREFIX_PATH=$(brew --prefix openssl@3) + make -j$(sysctl -n hw.ncpu) + + - name: Upload artifact + uses: actions/upload-artifact@v5 + with: + name: localproxy-macos-arm64 + path: build/bin/localproxy + + build-windows: + permissions: + contents: read + strategy: + matrix: + arch: [x64, ARM64] + runs-on: windows-2025 + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Setup MSVC + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: ${{ matrix.arch }} + + - name: Install Boost dependencies + run: | + vcpkg install boost-asio:${{ matrix.arch }}-windows boost-bind:${{ matrix.arch }}-windows boost-log:${{ matrix.arch }}-windows boost-program-options:${{ matrix.arch }}-windows boost-system:${{ matrix.arch }}-windows + shell: pwsh + + - name: Install Protobuf + run: | + vcpkg install protobuf:${{ matrix.arch }}-windows + shell: pwsh + + - name: Install OpenSSL + run: | + vcpkg install openssl:${{ matrix.arch }}-windows + shell: pwsh + + - name: Install Zlib + run: | + vcpkg install zlib:${{ matrix.arch }}-windows + shell: pwsh + + - name: Build + run: | + mkdir -p build + cd build + cmake .. -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" -A ${{ matrix.arch == 'x64' && 'x64' || 'ARM64' }} + cmake --build . --config Release -j + shell: pwsh + + - name: Upload artifact + uses: actions/upload-artifact@v5 + with: + name: localproxy-windows-${{ matrix.arch }} + path: build/bin/Release/localproxy.exe From a877886ab81b4d4281e5c7691809e15bcb68889b Mon Sep 17 00:00:00 2001 From: Anubhav Rawal Date: Mon, 8 Dec 2025 22:06:16 +0000 Subject: [PATCH 02/18] Add action cache --- .github/workflows/build-release.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index f09dafd..c6e6b90 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -31,6 +31,16 @@ jobs: with: fetch-depth: 0 + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: | + /usr/local/lib/libboost_* + /usr/local/include/boost + /usr/local/lib/libprotobuf* + /usr/local/include/google + key: linux-${{ matrix.arch }}-deps-boost-${{ matrix.boost_version }}-protobuf-3.17.3 + - name: Install dependencies run: | BOOST_VER_UNDERSCORE=$(echo ${{ matrix.boost_version }} | tr . _) @@ -60,6 +70,16 @@ jobs: with: fetch-depth: 0 + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: | + /usr/local/lib/libboost_* + /usr/local/include/boost + /usr/local/lib/libprotobuf* + /usr/local/include/google + key: macos-arm64-deps-boost-1.87.0-protobuf-3.17.3 + - name: Install system dependencies run: brew install cmake openssl@3 zlib @@ -115,6 +135,14 @@ jobs: with: arch: ${{ matrix.arch }} + - name: Cache vcpkg dependencies + uses: actions/cache@v4 + with: + path: | + ${{ env.VCPKG_ROOT }}/installed + ${{ env.VCPKG_ROOT }}/packages + key: windows-${{ matrix.arch }}-vcpkg-boost-protobuf-openssl-zlib-v1 + - name: Install Boost dependencies run: | vcpkg install boost-asio:${{ matrix.arch }}-windows boost-bind:${{ matrix.arch }}-windows boost-log:${{ matrix.arch }}-windows boost-program-options:${{ matrix.arch }}-windows boost-system:${{ matrix.arch }}-windows From f1dd72a75b3499988be0c467951671aab9c98e3a Mon Sep 17 00:00:00 2001 From: Anubhav Rawal Date: Tue, 9 Dec 2025 00:19:25 +0000 Subject: [PATCH 03/18] Fix macos --- .github/workflows/build-release.yml | 76 +++++++++++++++++------------ 1 file changed, 44 insertions(+), 32 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index c6e6b90..9f8312a 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -34,13 +34,16 @@ jobs: - name: Cache dependencies uses: actions/cache@v4 with: - path: | - /usr/local/lib/libboost_* - /usr/local/include/boost - /usr/local/lib/libprotobuf* - /usr/local/include/google + path: ~/deps-cache key: linux-${{ matrix.arch }}-deps-boost-${{ matrix.boost_version }}-protobuf-3.17.3 + - name: Restore cached dependencies + run: | + if [ -d ~/deps-cache/lib ]; then + sudo cp -r ~/deps-cache/lib/* /usr/local/lib/ + sudo cp -r ~/deps-cache/include/* /usr/local/include/ + fi + - name: Install dependencies run: | BOOST_VER_UNDERSCORE=$(echo ${{ matrix.boost_version }} | tr . _) @@ -51,6 +54,14 @@ jobs: cd .. && wget -q https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protobuf-all-3.17.3.tar.gz -O protobuf.tar.gz tar xzf protobuf.tar.gz && cd protobuf-3.17.3 && mkdir -p build && cd build && cmake ../cmake && make -j$(nproc) && sudo make install + - name: Save dependencies to cache + run: | + mkdir -p ~/deps-cache/lib ~/deps-cache/include + cp -r /usr/local/lib/libboost_* ~/deps-cache/lib/ 2>/dev/null || true + cp -r /usr/local/lib/libprotobuf* ~/deps-cache/lib/ 2>/dev/null || true + cp -r /usr/local/include/boost ~/deps-cache/include/ 2>/dev/null || true + cp -r /usr/local/include/google ~/deps-cache/include/ 2>/dev/null || true + - name: Build run: | mkdir -p build && cd build && cmake .. && make -j$(nproc) @@ -73,13 +84,16 @@ jobs: - name: Cache dependencies uses: actions/cache@v4 with: - path: | - /usr/local/lib/libboost_* - /usr/local/include/boost - /usr/local/lib/libprotobuf* - /usr/local/include/google + path: ~/deps-cache key: macos-arm64-deps-boost-1.87.0-protobuf-3.17.3 + - name: Restore cached dependencies + run: | + if [ -d ~/deps-cache/lib ]; then + sudo cp -r ~/deps-cache/lib/* /usr/local/lib/ + sudo cp -r ~/deps-cache/include/* /usr/local/include/ + fi + - name: Install system dependencies run: brew install cmake openssl@3 zlib @@ -99,12 +113,21 @@ jobs: wget -q https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protobuf-all-3.17.3.tar.gz -O protobuf.tar.gz tar xzf protobuf.tar.gz cd protobuf-3.17.3 - mkdir -p build + rm -rf build + mkdir build cd build - cmake ../cmake -DCMAKE_PREFIX_PATH=$(brew --prefix openssl@3) + cmake ../cmake -DCMAKE_PREFIX_PATH=$(brew --prefix openssl@3) -DCMAKE_POLICY_VERSION_MINIMUM=3.5 make -j$(sysctl -n hw.ncpu) sudo make install + - name: Save dependencies to cache + run: | + mkdir -p ~/deps-cache/lib ~/deps-cache/include + cp -r /usr/local/lib/libboost_* ~/deps-cache/lib/ 2>/dev/null || true + cp -r /usr/local/lib/libprotobuf* ~/deps-cache/lib/ 2>/dev/null || true + cp -r /usr/local/include/boost ~/deps-cache/include/ 2>/dev/null || true + cp -r /usr/local/include/google ~/deps-cache/include/ 2>/dev/null || true + - name: Build run: | mkdir -p build @@ -143,32 +166,21 @@ jobs: ${{ env.VCPKG_ROOT }}/packages key: windows-${{ matrix.arch }}-vcpkg-boost-protobuf-openssl-zlib-v1 - - name: Install Boost dependencies + - name: Install dependencies via vcpkg run: | - vcpkg install boost-asio:${{ matrix.arch }}-windows boost-bind:${{ matrix.arch }}-windows boost-log:${{ matrix.arch }}-windows boost-program-options:${{ matrix.arch }}-windows boost-system:${{ matrix.arch }}-windows - shell: pwsh - - - name: Install Protobuf - run: | - vcpkg install protobuf:${{ matrix.arch }}-windows - shell: pwsh - - - name: Install OpenSSL - run: | - vcpkg install openssl:${{ matrix.arch }}-windows - shell: pwsh - - - name: Install Zlib - run: | - vcpkg install zlib:${{ matrix.arch }}-windows + $triplet = if ("${{ matrix.arch }}" -eq "x64") { "x64-windows" } else { "arm64-windows" } + vcpkg install boost-asio:$triplet boost-bind:$triplet boost-log:$triplet boost-program-options:$triplet boost-system:$triplet protobuf:$triplet openssl:$triplet zlib:$triplet + vcpkg integrate install shell: pwsh - name: Build run: | - mkdir -p build + $triplet = if ("${{ matrix.arch }}" -eq "x64") { "x64-windows" } else { "arm64-windows" } + $platform = if ("${{ matrix.arch }}" -eq "x64") { "x64" } else { "ARM64" } + mkdir build -Force cd build - cmake .. -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" -A ${{ matrix.arch == 'x64' && 'x64' || 'ARM64' }} - cmake --build . --config Release -j + cmake .. -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" -A $platform -DVCPKG_TARGET_TRIPLET=$triplet + cmake --build . --config Release --parallel shell: pwsh - name: Upload artifact From ef3c47723147209c42c2334c6d82b4d84179b080 Mon Sep 17 00:00:00 2001 From: Anubhav Rawal Date: Tue, 9 Dec 2025 02:17:50 +0000 Subject: [PATCH 04/18] Add support for 32 bit arm --- .github/workflows/build-release.yml | 37 +++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 9f8312a..6b69195 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -72,6 +72,43 @@ jobs: name: localproxy-linux-${{ matrix.arch }} path: build/bin/localproxy + build-linux-arm32: + permissions: + contents: read + runs-on: ubuntu-24.04-arm + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: arm + + - name: Build in ARM32 container + run: | + docker run --rm --platform linux/arm/v7 \ + -v ${{ github.workspace }}:/workspace \ + -w /workspace \ + arm32v7/ubuntu:22.04 bash -c ' + apt-get update && apt-get install -y build-essential cmake wget git libssl-dev zlib1g-dev + BOOST_VER=1.87.0 + BOOST_VER_UNDERSCORE=$(echo $BOOST_VER | tr . _) + mkdir -p dependencies && cd dependencies + wget -q https://archives.boost.io/release/$BOOST_VER/source/boost_${BOOST_VER_UNDERSCORE}.tar.gz -O boost.tar.gz + tar xzf boost.tar.gz && cd boost_${BOOST_VER_UNDERSCORE} && ./bootstrap.sh && ./b2 install link=static -j$(nproc) + cd .. && wget -q https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protobuf-all-3.17.3.tar.gz -O protobuf.tar.gz + tar xzf protobuf.tar.gz && cd protobuf-3.17.3 && mkdir -p build && cd build && cmake ../cmake && make -j$(nproc) && make install + cd /workspace && mkdir -p build && cd build && cmake .. && make -j$(nproc) + ' + + - name: Upload artifact + uses: actions/upload-artifact@v5 + with: + name: localproxy-linux-armv7 + path: build/bin/localproxy + build-macos: permissions: contents: read From d576e3b9f0b069fa6d5d2d4ee15581621d997026 Mon Sep 17 00:00:00 2001 From: Anubhav Rawal Date: Tue, 9 Dec 2025 02:23:24 +0000 Subject: [PATCH 05/18] New fixes --- .github/workflows/build-release.yml | 47 +++-------------------------- 1 file changed, 4 insertions(+), 43 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 6b69195..12e4aec 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -31,19 +31,6 @@ jobs: with: fetch-depth: 0 - - name: Cache dependencies - uses: actions/cache@v4 - with: - path: ~/deps-cache - key: linux-${{ matrix.arch }}-deps-boost-${{ matrix.boost_version }}-protobuf-3.17.3 - - - name: Restore cached dependencies - run: | - if [ -d ~/deps-cache/lib ]; then - sudo cp -r ~/deps-cache/lib/* /usr/local/lib/ - sudo cp -r ~/deps-cache/include/* /usr/local/include/ - fi - - name: Install dependencies run: | BOOST_VER_UNDERSCORE=$(echo ${{ matrix.boost_version }} | tr . _) @@ -54,14 +41,6 @@ jobs: cd .. && wget -q https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protobuf-all-3.17.3.tar.gz -O protobuf.tar.gz tar xzf protobuf.tar.gz && cd protobuf-3.17.3 && mkdir -p build && cd build && cmake ../cmake && make -j$(nproc) && sudo make install - - name: Save dependencies to cache - run: | - mkdir -p ~/deps-cache/lib ~/deps-cache/include - cp -r /usr/local/lib/libboost_* ~/deps-cache/lib/ 2>/dev/null || true - cp -r /usr/local/lib/libprotobuf* ~/deps-cache/lib/ 2>/dev/null || true - cp -r /usr/local/include/boost ~/deps-cache/include/ 2>/dev/null || true - cp -r /usr/local/include/google ~/deps-cache/include/ 2>/dev/null || true - - name: Build run: | mkdir -p build && cd build && cmake .. && make -j$(nproc) @@ -118,19 +97,6 @@ jobs: with: fetch-depth: 0 - - name: Cache dependencies - uses: actions/cache@v4 - with: - path: ~/deps-cache - key: macos-arm64-deps-boost-1.87.0-protobuf-3.17.3 - - - name: Restore cached dependencies - run: | - if [ -d ~/deps-cache/lib ]; then - sudo cp -r ~/deps-cache/lib/* /usr/local/lib/ - sudo cp -r ~/deps-cache/include/* /usr/local/include/ - fi - - name: Install system dependencies run: brew install cmake openssl@3 zlib @@ -157,14 +123,6 @@ jobs: make -j$(sysctl -n hw.ncpu) sudo make install - - name: Save dependencies to cache - run: | - mkdir -p ~/deps-cache/lib ~/deps-cache/include - cp -r /usr/local/lib/libboost_* ~/deps-cache/lib/ 2>/dev/null || true - cp -r /usr/local/lib/libprotobuf* ~/deps-cache/lib/ 2>/dev/null || true - cp -r /usr/local/include/boost ~/deps-cache/include/ 2>/dev/null || true - cp -r /usr/local/include/google ~/deps-cache/include/ 2>/dev/null || true - - name: Build run: | mkdir -p build @@ -172,6 +130,9 @@ jobs: cmake .. -DCMAKE_PREFIX_PATH=$(brew --prefix openssl@3) make -j$(sysctl -n hw.ncpu) + # Note: Binary is not code-signed. macOS users may need to run: + # xattr -d com.apple.quarantine localproxy-macos-arm64 + # Or right-click the binary and select "Open" to bypass Gatekeeper - name: Upload artifact uses: actions/upload-artifact@v5 with: @@ -216,7 +177,7 @@ jobs: $platform = if ("${{ matrix.arch }}" -eq "x64") { "x64" } else { "ARM64" } mkdir build -Force cd build - cmake .. -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" -A $platform -DVCPKG_TARGET_TRIPLET=$triplet + cmake .. -DCMAKE_TOOLCHAIN_FILE="$Env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" -A $platform -DVCPKG_TARGET_TRIPLET=$triplet cmake --build . --config Release --parallel shell: pwsh From b40db1689217b3274798013a87e3b390bc5798bb Mon Sep 17 00:00:00 2001 From: Anubhav Rawal Date: Fri, 19 Dec 2025 21:21:24 +0000 Subject: [PATCH 06/18] Add in support for ubuntu 22.04 --- .github/workflows/build-release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 12e4aec..3b9e296 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -20,10 +20,10 @@ jobs: matrix: include: - arch: x86_64 - runner: ubuntu-24.04 + runner: ubuntu-22.04 boost_version: 1.87.0 - arch: aarch64 - runner: ubuntu-24.04-arm + runner: ubuntu-22.04-arm boost_version: 1.87.0 runs-on: ${{ matrix.runner }} steps: @@ -54,7 +54,7 @@ jobs: build-linux-arm32: permissions: contents: read - runs-on: ubuntu-24.04-arm + runs-on: ubuntu-22.04-arm steps: - uses: actions/checkout@v6 with: From 6def919c8e9d843e7628c176a87a5b50ccaba6d9 Mon Sep 17 00:00:00 2001 From: Anubhav Rawal Date: Fri, 19 Dec 2025 21:24:17 +0000 Subject: [PATCH 07/18] Add in support for dynamic openssl --- .github/workflows/build-release.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 3b9e296..4fee50e 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -43,7 +43,7 @@ jobs: - name: Build run: | - mkdir -p build && cd build && cmake .. && make -j$(nproc) + mkdir -p build && cd build && cmake .. -DLINK_STATIC_OPENSSL=OFF && make -j$(nproc) - name: Upload artifact uses: actions/upload-artifact@v5 @@ -79,7 +79,7 @@ jobs: tar xzf boost.tar.gz && cd boost_${BOOST_VER_UNDERSCORE} && ./bootstrap.sh && ./b2 install link=static -j$(nproc) cd .. && wget -q https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protobuf-all-3.17.3.tar.gz -O protobuf.tar.gz tar xzf protobuf.tar.gz && cd protobuf-3.17.3 && mkdir -p build && cd build && cmake ../cmake && make -j$(nproc) && make install - cd /workspace && mkdir -p build && cd build && cmake .. && make -j$(nproc) + cd /workspace && mkdir -p build && cd build && cmake .. -DLINK_STATIC_OPENSSL=OFF && make -j$(nproc) ' - name: Upload artifact @@ -127,7 +127,7 @@ jobs: run: | mkdir -p build cd build - cmake .. -DCMAKE_PREFIX_PATH=$(brew --prefix openssl@3) + cmake .. -DCMAKE_PREFIX_PATH=$(brew --prefix openssl@3) -DLINK_STATIC_OPENSSL=OFF make -j$(sysctl -n hw.ncpu) # Note: Binary is not code-signed. macOS users may need to run: @@ -177,7 +177,7 @@ jobs: $platform = if ("${{ matrix.arch }}" -eq "x64") { "x64" } else { "ARM64" } mkdir build -Force cd build - cmake .. -DCMAKE_TOOLCHAIN_FILE="$Env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" -A $platform -DVCPKG_TARGET_TRIPLET=$triplet + cmake .. -DCMAKE_TOOLCHAIN_FILE="$Env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" -A $platform -DVCPKG_TARGET_TRIPLET=$triplet -DLINK_STATIC_OPENSSL=OFF cmake --build . --config Release --parallel shell: pwsh From 54d9ac9b629a7eaf75cffaea1c930a78b97970ae Mon Sep 17 00:00:00 2001 From: Anubhav Rawal Date: Fri, 19 Dec 2025 22:23:31 +0000 Subject: [PATCH 08/18] Add caching for arm32 --- .github/workflows/build-release.yml | 51 +++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 4fee50e..5773d45 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -4,8 +4,6 @@ on: push: branches: - main - tags: - - 'v*' pull_request: workflow_dispatch: @@ -46,7 +44,7 @@ jobs: mkdir -p build && cd build && cmake .. -DLINK_STATIC_OPENSSL=OFF && make -j$(nproc) - name: Upload artifact - uses: actions/upload-artifact@v5 + uses: actions/upload-artifact@v6 with: name: localproxy-linux-${{ matrix.arch }} path: build/bin/localproxy @@ -65,6 +63,14 @@ jobs: with: platforms: arm + - name: Cache ARM32 dependencies + uses: actions/cache@v5 + with: + path: | + dependencies + arm32-prefix + key: arm32-deps-boost-1.87.0-protobuf-3.17.3-v3 + - name: Build in ARM32 container run: | docker run --rm --platform linux/arm/v7 \ @@ -74,16 +80,35 @@ jobs: apt-get update && apt-get install -y build-essential cmake wget git libssl-dev zlib1g-dev BOOST_VER=1.87.0 BOOST_VER_UNDERSCORE=$(echo $BOOST_VER | tr . _) - mkdir -p dependencies && cd dependencies - wget -q https://archives.boost.io/release/$BOOST_VER/source/boost_${BOOST_VER_UNDERSCORE}.tar.gz -O boost.tar.gz - tar xzf boost.tar.gz && cd boost_${BOOST_VER_UNDERSCORE} && ./bootstrap.sh && ./b2 install link=static -j$(nproc) - cd .. && wget -q https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protobuf-all-3.17.3.tar.gz -O protobuf.tar.gz - tar xzf protobuf.tar.gz && cd protobuf-3.17.3 && mkdir -p build && cd build && cmake ../cmake && make -j$(nproc) && make install - cd /workspace && mkdir -p build && cd build && cmake .. -DLINK_STATIC_OPENSSL=OFF && make -j$(nproc) + PREFIX=/workspace/arm32-prefix + mkdir -p $PREFIX dependencies + + # Check if already built + if [ -f "$PREFIX/lib/libboost_system.a" ] && [ -f "$PREFIX/lib/libprotobuf.a" ]; then + echo "Using cached dependencies" + else + cd /workspace/dependencies + if [ ! -d "boost_${BOOST_VER_UNDERSCORE}" ]; then + wget -q https://archives.boost.io/release/$BOOST_VER/source/boost_${BOOST_VER_UNDERSCORE}.tar.gz -O boost.tar.gz + tar xzf boost.tar.gz + fi + cd boost_${BOOST_VER_UNDERSCORE} && ./bootstrap.sh --prefix=$PREFIX && ./b2 install link=static -j$(nproc) + + cd /workspace/dependencies + if [ ! -d "protobuf-3.17.3" ]; then + wget -q https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protobuf-all-3.17.3.tar.gz -O protobuf.tar.gz + tar xzf protobuf.tar.gz + fi + cd protobuf-3.17.3 && rm -rf build && mkdir -p build && cd build && cmake ../cmake -DCMAKE_INSTALL_PREFIX=$PREFIX && make -j$(nproc) && make install + fi + + cd /workspace && rm -rf build && mkdir -p build && cd build + cmake .. -DLINK_STATIC_OPENSSL=OFF -DCMAKE_PREFIX_PATH=$PREFIX -DProtobuf_ROOT=$PREFIX + make -j$(nproc) ' - name: Upload artifact - uses: actions/upload-artifact@v5 + uses: actions/upload-artifact@v6 with: name: localproxy-linux-armv7 path: build/bin/localproxy @@ -134,7 +159,7 @@ jobs: # xattr -d com.apple.quarantine localproxy-macos-arm64 # Or right-click the binary and select "Open" to bypass Gatekeeper - name: Upload artifact - uses: actions/upload-artifact@v5 + uses: actions/upload-artifact@v6 with: name: localproxy-macos-arm64 path: build/bin/localproxy @@ -157,7 +182,7 @@ jobs: arch: ${{ matrix.arch }} - name: Cache vcpkg dependencies - uses: actions/cache@v4 + uses: actions/cache@v5 with: path: | ${{ env.VCPKG_ROOT }}/installed @@ -182,7 +207,7 @@ jobs: shell: pwsh - name: Upload artifact - uses: actions/upload-artifact@v5 + uses: actions/upload-artifact@v6 with: name: localproxy-windows-${{ matrix.arch }} path: build/bin/Release/localproxy.exe From c07d6525287064e129ed41e2ec0831fabfc3eb56 Mon Sep 17 00:00:00 2001 From: Anubhav Rawal Date: Fri, 19 Dec 2025 23:25:22 +0000 Subject: [PATCH 09/18] Simplify building for windows and arm32 --- .github/workflows/build-release.yml | 118 +++++++++++----------------- 1 file changed, 45 insertions(+), 73 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 5773d45..51eef84 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -52,61 +52,55 @@ jobs: build-linux-arm32: permissions: contents: read - runs-on: ubuntu-22.04-arm + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v6 with: fetch-depth: 0 - + - name: Set up QEMU uses: docker/setup-qemu-action@v3 with: platforms: arm - + - name: Cache ARM32 dependencies - uses: actions/cache@v5 + id: cache-arm32 + uses: actions/cache@v4 with: - path: | - dependencies - arm32-prefix - key: arm32-deps-boost-1.87.0-protobuf-3.17.3-v3 - - - name: Build in ARM32 container + path: arm32-deps + key: arm32-deps-boost1.87-protobuf3.17.3-v1 + + - name: Build dependencies in ARM32 container + if: steps.cache-arm32.outputs.cache-hit != 'true' run: | + mkdir -p arm32-deps docker run --rm --platform linux/arm/v7 \ - -v ${{ github.workspace }}:/workspace \ - -w /workspace \ + -v ${{ github.workspace }}/arm32-deps:/deps \ arm32v7/ubuntu:22.04 bash -c ' - apt-get update && apt-get install -y build-essential cmake wget git libssl-dev zlib1g-dev - BOOST_VER=1.87.0 - BOOST_VER_UNDERSCORE=$(echo $BOOST_VER | tr . _) - PREFIX=/workspace/arm32-prefix - mkdir -p $PREFIX dependencies - - # Check if already built - if [ -f "$PREFIX/lib/libboost_system.a" ] && [ -f "$PREFIX/lib/libprotobuf.a" ]; then - echo "Using cached dependencies" - else - cd /workspace/dependencies - if [ ! -d "boost_${BOOST_VER_UNDERSCORE}" ]; then - wget -q https://archives.boost.io/release/$BOOST_VER/source/boost_${BOOST_VER_UNDERSCORE}.tar.gz -O boost.tar.gz - tar xzf boost.tar.gz - fi - cd boost_${BOOST_VER_UNDERSCORE} && ./bootstrap.sh --prefix=$PREFIX && ./b2 install link=static -j$(nproc) - - cd /workspace/dependencies - if [ ! -d "protobuf-3.17.3" ]; then - wget -q https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protobuf-all-3.17.3.tar.gz -O protobuf.tar.gz - tar xzf protobuf.tar.gz - fi - cd protobuf-3.17.3 && rm -rf build && mkdir -p build && cd build && cmake ../cmake -DCMAKE_INSTALL_PREFIX=$PREFIX && make -j$(nproc) && make install - fi - - cd /workspace && rm -rf build && mkdir -p build && cd build - cmake .. -DLINK_STATIC_OPENSSL=OFF -DCMAKE_PREFIX_PATH=$PREFIX -DProtobuf_ROOT=$PREFIX - make -j$(nproc) - ' - + apt-get update && apt-get install -y build-essential cmake wget + wget -q https://archives.boost.io/release/1.87.0/source/boost_1_87_0.tar.gz -O /tmp/boost.tar.gz + tar xzf /tmp/boost.tar.gz -C /tmp && cd /tmp/boost_1_87_0 + ./bootstrap.sh --prefix=/deps --with-libraries=system,log,thread,program_options,date_time,filesystem,chrono + ./b2 install link=static -j$(nproc) + wget -q https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protobuf-all-3.17.3.tar.gz -O /tmp/protobuf.tar.gz + tar xzf /tmp/protobuf.tar.gz -C /tmp && cd /tmp/protobuf-3.17.3 + mkdir build && cd build && cmake ../cmake -DCMAKE_INSTALL_PREFIX=/deps -Dprotobuf_BUILD_TESTS=OFF + make -j$(nproc) && make install + ' + + - name: Build localproxy in ARM32 container + run: | + docker run --rm --platform linux/arm/v7 \ + -v ${{ github.workspace }}:/src \ + -v ${{ github.workspace }}/arm32-deps:/deps \ + -w /src \ + arm32v7/ubuntu:22.04 bash -c ' + apt-get update && apt-get install -y build-essential cmake libssl-dev zlib1g-dev + mkdir -p build && cd build + cmake .. -DCMAKE_PREFIX_PATH=/deps -DLINK_STATIC_OPENSSL=OFF -DBOOST_PKG_VERSION="" -DPROTOBUF_PKG_VERSION="" + make -j$(nproc) + ' + - name: Upload artifact uses: actions/upload-artifact@v6 with: @@ -167,47 +161,25 @@ jobs: build-windows: permissions: contents: read - strategy: - matrix: - arch: [x64, ARM64] runs-on: windows-2025 steps: - uses: actions/checkout@v6 with: fetch-depth: 0 - - - name: Setup MSVC - uses: ilammy/msvc-dev-cmd@v1 - with: - arch: ${{ matrix.arch }} - - - name: Cache vcpkg dependencies - uses: actions/cache@v5 - with: - path: | - ${{ env.VCPKG_ROOT }}/installed - ${{ env.VCPKG_ROOT }}/packages - key: windows-${{ matrix.arch }}-vcpkg-boost-protobuf-openssl-zlib-v1 - - - name: Install dependencies via vcpkg + + - name: Install dependencies run: | - $triplet = if ("${{ matrix.arch }}" -eq "x64") { "x64-windows" } else { "arm64-windows" } - vcpkg install boost-asio:$triplet boost-bind:$triplet boost-log:$triplet boost-program-options:$triplet boost-system:$triplet protobuf:$triplet openssl:$triplet zlib:$triplet - vcpkg integrate install - shell: pwsh - + vcpkg install openssl:x64-windows zlib:x64-windows boost:x64-windows protobuf:x64-windows + - name: Build run: | - $triplet = if ("${{ matrix.arch }}" -eq "x64") { "x64-windows" } else { "arm64-windows" } - $platform = if ("${{ matrix.arch }}" -eq "x64") { "x64" } else { "ARM64" } - mkdir build -Force + mkdir build cd build - cmake .. -DCMAKE_TOOLCHAIN_FILE="$Env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" -A $platform -DVCPKG_TARGET_TRIPLET=$triplet -DLINK_STATIC_OPENSSL=OFF - cmake --build . --config Release --parallel - shell: pwsh - + cmake .. -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" -DLINK_STATIC_OPENSSL=OFF -DWIN32_WINNT=0x0A00 -DPROTOBUF_PKG_VERSION="" -DBOOST_PKG_VERSION="" -DCMAKE_CXX_STANDARD=17 + cmake --build . --config Release + - name: Upload artifact uses: actions/upload-artifact@v6 with: - name: localproxy-windows-${{ matrix.arch }} + name: localproxy-windows-x64 path: build/bin/Release/localproxy.exe From a35d550354eed4c6cd565390a63527077b87fd34 Mon Sep 17 00:00:00 2001 From: Anubhav Rawal Date: Sat, 20 Dec 2025 02:26:32 +0000 Subject: [PATCH 10/18] Add caching for windows --- .github/workflows/build-release.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 51eef84..f4d002c 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -65,7 +65,7 @@ jobs: - name: Cache ARM32 dependencies id: cache-arm32 - uses: actions/cache@v4 + uses: actions/cache@v5 with: path: arm32-deps key: arm32-deps-boost1.87-protobuf3.17.3-v1 @@ -162,20 +162,29 @@ jobs: permissions: contents: read runs-on: windows-2025 + env: + VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}\vcpkg-cache steps: - uses: actions/checkout@v6 with: fetch-depth: 0 + - name: Cache vcpkg packages + uses: actions/cache@v5 + with: + path: ${{ github.workspace }}\vcpkg-cache + key: vcpkg-windows-x64-v1 + - name: Install dependencies run: | + New-Item -ItemType Directory -Force -Path $env:VCPKG_DEFAULT_BINARY_CACHE vcpkg install openssl:x64-windows zlib:x64-windows boost:x64-windows protobuf:x64-windows - name: Build run: | mkdir build cd build - cmake .. -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" -DLINK_STATIC_OPENSSL=OFF -DWIN32_WINNT=0x0A00 -DPROTOBUF_PKG_VERSION="" -DBOOST_PKG_VERSION="" -DCMAKE_CXX_STANDARD=17 + cmake .. -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" -DLINK_STATIC_OPENSSL=OFF -DWIN32_WINNT=0x0A00 -DPROTOBUF_PKG_VERSION="" -DBOOST_PKG_VERSION="" -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_FLAGS="/std:c++17" cmake --build . --config Release - name: Upload artifact From 79b64778626bc25c539ee3918ccbd28f2257b32c Mon Sep 17 00:00:00 2001 From: Anubhav Rawal Date: Sat, 20 Dec 2025 02:37:26 +0000 Subject: [PATCH 11/18] Add feature to strip the binaries at the end --- .github/workflows/build-release.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index f4d002c..755bf20 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -42,6 +42,7 @@ jobs: - name: Build run: | mkdir -p build && cd build && cmake .. -DLINK_STATIC_OPENSSL=OFF && make -j$(nproc) + strip bin/localproxy - name: Upload artifact uses: actions/upload-artifact@v6 @@ -99,6 +100,7 @@ jobs: mkdir -p build && cd build cmake .. -DCMAKE_PREFIX_PATH=/deps -DLINK_STATIC_OPENSSL=OFF -DBOOST_PKG_VERSION="" -DPROTOBUF_PKG_VERSION="" make -j$(nproc) + strip bin/localproxy ' - name: Upload artifact @@ -148,6 +150,7 @@ jobs: cd build cmake .. -DCMAKE_PREFIX_PATH=$(brew --prefix openssl@3) -DLINK_STATIC_OPENSSL=OFF make -j$(sysctl -n hw.ncpu) + strip bin/localproxy # Note: Binary is not code-signed. macOS users may need to run: # xattr -d com.apple.quarantine localproxy-macos-arm64 From d5296d783e913a777b472aae6510f5f6959547b3 Mon Sep 17 00:00:00 2001 From: Anubhav Rawal Date: Sat, 20 Dec 2025 04:40:01 +0000 Subject: [PATCH 12/18] Add in improved windows build --- .github/workflows/build-release.yml | 102 +++++++++++++++++++++++----- 1 file changed, 86 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 755bf20..42feecb 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -54,6 +54,9 @@ jobs: permissions: contents: read runs-on: ubuntu-22.04 + env: + BOOST_VERSION: "1.87.0" + PROTOBUF_VERSION: "3.17.3" steps: - uses: actions/checkout@v6 with: @@ -69,22 +72,28 @@ jobs: uses: actions/cache@v5 with: path: arm32-deps - key: arm32-deps-boost1.87-protobuf3.17.3-v1 + key: arm32-deps-boost${{ env.BOOST_VERSION }}-protobuf${{ env.PROTOBUF_VERSION }}-v1 - name: Build dependencies in ARM32 container if: steps.cache-arm32.outputs.cache-hit != 'true' + env: + BOOST_VER_UNDERSCORE: ${{ env.BOOST_VERSION }} run: | + BOOST_VER_UNDERSCORE=$(echo ${{ env.BOOST_VERSION }} | tr . _) mkdir -p arm32-deps docker run --rm --platform linux/arm/v7 \ -v ${{ github.workspace }}/arm32-deps:/deps \ + -e BOOST_VERSION=${{ env.BOOST_VERSION }} \ + -e BOOST_VER_UNDERSCORE=$BOOST_VER_UNDERSCORE \ + -e PROTOBUF_VERSION=${{ env.PROTOBUF_VERSION }} \ arm32v7/ubuntu:22.04 bash -c ' apt-get update && apt-get install -y build-essential cmake wget - wget -q https://archives.boost.io/release/1.87.0/source/boost_1_87_0.tar.gz -O /tmp/boost.tar.gz - tar xzf /tmp/boost.tar.gz -C /tmp && cd /tmp/boost_1_87_0 + wget -q https://archives.boost.io/release/$BOOST_VERSION/source/boost_$BOOST_VER_UNDERSCORE.tar.gz -O /tmp/boost.tar.gz + tar xzf /tmp/boost.tar.gz -C /tmp && cd /tmp/boost_$BOOST_VER_UNDERSCORE ./bootstrap.sh --prefix=/deps --with-libraries=system,log,thread,program_options,date_time,filesystem,chrono ./b2 install link=static -j$(nproc) - wget -q https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protobuf-all-3.17.3.tar.gz -O /tmp/protobuf.tar.gz - tar xzf /tmp/protobuf.tar.gz -C /tmp && cd /tmp/protobuf-3.17.3 + wget -q https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protobuf-all-$PROTOBUF_VERSION.tar.gz -O /tmp/protobuf.tar.gz + tar xzf /tmp/protobuf.tar.gz -C /tmp && cd /tmp/protobuf-$PROTOBUF_VERSION mkdir build && cd build && cmake ../cmake -DCMAKE_INSTALL_PREFIX=/deps -Dprotobuf_BUILD_TESTS=OFF make -j$(nproc) && make install ' @@ -164,31 +173,92 @@ jobs: build-windows: permissions: contents: read - runs-on: windows-2025 + actions: write + runs-on: windows-2022 env: - VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}\vcpkg-cache + DEPS_DIR: ${{ github.workspace }}\deps + OPENSSL_VERSION: "3.0.12" + BOOST_VERSION: "1.87.0" + PROTOBUF_VERSION: "3.17.3" + ZLIB_VERSION: "1.2.13" steps: - uses: actions/checkout@v6 with: fetch-depth: 0 - - name: Cache vcpkg packages - uses: actions/cache@v5 + - name: Setup developer command prompt + uses: ilammy/msvc-dev-cmd@v1 with: - path: ${{ github.workspace }}\vcpkg-cache - key: vcpkg-windows-x64-v1 + arch: x64 - - name: Install dependencies + - name: Restore Windows dependencies cache + id: cache-windows-deps + uses: actions/cache/restore@v4 + with: + path: ${{ env.DEPS_DIR }} + key: windows-deps-openssl${{ env.OPENSSL_VERSION }}-boost${{ env.BOOST_VERSION }}-protobuf${{ env.PROTOBUF_VERSION }}-zlib${{ env.ZLIB_VERSION }}-v1 + + - name: Install OpenSSL + if: steps.cache-windows-deps.outputs.cache-hit != 'true' run: | - New-Item -ItemType Directory -Force -Path $env:VCPKG_DEFAULT_BINARY_CACHE - vcpkg install openssl:x64-windows zlib:x64-windows boost:x64-windows protobuf:x64-windows + New-Item -ItemType Directory -Force -Path $env:DEPS_DIR + Invoke-WebRequest "https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/win64/nasm-2.15.05-win64.zip" -OutFile "nasm-2.15.05-win64.zip" + Expand-Archive "nasm-2.15.05-win64.zip" -Force -DestinationPath "C:\NASM" + $env:Path += ";C:\NASM\nasm-2.15.05\" + Invoke-WebRequest "https://github.com/openssl/openssl/archive/refs/tags/openssl-$env:OPENSSL_VERSION.zip" -OutFile "openssl.zip" + Expand-Archive "openssl.zip" -Force + cd .\openssl\openssl-openssl-$env:OPENSSL_VERSION\ + perl Configure VC-WIN64A --prefix="$env:DEPS_DIR\openssl" --openssldir="$env:DEPS_DIR\openssl\ssl" + nmake + nmake install_sw + + - name: Install zlib + if: steps.cache-windows-deps.outputs.cache-hit != 'true' + run: | + git clone -b v$env:ZLIB_VERSION https://github.com/madler/zlib.git + cd zlib + mkdir build + cd build + cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$env:DEPS_DIR\zlib" ../ + nmake + nmake install + + - name: Install boost + if: steps.cache-windows-deps.outputs.cache-hit != 'true' + run: | + $boostUnderscore = $env:BOOST_VERSION -replace '\.', '_' + Invoke-WebRequest "https://archives.boost.io/release/$env:BOOST_VERSION/source/boost_$boostUnderscore.zip" -OutFile "boost.zip" + Expand-Archive "boost.zip" -Force + cd .\boost\boost_$boostUnderscore\ + .\bootstrap.bat + .\b2 toolset=msvc address-model=64 --prefix="$env:DEPS_DIR\boost" install define=_WIN32_WINNT=0x0A00 define=BOOST_WINAPI_VERSION_WIN10 link=static + + - name: Install protobuf + if: steps.cache-windows-deps.outputs.cache-hit != 'true' + run: | + Invoke-WebRequest "https://github.com/protocolbuffers/protobuf/releases/download/v$env:PROTOBUF_VERSION/protobuf-all-$env:PROTOBUF_VERSION.zip" -OutFile "protobuf.zip" + Expand-Archive "protobuf.zip" -Force + cd .\protobuf\protobuf-$env:PROTOBUF_VERSION\cmake\ + mkdir build + cd build + cmake -G "NMake Makefiles" -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -DCMAKE_INSTALL_PREFIX="$env:DEPS_DIR\protobuf" ../ + nmake + nmake install + + - name: Save Windows dependencies cache + if: always() && steps.cache-windows-deps.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + with: + path: ${{ env.DEPS_DIR }} + key: windows-deps-openssl${{ env.OPENSSL_VERSION }}-boost${{ env.BOOST_VERSION }}-protobuf${{ env.PROTOBUF_VERSION }}-zlib${{ env.ZLIB_VERSION }}-v1 - name: Build run: | mkdir build cd build - cmake .. -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" -DLINK_STATIC_OPENSSL=OFF -DWIN32_WINNT=0x0A00 -DPROTOBUF_PKG_VERSION="" -DBOOST_PKG_VERSION="" -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_FLAGS="/std:c++17" - cmake --build . --config Release + $prefixPath = "$env:DEPS_DIR\boost;$env:DEPS_DIR\protobuf;$env:DEPS_DIR\openssl;$env:DEPS_DIR\zlib" + cmake -DBUILD_TESTS=OFF -DLINK_STATIC_OPENSSL=OFF "-DBOOST_PKG_VERSION=$env:BOOST_VERSION" -DWIN32_WINNT=0x0A00 -DBoost_USE_STATIC_LIBS=ON "-DCMAKE_PREFIX_PATH=$prefixPath" -G "Visual Studio 17 2022" -A x64 .. + msbuild localproxy.vcxproj -p:Configuration=Release - name: Upload artifact uses: actions/upload-artifact@v6 From 0e82cd9ce3578c54ad4150ea0c9337cd0089885f Mon Sep 17 00:00:00 2001 From: Anubhav Rawal Date: Sat, 20 Dec 2025 19:20:35 +0000 Subject: [PATCH 13/18] Enable tests with build --- .github/workflows/build-release.yml | 75 ++++++++++++++++++++++------- 1 file changed, 58 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 42feecb..2653300 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -20,28 +20,45 @@ jobs: - arch: x86_64 runner: ubuntu-22.04 boost_version: 1.87.0 + protobuf_version: 3.17.3 - arch: aarch64 runner: ubuntu-22.04-arm boost_version: 1.87.0 + protobuf_version: 3.17.3 runs-on: ${{ matrix.runner }} steps: - uses: actions/checkout@v6 with: fetch-depth: 0 - - - name: Install dependencies + + - name: Install system dependencies + run: sudo apt-get update && sudo apt-get install -y build-essential cmake wget git libssl-dev zlib1g-dev + + - name: Install Boost run: | BOOST_VER_UNDERSCORE=$(echo ${{ matrix.boost_version }} | tr . _) - sudo apt-get update && sudo apt-get install -y build-essential cmake wget git libssl-dev zlib1g-dev mkdir -p dependencies && cd dependencies wget -q https://archives.boost.io/release/${{ matrix.boost_version }}/source/boost_${BOOST_VER_UNDERSCORE}.tar.gz -O boost.tar.gz - tar xzf boost.tar.gz && cd boost_${BOOST_VER_UNDERSCORE} && ./bootstrap.sh && sudo ./b2 install link=static -j$(nproc) - cd .. && wget -q https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protobuf-all-3.17.3.tar.gz -O protobuf.tar.gz - tar xzf protobuf.tar.gz && cd protobuf-3.17.3 && mkdir -p build && cd build && cmake ../cmake && make -j$(nproc) && sudo make install - + tar xzf boost.tar.gz && cd boost_${BOOST_VER_UNDERSCORE} + ./bootstrap.sh && sudo ./b2 install link=static -j$(nproc) + + - name: Install Protobuf + run: | + cd dependencies + wget -q https://github.com/protocolbuffers/protobuf/releases/download/v${{ matrix.protobuf_version }}/protobuf-all-${{ matrix.protobuf_version }}.tar.gz -O protobuf.tar.gz + tar xzf protobuf.tar.gz && cd protobuf-${{ matrix.protobuf_version }} + mkdir -p build && cd build && cmake ../cmake && make -j$(nproc) && sudo make install + + - name: Install Catch2 + run: | + cd dependencies + git clone --branch v3.7.0 https://github.com/catchorg/Catch2.git + cd Catch2 && mkdir build && cd build + cmake ../ && make -j$(nproc) && sudo make install + - name: Build run: | - mkdir -p build && cd build && cmake .. -DLINK_STATIC_OPENSSL=OFF && make -j$(nproc) + mkdir -p build && cd build && cmake .. -DBUILD_TESTS=ON -DLINK_STATIC_OPENSSL=OFF && make -j$(nproc) strip bin/localproxy - name: Upload artifact @@ -57,6 +74,7 @@ jobs: env: BOOST_VERSION: "1.87.0" PROTOBUF_VERSION: "3.17.3" + CATCH2_VERSION: "3.7.0" steps: - uses: actions/checkout@v6 with: @@ -72,7 +90,7 @@ jobs: uses: actions/cache@v5 with: path: arm32-deps - key: arm32-deps-boost${{ env.BOOST_VERSION }}-protobuf${{ env.PROTOBUF_VERSION }}-v1 + key: arm32-deps-boost${{ env.BOOST_VERSION }}-protobuf${{ env.PROTOBUF_VERSION }}-catch2${{ env.CATCH2_VERSION }}-v1 - name: Build dependencies in ARM32 container if: steps.cache-arm32.outputs.cache-hit != 'true' @@ -86,8 +104,9 @@ jobs: -e BOOST_VERSION=${{ env.BOOST_VERSION }} \ -e BOOST_VER_UNDERSCORE=$BOOST_VER_UNDERSCORE \ -e PROTOBUF_VERSION=${{ env.PROTOBUF_VERSION }} \ + -e CATCH2_VERSION=${{ env.CATCH2_VERSION }} \ arm32v7/ubuntu:22.04 bash -c ' - apt-get update && apt-get install -y build-essential cmake wget + apt-get update && apt-get install -y build-essential cmake wget git wget -q https://archives.boost.io/release/$BOOST_VERSION/source/boost_$BOOST_VER_UNDERSCORE.tar.gz -O /tmp/boost.tar.gz tar xzf /tmp/boost.tar.gz -C /tmp && cd /tmp/boost_$BOOST_VER_UNDERSCORE ./bootstrap.sh --prefix=/deps --with-libraries=system,log,thread,program_options,date_time,filesystem,chrono @@ -96,6 +115,9 @@ jobs: tar xzf /tmp/protobuf.tar.gz -C /tmp && cd /tmp/protobuf-$PROTOBUF_VERSION mkdir build && cd build && cmake ../cmake -DCMAKE_INSTALL_PREFIX=/deps -Dprotobuf_BUILD_TESTS=OFF make -j$(nproc) && make install + git clone --branch v$CATCH2_VERSION https://github.com/catchorg/Catch2.git /tmp/Catch2 + cd /tmp/Catch2 && mkdir build && cd build + cmake ../ -DCMAKE_INSTALL_PREFIX=/deps && make -j$(nproc) && make install ' - name: Build localproxy in ARM32 container @@ -107,7 +129,7 @@ jobs: arm32v7/ubuntu:22.04 bash -c ' apt-get update && apt-get install -y build-essential cmake libssl-dev zlib1g-dev mkdir -p build && cd build - cmake .. -DCMAKE_PREFIX_PATH=/deps -DLINK_STATIC_OPENSSL=OFF -DBOOST_PKG_VERSION="" -DPROTOBUF_PKG_VERSION="" + cmake .. -DBUILD_TESTS=ON -DCMAKE_PREFIX_PATH=/deps -DLINK_STATIC_OPENSSL=OFF -DBOOST_PKG_VERSION="" -DPROTOBUF_PKG_VERSION="" make -j$(nproc) strip bin/localproxy ' @@ -152,12 +174,19 @@ jobs: cmake ../cmake -DCMAKE_PREFIX_PATH=$(brew --prefix openssl@3) -DCMAKE_POLICY_VERSION_MINIMUM=3.5 make -j$(sysctl -n hw.ncpu) sudo make install - + + - name: Install Catch2 + run: | + cd $HOME/dependencies + git clone --branch v3.7.0 https://github.com/catchorg/Catch2.git + cd Catch2 && mkdir build && cd build + cmake ../ && make -j$(sysctl -n hw.ncpu) && sudo make install + - name: Build run: | mkdir -p build cd build - cmake .. -DCMAKE_PREFIX_PATH=$(brew --prefix openssl@3) -DLINK_STATIC_OPENSSL=OFF + cmake .. -DBUILD_TESTS=ON -DCMAKE_PREFIX_PATH=$(brew --prefix openssl@3) -DLINK_STATIC_OPENSSL=OFF make -j$(sysctl -n hw.ncpu) strip bin/localproxy @@ -181,6 +210,7 @@ jobs: BOOST_VERSION: "1.87.0" PROTOBUF_VERSION: "3.17.3" ZLIB_VERSION: "1.2.13" + CATCH2_VERSION: "3.7.0" steps: - uses: actions/checkout@v6 with: @@ -196,7 +226,7 @@ jobs: uses: actions/cache/restore@v4 with: path: ${{ env.DEPS_DIR }} - key: windows-deps-openssl${{ env.OPENSSL_VERSION }}-boost${{ env.BOOST_VERSION }}-protobuf${{ env.PROTOBUF_VERSION }}-zlib${{ env.ZLIB_VERSION }}-v1 + key: windows-deps-openssl${{ env.OPENSSL_VERSION }}-boost${{ env.BOOST_VERSION }}-protobuf${{ env.PROTOBUF_VERSION }}-zlib${{ env.ZLIB_VERSION }}-catch2${{ env.CATCH2_VERSION }}-v1 - name: Install OpenSSL if: steps.cache-windows-deps.outputs.cache-hit != 'true' @@ -245,19 +275,30 @@ jobs: nmake nmake install + - name: Install Catch2 + if: steps.cache-windows-deps.outputs.cache-hit != 'true' + run: | + git clone --branch v$env:CATCH2_VERSION https://github.com/catchorg/Catch2.git + cd Catch2 + mkdir build + cd build + cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$env:DEPS_DIR\catch2" ../ + nmake + nmake install + - name: Save Windows dependencies cache if: always() && steps.cache-windows-deps.outputs.cache-hit != 'true' uses: actions/cache/save@v4 with: path: ${{ env.DEPS_DIR }} - key: windows-deps-openssl${{ env.OPENSSL_VERSION }}-boost${{ env.BOOST_VERSION }}-protobuf${{ env.PROTOBUF_VERSION }}-zlib${{ env.ZLIB_VERSION }}-v1 + key: windows-deps-openssl${{ env.OPENSSL_VERSION }}-boost${{ env.BOOST_VERSION }}-protobuf${{ env.PROTOBUF_VERSION }}-zlib${{ env.ZLIB_VERSION }}-catch2${{ env.CATCH2_VERSION }}-v1 - name: Build run: | mkdir build cd build - $prefixPath = "$env:DEPS_DIR\boost;$env:DEPS_DIR\protobuf;$env:DEPS_DIR\openssl;$env:DEPS_DIR\zlib" - cmake -DBUILD_TESTS=OFF -DLINK_STATIC_OPENSSL=OFF "-DBOOST_PKG_VERSION=$env:BOOST_VERSION" -DWIN32_WINNT=0x0A00 -DBoost_USE_STATIC_LIBS=ON "-DCMAKE_PREFIX_PATH=$prefixPath" -G "Visual Studio 17 2022" -A x64 .. + $prefixPath = "$env:DEPS_DIR\boost;$env:DEPS_DIR\protobuf;$env:DEPS_DIR\openssl;$env:DEPS_DIR\zlib;$env:DEPS_DIR\catch2" + cmake -DBUILD_TESTS=ON -DLINK_STATIC_OPENSSL=OFF "-DBOOST_PKG_VERSION=$env:BOOST_VERSION" -DWIN32_WINNT=0x0A00 -DBoost_USE_STATIC_LIBS=ON "-DCMAKE_PREFIX_PATH=$prefixPath" -G "Visual Studio 17 2022" -A x64 .. msbuild localproxy.vcxproj -p:Configuration=Release - name: Upload artifact From a1b0dc3763ce5aab03dac6d8bdaaee2008bb3352 Mon Sep 17 00:00:00 2001 From: Anubhav Rawal Date: Sat, 20 Dec 2025 20:16:40 +0000 Subject: [PATCH 14/18] Add testing with CI --- .github/workflows/build-release.yml | 53 +++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 2653300..9b900aa 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -57,9 +57,13 @@ jobs: cmake ../ && make -j$(nproc) && sudo make install - name: Build - run: | - mkdir -p build && cd build && cmake .. -DBUILD_TESTS=ON -DLINK_STATIC_OPENSSL=OFF && make -j$(nproc) - strip bin/localproxy + run: mkdir -p build && cd build && cmake .. -DBUILD_TESTS=ON -DLINK_STATIC_OPENSSL=OFF && make -j$(nproc) + + - name: Run tests + run: ./build/bin/localproxytest + + - name: Strip binary + run: strip build/bin/localproxy - name: Upload artifact uses: actions/upload-artifact@v6 @@ -131,9 +135,26 @@ jobs: mkdir -p build && cd build cmake .. -DBUILD_TESTS=ON -DCMAKE_PREFIX_PATH=/deps -DLINK_STATIC_OPENSSL=OFF -DBOOST_PKG_VERSION="" -DPROTOBUF_PKG_VERSION="" make -j$(nproc) - strip bin/localproxy ' + - name: Run tests in ARM32 container + run: | + docker run --rm --platform linux/arm/v7 \ + -v ${{ github.workspace }}:/src \ + -v ${{ github.workspace }}/arm32-deps:/deps \ + -w /src \ + arm32v7/ubuntu:22.04 bash -c ' + apt-get update && apt-get install -y libssl-dev + ./build/bin/localproxytest + ' + + - name: Strip binary in ARM32 container + run: | + docker run --rm --platform linux/arm/v7 \ + -v ${{ github.workspace }}:/src \ + -w /src \ + arm32v7/ubuntu:22.04 strip build/bin/localproxy + - name: Upload artifact uses: actions/upload-artifact@v6 with: @@ -188,7 +209,12 @@ jobs: cd build cmake .. -DBUILD_TESTS=ON -DCMAKE_PREFIX_PATH=$(brew --prefix openssl@3) -DLINK_STATIC_OPENSSL=OFF make -j$(sysctl -n hw.ncpu) - strip bin/localproxy + + - name: Run tests + run: ./build/bin/localproxytest + + - name: Strip binary + run: strip build/bin/localproxy # Note: Binary is not code-signed. macOS users may need to run: # xattr -d com.apple.quarantine localproxy-macos-arm64 @@ -221,9 +247,9 @@ jobs: with: arch: x64 - - name: Restore Windows dependencies cache + - name: Cache Windows dependencies id: cache-windows-deps - uses: actions/cache/restore@v4 + uses: actions/cache@v5 with: path: ${{ env.DEPS_DIR }} key: windows-deps-openssl${{ env.OPENSSL_VERSION }}-boost${{ env.BOOST_VERSION }}-protobuf${{ env.PROTOBUF_VERSION }}-zlib${{ env.ZLIB_VERSION }}-catch2${{ env.CATCH2_VERSION }}-v1 @@ -286,13 +312,6 @@ jobs: nmake nmake install - - name: Save Windows dependencies cache - if: always() && steps.cache-windows-deps.outputs.cache-hit != 'true' - uses: actions/cache/save@v4 - with: - path: ${{ env.DEPS_DIR }} - key: windows-deps-openssl${{ env.OPENSSL_VERSION }}-boost${{ env.BOOST_VERSION }}-protobuf${{ env.PROTOBUF_VERSION }}-zlib${{ env.ZLIB_VERSION }}-catch2${{ env.CATCH2_VERSION }}-v1 - - name: Build run: | mkdir build @@ -301,6 +320,12 @@ jobs: cmake -DBUILD_TESTS=ON -DLINK_STATIC_OPENSSL=OFF "-DBOOST_PKG_VERSION=$env:BOOST_VERSION" -DWIN32_WINNT=0x0A00 -DBoost_USE_STATIC_LIBS=ON "-DCMAKE_PREFIX_PATH=$prefixPath" -G "Visual Studio 17 2022" -A x64 .. msbuild localproxy.vcxproj -p:Configuration=Release + - name: Build tests + run: msbuild build\localproxytest.vcxproj -p:Configuration=Release + + - name: Run tests + run: .\build\bin\Release\localproxytest.exe + - name: Upload artifact uses: actions/upload-artifact@v6 with: From d8bb363c7e87df5f75aa1957e5b995c4967e9ed9 Mon Sep 17 00:00:00 2001 From: Anubhav Rawal Date: Sat, 20 Dec 2025 21:28:46 +0000 Subject: [PATCH 15/18] Fix the race condition in tests --- .github/workflows/build-release.yml | 10 ++++++++-- test/AdapterTests.cpp | 13 ++++++------- test/TestWebsocketServer.cpp | 11 +++++++++++ test/TestWebsocketServer.h | 8 ++++++++ 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 9b900aa..3940573 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -96,6 +96,9 @@ jobs: path: arm32-deps key: arm32-deps-boost${{ env.BOOST_VERSION }}-protobuf${{ env.PROTOBUF_VERSION }}-catch2${{ env.CATCH2_VERSION }}-v1 + # GitHub Actions uses 'docker run --rm' removing containers after each step. (--rm is required for cleanup) + # Only way to reuse the container would be docker create ->start ->exec -> cleanup. + # Current approach for easy dependency caching; - name: Build dependencies in ARM32 container if: steps.cache-arm32.outputs.cache-hit != 'true' env: @@ -124,7 +127,7 @@ jobs: cmake ../ -DCMAKE_INSTALL_PREFIX=/deps && make -j$(nproc) && make install ' - - name: Build localproxy in ARM32 container + - name: Build in ARM32 container run: | docker run --rm --platform linux/arm/v7 \ -v ${{ github.workspace }}:/src \ @@ -153,7 +156,10 @@ jobs: docker run --rm --platform linux/arm/v7 \ -v ${{ github.workspace }}:/src \ -w /src \ - arm32v7/ubuntu:22.04 strip build/bin/localproxy + arm32v7/ubuntu:22.04 bash -c ' + apt-get update && apt-get install -y binutils + strip build/bin/localproxy + ' - name: Upload artifact uses: actions/upload-artifact@v6 diff --git a/test/AdapterTests.cpp b/test/AdapterTests.cpp index db48190..d301b21 100644 --- a/test/AdapterTests.cpp +++ b/test/AdapterTests.cpp @@ -213,8 +213,8 @@ TEST_CASE( "Test source mode", "[source]") { thread ws_server_thread{[&ws_server]() { ws_server.run(); } }; thread tcp_adapter_thread{[&proxy]() { proxy.run_proxy(); } }; - // Verify web socket handshake request from local proxy - this_thread::sleep_for(chrono::milliseconds(IO_PAUSE_MS)); + // Wait for web socket handshake to complete + ws_server.wait_for_handshake(); CHECK( ws_server.get_handshake_request().method() == boost::beast::http::verb::get ); CHECK( ws_server.get_handshake_request().target() == "/tunnel?local-proxy-mode=source" ); CHECK( ws_server.get_handshake_request().base()["sec-websocket-protocol"] == "aws.iot.securetunneling-3.0" ); @@ -312,8 +312,8 @@ TEST_CASE( "Test source mode with client token", "[source]") { thread ws_server_thread{[&ws_server]() { ws_server.run(); } }; thread tcp_adapter_thread{[&proxy]() { proxy.run_proxy(); } }; - // Verify web socket handshake request from local proxy - this_thread::sleep_for(chrono::milliseconds(IO_PAUSE_MS)); + // Wait for web socket handshake to complete + ws_server.wait_for_handshake(); CHECK( ws_server.get_handshake_request().method() == boost::beast::http::verb::get ); CHECK( ws_server.get_handshake_request().target() == "/tunnel?local-proxy-mode=source" ); CHECK( ws_server.get_handshake_request().base()["sec-websocket-protocol"] == "aws.iot.securetunneling-3.0" ); @@ -407,7 +407,6 @@ TEST_CASE( "Test destination mode", "[destination]") { //start web socket server thread and tcp adapter threads thread ws_server_thread{[&ws_server]() { ws_server.run(); } }; std::cout << "Test server listening on address: " << ws_address.address() << " and port: " << ws_address.port() << endl; - this_thread::sleep_for(chrono::milliseconds(IO_PAUSE_MS)); LocalproxyConfig adapter_cfg; apply_test_config(adapter_cfg, ws_address); @@ -422,9 +421,9 @@ TEST_CASE( "Test destination mode", "[destination]") { tcp_adapter_proxy proxy{ settings, adapter_cfg }; thread tcp_adapter_thread{[&proxy]() { proxy.run_proxy(); } }; - this_thread::sleep_for(chrono::milliseconds(IO_PAUSE_MS)); - // Verify web socket handshake request from local proxy + // Wait for web socket handshake to complete + ws_server.wait_for_handshake(); CHECK( ws_server.get_handshake_request().method() == boost::beast::http::verb::get ); CHECK( ws_server.get_handshake_request().target() == "/tunnel?local-proxy-mode=destination" ); CHECK( ws_server.get_handshake_request().base()["sec-websocket-protocol"] == "aws.iot.securetunneling-3.0" ); diff --git a/test/TestWebsocketServer.cpp b/test/TestWebsocketServer.cpp index 94299d2..dd8d54f 100644 --- a/test/TestWebsocketServer.cpp +++ b/test/TestWebsocketServer.cpp @@ -59,6 +59,11 @@ void TestWebsocketServer::run() throw std::runtime_error((boost::format("Accept handshake error: %1%") % ec.message()).str().c_str()); } ws.binary(true); + { + std::lock_guard lock(handshake_mutex); + handshake_complete = true; + } + handshake_cv.notify_all(); //async for reading ws.async_read_some(incoming_message_buffer, incoming_message_buffer.max_size() - incoming_message_buffer.size(), std::bind(&TestWebsocketServer::on_read_complete, this, std::ref(ws), @@ -195,6 +200,12 @@ void TestWebsocketServer::close_client(std::string const& close_reason, boost::b }); } +void TestWebsocketServer::wait_for_handshake() +{ + std::unique_lock lock(handshake_mutex); + handshake_cv.wait(lock, [this]{ return handshake_complete; }); +} + void TestWebsocketServer::expect_next_message(std::function predicate) { expect_messages.push(predicate); diff --git a/test/TestWebsocketServer.h b/test/TestWebsocketServer.h index 6e53493..1637b70 100644 --- a/test/TestWebsocketServer.h +++ b/test/TestWebsocketServer.h @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include "Message.pb.h" @@ -38,6 +40,8 @@ class TestWebsocketServer boost::beast::http::request const & get_handshake_request() { return handshake_request; } + void wait_for_handshake(); + protected: void process_input_buffer(web_socket_stream &ws, boost::beast::multi_buffer &message_buffer); void send_message(web_socket_stream &ws, message const &message); @@ -62,6 +66,10 @@ class TestWebsocketServer boost::beast::http::request handshake_request; std::queue> expect_messages; + + std::mutex handshake_mutex; + std::condition_variable handshake_cv; + bool handshake_complete{false}; }; }}}} From c6c48265279c7ebef0d06a82435a73dc139756b5 Mon Sep 17 00:00:00 2001 From: Anubhav Rawal Date: Sun, 21 Dec 2025 01:25:09 +0000 Subject: [PATCH 16/18] Add support for windows tests --- CMakeLists.txt | 2 +- test/AdapterTests.cpp | 30 ++++++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 20ae489..1c2f0e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,7 +61,7 @@ set_property(GLOBAL PROPERTY PROTOBUF_USE_STATIC_LIBS ON) #this flag doesn't ac set(PROTOBUF_PKG_VERSION "3.17.3" CACHE STRING "") find_package(Protobuf ${PROTOBUF_PKG_VERSION} REQUIRED) string(REPLACE ${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_STATIC_LIBRARY_SUFFIX} Protobuf_LITE_STATIC_LIBRARY ${Protobuf_LITE_LIBRARY}) -include_directories(${Protobuf_INCLUDE_DIRS}) +include_directories(SYSTEM ${Protobuf_INCLUDE_DIRS}) include_directories(${CMAKE_CURRENT_BINARY_DIR}) #needed to include generated protobuf headers protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${PROJECT_SOURCE_DIR}/resources/Message.proto) diff --git a/test/AdapterTests.cpp b/test/AdapterTests.cpp index d301b21..af9f73f 100644 --- a/test/AdapterTests.cpp +++ b/test/AdapterTests.cpp @@ -33,7 +33,29 @@ using aws::iot::securedtunneling::proxy_mode; int const IO_PAUSE_MS = 50; size_t const READ_BUFFER_SIZE = 63 * 1024; char const * const LOCALHOST = "127.0.0.1"; -errc_t const BOOST_EC_SOCKET_CLOSED = boost::system::errc::no_such_file_or_directory; + +/** + * Check if error code indicates socket was closed by peer. + * Different platforms return different error codes: + * - Windows: connection_reset (WSAECONNRESET) or connection_aborted (WSAECONNABORTED) + * - Unix/Linux: no_such_file_or_directory + */ +#ifdef _WIN32 +auto const EC_CONNECTION_RESET = boost::asio::error::connection_reset; +auto const EC_CONNECTION_ABORTED = boost::asio::error::connection_aborted; + +bool is_socket_closed_error(boost::system::error_code const& ec) +{ + return ec == EC_CONNECTION_RESET || ec == EC_CONNECTION_ABORTED; +} +#else +auto const EC_SOCKET_CLOSED = boost::system::errc::no_such_file_or_directory; + +bool is_socket_closed_error(boost::system::error_code const& ec) +{ + return ec.value() == EC_SOCKET_CLOSED; +} +#endif namespace aws { namespace iot { namespace securedtunneling { namespace test { @@ -270,7 +292,7 @@ TEST_CASE( "Test source mode", "[source]") { ws_server.close_client("test_closure", boost::beast::websocket::internal_error); //attempt a read on the client which should now see the socket EOF (peer closed) caused by adapter client_socket.read_some(boost::asio::buffer(reinterpret_cast(read_buffer), READ_BUFFER_SIZE), ec); - CHECK( ec.value() == BOOST_EC_SOCKET_CLOSED ); + CHECK( is_socket_closed_error(ec) ); client_socket.close(); @@ -370,7 +392,7 @@ TEST_CASE( "Test source mode with client token", "[source]") { ws_server.close_client("test_closure", boost::beast::websocket::internal_error); //attempt a read on the client which should now see the socket EOF (peer closed) caused by adapter client_socket.read_some(boost::asio::buffer(reinterpret_cast(read_buffer), READ_BUFFER_SIZE), ec); - CHECK( ec.value() == BOOST_EC_SOCKET_CLOSED ); + CHECK( is_socket_closed_error(ec) ); client_socket.close(); @@ -475,7 +497,7 @@ TEST_CASE( "Test destination mode", "[destination]") { ws_server.close_client("test_closure", boost::beast::websocket::internal_error); //need to perform write to trigger close //attempt a read on the client which should now see the socket EOF (peer closed) caused by adapter destination_socket.read_some(boost::asio::buffer(reinterpret_cast(read_buffer), READ_BUFFER_SIZE), ec); - CHECK( ec.value() == BOOST_EC_SOCKET_CLOSED ); + CHECK( is_socket_closed_error(ec) ); ws_server_thread.join(); tcp_adapter_thread.join(); From 7490d745ca31835f49bbe0f039c69743e098108a Mon Sep 17 00:00:00 2001 From: Anubhav Rawal Date: Sun, 21 Dec 2025 01:38:09 +0000 Subject: [PATCH 17/18] Add caching for all platforms --- .github/workflows/build-release.yml | 90 +++++++++++++++++++---------- 1 file changed, 59 insertions(+), 31 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 3940573..0bf8aaa 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -21,10 +21,12 @@ jobs: runner: ubuntu-22.04 boost_version: 1.87.0 protobuf_version: 3.17.3 + catch2_version: 3.7.0 - arch: aarch64 runner: ubuntu-22.04-arm boost_version: 1.87.0 protobuf_version: 3.17.3 + catch2_version: 3.7.0 runs-on: ${{ matrix.runner }} steps: - uses: actions/checkout@v6 @@ -34,30 +36,47 @@ jobs: - name: Install system dependencies run: sudo apt-get update && sudo apt-get install -y build-essential cmake wget git libssl-dev zlib1g-dev + - name: Cache dependencies + id: cache-deps + uses: actions/cache@v5 + with: + path: deps-install + key: linux-${{ matrix.arch }}-deps-boost${{ matrix.boost_version }}-protobuf${{ matrix.protobuf_version }}-catch2${{ matrix.catch2_version }}-v1 + - name: Install Boost + if: steps.cache-deps.outputs.cache-hit != 'true' run: | BOOST_VER_UNDERSCORE=$(echo ${{ matrix.boost_version }} | tr . _) mkdir -p dependencies && cd dependencies wget -q https://archives.boost.io/release/${{ matrix.boost_version }}/source/boost_${BOOST_VER_UNDERSCORE}.tar.gz -O boost.tar.gz tar xzf boost.tar.gz && cd boost_${BOOST_VER_UNDERSCORE} - ./bootstrap.sh && sudo ./b2 install link=static -j$(nproc) + ./bootstrap.sh --prefix=${{ github.workspace }}/deps-install + ./b2 install link=static -j$(nproc) - name: Install Protobuf + if: steps.cache-deps.outputs.cache-hit != 'true' run: | - cd dependencies + mkdir -p dependencies && cd dependencies wget -q https://github.com/protocolbuffers/protobuf/releases/download/v${{ matrix.protobuf_version }}/protobuf-all-${{ matrix.protobuf_version }}.tar.gz -O protobuf.tar.gz tar xzf protobuf.tar.gz && cd protobuf-${{ matrix.protobuf_version }} - mkdir -p build && cd build && cmake ../cmake && make -j$(nproc) && sudo make install + mkdir -p build && cd build + cmake ../cmake -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/deps-install -Dprotobuf_BUILD_TESTS=OFF + make -j$(nproc) && make install - name: Install Catch2 + if: steps.cache-deps.outputs.cache-hit != 'true' run: | - cd dependencies - git clone --branch v3.7.0 https://github.com/catchorg/Catch2.git + mkdir -p dependencies && cd dependencies + git clone --branch v${{ matrix.catch2_version }} https://github.com/catchorg/Catch2.git cd Catch2 && mkdir build && cd build - cmake ../ && make -j$(nproc) && sudo make install + cmake ../ -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/deps-install + make -j$(nproc) && make install - name: Build - run: mkdir -p build && cd build && cmake .. -DBUILD_TESTS=ON -DLINK_STATIC_OPENSSL=OFF && make -j$(nproc) + run: | + mkdir -p build && cd build + cmake .. -DBUILD_TESTS=ON -DLINK_STATIC_OPENSSL=OFF -DCMAKE_PREFIX_PATH=${{ github.workspace }}/deps-install -DBOOST_PKG_VERSION="" -DPROTOBUF_PKG_VERSION="" + make -j$(nproc) - name: Run tests run: ./build/bin/localproxytest @@ -171,6 +190,10 @@ jobs: permissions: contents: read runs-on: macos-26 + env: + BOOST_VERSION: "1.87.0" + PROTOBUF_VERSION: "3.17.3" + CATCH2_VERSION: "3.7.0" steps: - uses: actions/checkout@v6 with: @@ -178,42 +201,47 @@ jobs: - name: Install system dependencies run: brew install cmake openssl@3 zlib - + + - name: Cache dependencies + id: cache-deps + uses: actions/cache@v5 + with: + path: deps-install + key: macos-arm64-deps-boost${{ env.BOOST_VERSION }}-protobuf${{ env.PROTOBUF_VERSION }}-catch2${{ env.CATCH2_VERSION }}-v1 + - name: Install Boost + if: steps.cache-deps.outputs.cache-hit != 'true' run: | - mkdir -p $HOME/dependencies - cd $HOME/dependencies - wget -q https://archives.boost.io/release/1.87.0/source/boost_1_87_0.tar.gz -O boost.tar.gz - tar xzf boost.tar.gz - cd boost_1_87_0 - ./bootstrap.sh - sudo ./b2 install link=static -j$(sysctl -n hw.ncpu) + BOOST_VER_UNDERSCORE=$(echo $BOOST_VERSION | tr . _) + mkdir -p dependencies && cd dependencies + wget -q https://archives.boost.io/release/$BOOST_VERSION/source/boost_${BOOST_VER_UNDERSCORE}.tar.gz -O boost.tar.gz + tar xzf boost.tar.gz && cd boost_${BOOST_VER_UNDERSCORE} + ./bootstrap.sh --prefix=${{ github.workspace }}/deps-install + ./b2 install link=static -j$(sysctl -n hw.ncpu) - name: Install Protobuf + if: steps.cache-deps.outputs.cache-hit != 'true' run: | - cd $HOME/dependencies - wget -q https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protobuf-all-3.17.3.tar.gz -O protobuf.tar.gz - tar xzf protobuf.tar.gz - cd protobuf-3.17.3 - rm -rf build - mkdir build - cd build - cmake ../cmake -DCMAKE_PREFIX_PATH=$(brew --prefix openssl@3) -DCMAKE_POLICY_VERSION_MINIMUM=3.5 - make -j$(sysctl -n hw.ncpu) - sudo make install + mkdir -p dependencies && cd dependencies + wget -q https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protobuf-all-$PROTOBUF_VERSION.tar.gz -O protobuf.tar.gz + tar xzf protobuf.tar.gz && cd protobuf-$PROTOBUF_VERSION + mkdir -p build && cd build + cmake ../cmake -DCMAKE_PREFIX_PATH=$(brew --prefix openssl@3) -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/deps-install -Dprotobuf_BUILD_TESTS=OFF + make -j$(sysctl -n hw.ncpu) && make install - name: Install Catch2 + if: steps.cache-deps.outputs.cache-hit != 'true' run: | - cd $HOME/dependencies - git clone --branch v3.7.0 https://github.com/catchorg/Catch2.git + mkdir -p dependencies && cd dependencies + git clone --branch v$CATCH2_VERSION https://github.com/catchorg/Catch2.git cd Catch2 && mkdir build && cd build - cmake ../ && make -j$(sysctl -n hw.ncpu) && sudo make install + cmake ../ -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/deps-install + make -j$(sysctl -n hw.ncpu) && make install - name: Build run: | - mkdir -p build - cd build - cmake .. -DBUILD_TESTS=ON -DCMAKE_PREFIX_PATH=$(brew --prefix openssl@3) -DLINK_STATIC_OPENSSL=OFF + mkdir -p build && cd build + cmake .. -DBUILD_TESTS=ON -DCMAKE_PREFIX_PATH="$(brew --prefix openssl@3);${{ github.workspace }}/deps-install" -DLINK_STATIC_OPENSSL=OFF -DBOOST_PKG_VERSION="" -DPROTOBUF_PKG_VERSION="" make -j$(sysctl -n hw.ncpu) - name: Run tests From c651ed769d55bab853aade60c05a4e070fb3b248 Mon Sep 17 00:00:00 2001 From: Anubhav Rawal Date: Sun, 21 Dec 2025 02:05:40 +0000 Subject: [PATCH 18/18] Fix macos build --- .github/workflows/build-release.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 0bf8aaa..5998b51 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -68,7 +68,7 @@ jobs: run: | mkdir -p dependencies && cd dependencies git clone --branch v${{ matrix.catch2_version }} https://github.com/catchorg/Catch2.git - cd Catch2 && mkdir build && cd build + cd Catch2 && mkdir -p build && cd build cmake ../ -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/deps-install make -j$(nproc) && make install @@ -222,19 +222,21 @@ jobs: - name: Install Protobuf if: steps.cache-deps.outputs.cache-hit != 'true' run: | - mkdir -p dependencies && cd dependencies + cd dependencies wget -q https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protobuf-all-$PROTOBUF_VERSION.tar.gz -O protobuf.tar.gz - tar xzf protobuf.tar.gz && cd protobuf-$PROTOBUF_VERSION - mkdir -p build && cd build + tar xzf protobuf.tar.gz + cd protobuf-$PROTOBUF_VERSION + mkdir -p proto-build + cd proto-build cmake ../cmake -DCMAKE_PREFIX_PATH=$(brew --prefix openssl@3) -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/deps-install -Dprotobuf_BUILD_TESTS=OFF make -j$(sysctl -n hw.ncpu) && make install - name: Install Catch2 if: steps.cache-deps.outputs.cache-hit != 'true' run: | - mkdir -p dependencies && cd dependencies + cd dependencies git clone --branch v$CATCH2_VERSION https://github.com/catchorg/Catch2.git - cd Catch2 && mkdir build && cd build + cd Catch2 && mkdir -p build && cd build cmake ../ -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/deps-install make -j$(sysctl -n hw.ncpu) && make install