Skip to content

Commit

Permalink
ci: update workflows to use latitude.sh based runners (#767)
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan Klick <[email protected]>
  • Loading branch information
nathanklick authored Aug 30, 2024
1 parent 4f39b63 commit efffe10
Showing 1 changed file with 88 additions and 39 deletions.
127 changes: 88 additions & 39 deletions .github/workflows/zxc-build-library.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions:
jobs:
build:
name: Build
runs-on: [self-hosted, Linux, xlarge, ephemeral]
runs-on: client-sdk-linux-large

env:
HEDERA_NETWORK: localhost
Expand All @@ -23,6 +23,47 @@ jobs:
preset: linux-x64

steps:
- 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: Harden Runner
uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1
with:
Expand All @@ -33,35 +74,19 @@ jobs:
with:
submodules: true

- name: Run Clang-Format
uses: jidicula/clang-format-action@c74383674bf5f7c69f60ce562019c1c94bc1421a # v4.13.0
with:
clang-format-version: "17"
check-path: "src"

- name: Setup Docker Compose
run: |
sudo apt-get update
sudo apt-get install -y --allow-downgrades \
ca-certificates \
curl \
gnupg \
lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# - name: Run Clang-Format
# uses: jidicula/clang-format-action@c74383674bf5f7c69f60ce562019c1c94bc1421a # v4.13.0
# with:
# clang-format-version: "17"
# check-path: "src"

- name: Use Node.js 21
- name: Use Node.js 22
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: 21
node-version: 22

- name: Install Local Node
run: sudo npm install -g @hashgraph/hedera-local
run: sudo npm install -g @hashgraph/hedera-local@2.29.2

- name: Install Linux Prerequisites
run: |
Expand All @@ -80,41 +105,65 @@ jobs:
binaryCachePath: ${{ github.workspace }}/b/vcpkg_cache

- name: Convert VCPkg to Full Clone
run: |
cd vcpkg
git fetch --unshallow --prune
working-directory: vcpkg
run: git fetch --unshallow --prune

# - name: CMake Build (Debug)
# uses: lukka/run-cmake@2ce8982be71b8e9a3c4d5e432135035afd1e76a7 # v10.7
# env:
# VCPKG_BINARY_SOURCES: clear
# with:
# configurePreset: ${{ matrix.preset }}-debug
# buildPreset: ${{ matrix.preset }}-debug

- name: CMake Build (Debug)
uses: lukka/run-cmake@2ce8982be71b8e9a3c4d5e432135035afd1e76a7 # v10.7
env:
VCPKG_BINARY_SOURCES: clear
with:
configurePreset: ${{ matrix.preset }}-debug
buildPreset: ${{ matrix.preset }}-debug
run: |
echo "::group::Configure Project"
${{ steps.cgroup.outputs.exec }} cmake --preset ${{ matrix.preset }}-debug
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
# uses: lukka/run-cmake@2ce8982be71b8e9a3c4d5e432135035afd1e76a7 # v10.7
# env:
# VCPKG_BINARY_SOURCES: clear
# with:
# configurePreset: ${{ matrix.preset }}-release
# buildPreset: ${{ matrix.preset }}-release

- name: CMake Build (Release)
if: github.event.pull_request.merged == true
uses: lukka/run-cmake@2ce8982be71b8e9a3c4d5e432135035afd1e76a7 # v10.7
env:
VCPKG_BINARY_SOURCES: clear
with:
configurePreset: ${{ matrix.preset }}-release
buildPreset: ${{ matrix.preset }}-release
run: |
echo "::group::Configure Project"
${{ steps.cgroup.outputs.exec }} cmake --preset ${{ matrix.preset }}-release
echo "::endgroup::"
echo "::group::Build Project"
${{ steps.cgroup.outputs.exec }} cmake --build -j 6 --preset ${{ matrix.preset }}-release
echo "::endgroup::"
# - name: List Directory Structure
# if: ${{ contains(runner.os, 'Windows') && always() }}
# shell: pwsh
# run: tree /F build

- name: Start the local node
run: sudo npx @hashgraph/hedera-local start -d --network local --network-tag=0.52.0-alpha.6
run: npx hedera start --verbose=trace --detached --network-tag=0.52.3

- name: Start CTest suite (Debug)
run: ctest -C Debug --test-dir build/${{ matrix.preset }}-debug --output-on-failure
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: ctest -C Debug --test-dir build/${{ matrix.preset }}-release --output-on-failure
run: ${{ steps.cgroup.outputs.exec }} ctest -j 6 -C Debug --test-dir build/${{ matrix.preset }}-release --output-on-failure

- name: Stop the local node
run: sudo npx @hashgraph/hedera-local stop
Expand Down

0 comments on commit efffe10

Please sign in to comment.