Skip to content

Commit

Permalink
update: build workflow
Browse files Browse the repository at this point in the history
Signed-off-by: svetoslav-nikol0v <[email protected]>
  • Loading branch information
svetoslav-nikol0v committed Jun 6, 2024
1 parent 20fd9f0 commit 495d2ed
Showing 1 changed file with 54 additions and 10 deletions.
64 changes: 54 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ defaults:
permissions:
contents: read

env:
CG_EXEC: export R_UID=$(id -u); CGROUP_LOGLEVEL=DEBUG cgexec -g cpu,memory:user.slice/user-${R_UID}.slice/user@${R_UID}.service/e2e-${{ github.run_id }} --sticky ionice -c 2 -n 2 nice -n 19

jobs:
build:
name: Build using Node ${{ matrix.node }}
Expand All @@ -44,7 +47,7 @@ jobs:
version: 3.35.1

- name: Install PNPM
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
version: 8.15.4

Expand All @@ -65,6 +68,47 @@ jobs:
node: [ "16" ]

steps:
- name: Setup Control Groups
run: |
echo "::group::Get System Configuration"
USR_ID="$(id -un)"
GRP_ID="$(id -gn)"
E2E_MEM_LIMIT="30064771072"
AGENT_MEM_LIMIT="2147483648"
USER_SLICE="user.slice/user-$(id -u).slice"
USER_SERVICE="${USER_SLICE}/user@$(id -u).service"
E2E_GROUP_NAME="${USER_SERVICE}/e2e-${{ 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:${E2E_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 ${E2E_GROUP_NAME}
cgset -r cpu.weight=500 ${AGENT_GROUP_NAME}
cgset -r memory.max=${E2E_MEM_LIMIT} ${E2E_GROUP_NAME}
cgset -r memory.max=${AGENT_MEM_LIMIT} ${AGENT_GROUP_NAME}
cgset -r memory.swap.max=${E2E_MEM_LIMIT} ${E2E_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::"
- name: Harden Runner
uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0
with:
Expand All @@ -89,7 +133,7 @@ jobs:
cat .env
- name: Install PNPM
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
version: 8.15.4

Expand All @@ -112,38 +156,38 @@ jobs:
id: start-local-node
if: ${{ steps.build-sdk.conclusion == 'success' && !cancelled() && always() }}
run: |
npx @hashgraph/hedera-local start -d --network-tag=0.49.7 --balance=100000
${{ env.CG_EXEC }} npx @hashgraph/hedera-local start -d --network-tag=0.49.7 --balance=100000
# Wait for the network to fully start
sleep 30
- name: Run Hedera SDK Integration Tests Codecov
if: ${{ steps.build-sdk.conclusion == 'success' && steps.start-local-node.conclusion == 'success' && !cancelled() && always() }}
run: task test:integration:codecov
run: ${{ env.CG_EXEC }} task test:integration:codecov

- name: Build @hashgraph/cryptography
working-directory: packages/cryptography
if: ${{ steps.build-sdk.conclusion == 'success' && steps.start-local-node.conclusion == 'success' && !cancelled() && always() }}
run: task build
run: ${{ env.CG_EXEC }} task build

- name: Unit Test @hashgraph/cryptography
working-directory: packages/cryptography
if: ${{ steps.build-sdk.conclusion == 'success' && steps.start-local-node.conclusion == 'success' && !cancelled() && always() }}
run: task test:unit
run: ${{ env.CG_EXEC }} task test:unit

- name: Codecov @hashgraph/cryptography
working-directory: packages/cryptography
if: ${{ steps.build-sdk.conclusion == 'success' && steps.start-local-node.conclusion == 'success' && !cancelled() && always() }}
run: task test:unit:codecov
run: ${{ env.CG_EXEC }} task test:unit:codecov

- name: Unit Test @hashgraph/sdk
if: ${{ steps.build-sdk.conclusion == 'success' && steps.start-local-node.conclusion == 'success' && steps.playwright-deps.conclusion == 'success' && !cancelled() && always() }}
run: task test:unit
run: ${{ env.CG_EXEC }} task test:unit

- name: Codecov @hashgraph/sdk
if: ${{ steps.build-sdk.conclusion == 'success' && steps.start-local-node.conclusion == 'success' && !cancelled() && always() }}
run: task test:unit:codecov
run: ${{ env.CG_EXEC }} task test:unit:codecov

- name: Stop the local node
id: stop-local-node
if: ${{ steps.start-local-node.conclusion == 'success' && !cancelled() && always() }}
run: npx @hashgraph/hedera-local stop
run: ${{ env.CG_EXEC }} npx @hashgraph/hedera-local stop

0 comments on commit 495d2ed

Please sign in to comment.