ZXC: Build Library #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "ZXC: Build Library" | |
on: | |
workflow_call: | |
inputs: | |
run-windows-builds: | |
description: "Select this option when you want to run the Windows builds." | |
type: boolean | |
required: false | |
default: false | |
run-macos-builds: | |
description: "Select this option when you want to run the MacOS builds." | |
type: boolean | |
required: false | |
default: false | |
workflow_dispatch: | |
inputs: | |
run-windows-builds: | |
description: "Select this option when you want to run the Windows builds." | |
type: boolean | |
required: false | |
default: false | |
run-macos-builds: | |
description: "Select this option when you want to run the MacOS builds." | |
type: boolean | |
required: false | |
default: false | |
defaults: | |
run: | |
shell: bash | |
permissions: | |
contents: read | |
jobs: | |
build: | |
name: Build | |
runs-on: hiero-client-sdk-linux-large | |
env: | |
HIERO_NETWORK: localhost | |
strategy: | |
matrix: | |
include: | |
- os: Linux | |
preset: linux-x64 | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0 | |
with: | |
egress-policy: audit | |
- name: Setup Control Groups | |
id: cgroup | |
run: | | |
echo "::group::Get System Configuration" | |
USR_ID="$(id -un)" | |
GRP_ID="$(id -gn)" | |
SDK_CPP_MEM_LIMIT="30064771072" | |
AGENT_MEM_LIMIT="2147483648" | |
USER_SLICE="user.slice/user-$(id -u).slice" | |
USER_SERVICE="${USER_SLICE}/user@$(id -u).service" | |
SDK_CPP_GROUP_NAME="${USER_SERVICE}/sdk-cpp-${{ github.run_id }}" | |
AGENT_GROUP_NAME="${USER_SERVICE}/agent-${{ github.run_id }}" | |
echo "::endgroup::" | |
echo "::group::Install Control Group Tools" | |
if ! command -v cgcreate >/dev/null 2>&1; then | |
sudo apt-get update | |
sudo apt-get install -y cgroup-tools | |
fi | |
echo "::endgroup::" | |
echo "::group::Create Control Groups" | |
sudo cgcreate -g cpu,memory:${USER_SLICE} -a ${USR_ID}:${GRP_ID} -t ${USR_ID}:${GRP_ID} | |
sudo cgcreate -g cpu,memory:${USER_SERVICE} -a ${USR_ID}:${GRP_ID} -t ${USR_ID}:${GRP_ID} | |
sudo cgcreate -g cpu,memory:${SDK_CPP_GROUP_NAME} -a ${USR_ID}:${GRP_ID} -t ${USR_ID}:${GRP_ID} | |
sudo cgcreate -g cpu,memory:${AGENT_GROUP_NAME} -a ${USR_ID}:${GRP_ID} -t ${USR_ID}:${GRP_ID} | |
echo "::endgroup::" | |
echo "::group::Set Control Group Limits" | |
cgset -r cpu.weight=768 ${SDK_CPP_GROUP_NAME} | |
cgset -r cpu.weight=500 ${AGENT_GROUP_NAME} | |
cgset -r memory.max=${SDK_CPP_MEM_LIMIT} ${SDK_CPP_GROUP_NAME} | |
cgset -r memory.max=${AGENT_MEM_LIMIT} ${AGENT_GROUP_NAME} | |
cgset -r memory.swap.max=${SDK_CPP_MEM_LIMIT} ${SDK_CPP_GROUP_NAME} | |
cgset -r memory.swap.max=${AGENT_MEM_LIMIT} ${AGENT_GROUP_NAME} | |
echo "::endgroup::" | |
echo "::group::Move Runner Processes to Control Groups" | |
sudo cgclassify --sticky -g cpu,memory:${AGENT_GROUP_NAME} $(pgrep 'Runner.Listener' | tr '\n' ' ') | |
sudo cgclassify -g cpu,memory:${AGENT_GROUP_NAME} $(pgrep 'Runner.Worker' | tr '\n' ' ') | |
echo "::endgroup::" | |
CG_EXEC="cgexec -g cpu,memory:${SDK_CPP_GROUP_NAME} --sticky ionice -c 2 -n 2 nice -n 19" | |
echo "exec=${CG_EXEC}" >> "${GITHUB_OUTPUT}" | |
- name: Checkout Code | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
submodules: true | |
- name: Use Node.js 22 | |
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0 | |
with: | |
node-version: 22 | |
- name: Install Linux Prerequisites | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y pkg-config libc6-dbg libgtest-dev build-essential | |
- name: Ensure Binary Cache Path Exists | |
run: mkdir -p "${{ github.workspace }}/b/vcpkg_cache" | |
- name: Install CMake & Ninja | |
uses: lukka/get-cmake@56d043d188c3612951d8755da8f4b709ec951ad6 # v3.31.6 | |
with: | |
useCloudCache: true | |
- name: Setup VCPkg | |
uses: lukka/run-vcpkg@5e0cab206a5ea620130caf672fce3e4a6b5666a1 # v11.5 | |
with: | |
binaryCachePath: ${{ github.workspace }}/b/vcpkg_cache | |
- name: Convert VCPkg to Full Clone | |
working-directory: vcpkg | |
run: git fetch --unshallow --prune | |
- name: CMake Build (Debug) | |
env: | |
VCPKG_BINARY_SOURCES: clear | |
run: | | |
echo "::group::Configure Project" | |
${{ steps.cgroup.outputs.exec }} cmake --preset ${{ matrix.preset }}-debug -DBUILD_TESTS=ON | |
echo "::endgroup::" | |
echo "::group::Build Project" | |
${{ steps.cgroup.outputs.exec }} cmake --build -j 6 --preset ${{ matrix.preset }}-debug | |
echo "::endgroup::" | |
- name: CMake Build (Release) | |
if: github.event.pull_request.merged == true | |
env: | |
VCPKG_BINARY_SOURCES: clear | |
run: | | |
echo "::group::Configure Project" | |
${{ steps.cgroup.outputs.exec }} cmake --preset ${{ matrix.preset }}-release -DBUILD_TESTS=ON | |
echo "::endgroup::" | |
echo "::group::Build Project" | |
${{ steps.cgroup.outputs.exec }} cmake --build -j 6 --preset ${{ matrix.preset }}-release | |
echo "::endgroup::" | |
- name: Install Solo | |
run: sudo npm install -g @hashgraph/[email protected] | |
- name: Install Solo Required Tools | |
run: | | |
sudo curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" | |
sudo chmod +x ./kubectl | |
sudo mv ./kubectl /usr/local/bin/kubectl | |
sudo curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.26.0/kind-linux-amd64 | |
sudo chmod +x ./kind | |
sudo mv ./kind /usr/local/bin/kind | |
- name: Start Solo | |
run: | | |
export SOLO_CLUSTER_NAME=solo-e2e | |
export SOLO_NAMESPACE=solo-e2e | |
export SOLO_CLUSTER_SETUP_NAMESPACE=fullstack-setup | |
kind create cluster -n "${SOLO_CLUSTER_NAME}" | |
solo init | |
solo node keys -i node1 --gossip-keys --tls-keys | |
solo cluster setup | |
solo network deploy -i node1 -n solo-e2e | |
solo node setup -i node1 -n solo-e2e -t v0.59.0 | |
solo node start -i node1 -n solo-e2e | |
kubectl port-forward svc/haproxy-node1-svc -n "${SOLO_NAMESPACE}" 50211:50211 & | |
solo mirror-node deploy -n "${SOLO_NAMESPACE}" --pinger true | |
kubectl port-forward $(cut -d' ' -f1 <<<$(kubectl get pods -n solo-e2e | grep mirror-rest-)) 5551:5551 -n solo-e2e & | |
kubectl port-forward $(cut -d' ' -f1 <<<$(kubectl get pods -n solo-e2e | grep mirror-web)) 8545:8545 -n solo-e2e & | |
kubectl port-forward $(cut -d' ' -f1 <<<$(kubectl get pods -n solo-e2e | grep mirror-grpc)) 5600:5600 -n solo-e2e & | |
- name: Start CTest suite (Debug) | |
run: ${{ steps.cgroup.outputs.exec }} ctest -j 6 -C Debug --test-dir build/${{ matrix.preset }}-debug --output-on-failure | |
- name: Start CTest suite (Release) | |
if: github.event.pull_request.merged == true | |
run: ${{ steps.cgroup.outputs.exec }} ctest -j 6 -C Debug --test-dir build/${{ matrix.preset }}-release --output-on-failure | |
- name: Compute Short SHA | |
id: sha | |
run: echo "short=$(echo -n "${{ github.sha }}" | cut -c1-8)" >> $GITHUB_OUTPUT | |
- name: Attach Artifact | |
if: github.event.pull_request.merged == true | |
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 | |
with: | |
name: hapi-library-${{ runner.os }}-${{ steps.sha.outputs.short }} | |
path: package/ | |
if-no-files-found: warn | |
build-windows: | |
name: Build (Windows) | |
runs-on: windows-latest | |
if: ${{ (inputs.run-windows-builds) && !cancelled() }} | |
env: | |
HEDERA_NETWORK: localhost | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0 | |
with: | |
egress-policy: audit | |
- name: Checkout Code | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 0 | |
- name: Setup-msbuild | |
uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2 | |
with: | |
msbuild-architecture: x64 | |
- name: Setup-perl | |
uses: shogo82148/actions-setup-perl@49c14f24551d2de3bf56fb107a869c3760b1875e # v1.33.0 | |
with: | |
perl-version: "5.32" | |
distribution: strawberry | |
- name: Setup-nasm | |
uses: ilammy/setup-nasm@72793074d3c8cdda771dba85f6deafe00623038b # v1.5.2 | |
- name: Enable Git long paths | |
run: git config --global core.longpaths true | |
- name: Build (Debug) | |
run: | | |
git submodule update --init | |
cmake --preset windows-x64-debug | |
cmake --build --preset windows-x64-debug -j 4 | |
- name: Build (Release) | |
run: | | |
cmake --preset windows-x64-release | |
cmake --build --preset windows-x64-release -j 4 | |
- name: Compute Short SHA | |
id: sha | |
shell: pwsh | |
run: | | |
$sha = "${{ github.sha }}" | |
$short = $sha.Substring(0, 8) | |
Add-Content -Path $env:GITHUB_OUTPUT -Value "short=$short" | |
- name: Attach Artifact | |
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 | |
with: | |
name: hapi-library-${{ runner.os }}-${{ steps.sha.outputs.short }} | |
path: package/ | |
if-no-files-found: warn | |
build-macos: | |
name: Build (MacOS) | |
runs-on: macos-latest | |
if: ${{ (inputs.run-macos-builds) && !cancelled() }} | |
env: | |
HEDERA_NETWORK: localhost | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0 | |
with: | |
egress-policy: audit | |
- name: Checkout Code | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 0 | |
- name: Install Ninja | |
uses: seanmiddleditch/gha-setup-ninja@3b1f8f94a2f8254bd26914c4ab9474d4f0015f67 # v5.0.0 | |
- name: Build (Debug) | |
run: | | |
git submodule update --init | |
cmake --preset macos-arm64-debug | |
cmake --build --preset macos-arm64-debug -j 4 | |
- name: Build (Release) | |
run: | | |
cmake --preset macos-arm64-release | |
cmake --build --preset macos-arm64-release -j 4 | |
- name: Compute Short SHA | |
id: sha | |
run: echo "short=$(echo -n "${{ github.sha }}" | cut -c1-8)" >> $GITHUB_OUTPUT | |
- name: Attach Artifact | |
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 | |
with: | |
name: hapi-library-${{ runner.os }}-${{ steps.sha.outputs.short }} | |
path: package/ | |
if-no-files-found: warn |