Skip to content

feat: Add E2E Local Node Smart Contracts Workflow #9

feat: Add E2E Local Node Smart Contracts Workflow

feat: Add E2E Local Node Smart Contracts Workflow #9

# SPDX-License-Identifier: Apache-2.0
name: "Local Node Test"
on:
push:
branches:
- main
- release/*
pull_request:
types:
- opened
- reopened
- synchronize
workflow_dispatch:
defaults:
run:
shell: bash
env:
GRADLE_EXEC: ./gradlew
permissions:
contents: read
jobs:
local-node-test:
name: "Local Node Integration Tests"
runs-on: hiero-block-node-linux-medium
steps:
- name: Harden Runner
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
with:
egress-policy: audit
- name: Checkout Block Node
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Expand Shallow Clone for Spotless
run: |
if [ -f .git/shallow ]; then
git fetch --unshallow --no-recurse-submodules
else
echo "Repository is not shallow, no need to unshallow."
fi
- name: Set up JDK 21
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
with:
distribution: "temurin"
java-version: "21.0.6"
- name: Cache Gradle packages
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build Block Node Docker Image
run: ${{ env.GRADLE_EXEC }} :block-node-server:createDockerImage
- name: Checkout Local Node
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: hiero-ledger/hiero-local-node
path: local-node
- name: Use Node.js [20]
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
with:
node-version: 20
working-directory: local-node
- name: Install Local Node Dependencies
working-directory: local-node
run: npm install
- name: Modify Docker Compose
working-directory: local-node
run: |
# Get the current version from the block-node project
BLOCK_NODE_VERSION=$(cd .. && ./gradlew :block-node-server:properties | grep "version:" | awk '{print $2}')
# Replace the block-node image in docker-compose.yml
sed -i "s|image: \"\${BLOCK_NODE_IMAGE_PREFIX}hiero-block-node:\${BLOCK_NODE_IMAGE_TAG}\"|image: \"block-node-server:${BLOCK_NODE_VERSION}\"|" docker-compose.yml
# Update the VERSION environment variable
sed -i "s|VERSION: \${BLOCK_NODE_IMAGE_TAG}|VERSION: ${BLOCK_NODE_VERSION}|" docker-compose.yml
- name: Start Local Node
working-directory: local-node
run: npm run start:block-node -- --verbose=trace
- name: Checkout Hedera Smart Contracts
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: hashgraph/hedera-smart-contracts
path: hedera-smart-contracts
- name: Setup Node.js for Smart Contracts
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
with:
node-version: 20
working-directory: hedera-smart-contracts
- name: Install Smart Contracts Dependencies
working-directory: hedera-smart-contracts
run: npm install
- name: Create .env file
working-directory: hedera-smart-contracts
run: cp local.env .env
- name: Run Smart Contract Tests
working-directory: hedera-smart-contracts
run: npx hardhat test
- name: Check Block Node Logs
if: always()
run: docker logs block-node-server
- name: Stop Local Node
if: always()
working-directory: local-node
run: npm run stop