Skip to content

Commit 9ddbf9d

Browse files
committed
feat: add CI workflow for unit, integration and e2e tests
Signed-off-by: Maciek Malik <[email protected]>
1 parent ee7b5d2 commit 9ddbf9d

File tree

49 files changed

+379
-85
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+379
-85
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
name: "PR Formatting"
3+
on:
4+
pull_request_target:
5+
types:
6+
- assigned
7+
- unassigned
8+
- labeled
9+
- unlabeled
10+
- opened
11+
- reopened
12+
- edited
13+
- converted_to_draft
14+
- ready_for_review
15+
- review_requested
16+
- review_request_removed
17+
- locked
18+
- unlocked
19+
- synchronize
20+
21+
defaults:
22+
run:
23+
shell: bash
24+
25+
permissions:
26+
statuses: write
27+
28+
jobs:
29+
title-check:
30+
name: Title Check
31+
runs-on: hedera-agent-linux-medium
32+
steps:
33+
- name: Harden Runner
34+
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
35+
with:
36+
egress-policy: audit
37+
38+
- name: Check PR Title
39+
uses: step-security/conventional-pr-title-action@d47e8818876fa91d2010b65c4d699bb5f0d34d56 # v3.2.3
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
43+
assignee-check:
44+
name: Assignee Check
45+
runs-on: hedera-agent-linux-medium
46+
steps:
47+
- name: Harden Runner
48+
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
49+
with:
50+
egress-policy: audit
51+
52+
- name: Check Assignee
53+
if: ${{ github.event.pull_request.assignees == null || github.event.pull_request.assignees[0] == null }}
54+
run: |
55+
echo "Assignee is not set. Failing the workflow."
56+
exit 1

.github/workflows/pr-tests.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: PR Tests
2+
3+
on:
4+
pull_request:
5+
branches: [ main, "feat/75-tests-ci" ]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
unit-tests:
12+
uses: ./.github/workflows/run-unit-tests.yml
13+
14+
integration-tests:
15+
needs: [ unit-tests ]
16+
uses: ./.github/workflows/run-integration-tests.yml
17+
secrets:
18+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
19+
ACCOUNT_ID: ${{ secrets.ACCOUNT_ID }}
20+
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
21+
22+
e2e-tests:
23+
needs: [ integration-tests ]
24+
uses: ./.github/workflows/run-e2e-tests.yml
25+
secrets:
26+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
27+
ACCOUNT_ID: ${{ secrets.ACCOUNT_ID }}
28+
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Run E2E Tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
workdir:
7+
description: Working directory
8+
required: false
9+
default: 'python'
10+
type: string
11+
secrets:
12+
OPENAI_API_KEY:
13+
required: true
14+
ACCOUNT_ID:
15+
required: true
16+
PRIVATE_KEY:
17+
required: true
18+
19+
permissions:
20+
contents: read
21+
22+
jobs:
23+
e2e-tests:
24+
runs-on: hedera-agent-linux-medium
25+
env:
26+
WORKDIR: python
27+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
28+
ACCOUNT_ID: ${{ secrets.ACCOUNT_ID }}
29+
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
30+
E2E_LLM_PROVIDER: ${{ vars.E2E_LLM_PROVIDER }}
31+
steps:
32+
- name: Harden the runner (Audit all outbound calls)
33+
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
34+
with:
35+
egress-policy: audit
36+
37+
- name: Checkout repository
38+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
39+
with:
40+
fetch-depth: 0
41+
42+
- name: Set up Python
43+
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
44+
with:
45+
python-version: '3.11'
46+
47+
- name: Upgrade pip
48+
run: pip install --upgrade pip pytest
49+
50+
- name: Install Poetry
51+
uses: snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a # v1.4.1
52+
with:
53+
version: 2.2.1
54+
virtualenvs-create: true
55+
virtualenvs-in-project: true
56+
virtualenvs-path: .venv
57+
installer-parallel: true
58+
59+
- name: Load cached venv
60+
id: cached-poetry-dependencies
61+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
62+
with:
63+
path: .venv
64+
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
65+
66+
- name: Install dependencies
67+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
68+
working-directory: ${{ inputs.workdir }}
69+
run: poetry install --no-interaction --no-root
70+
71+
- name: Run E2E tests (throttled)
72+
working-directory: ${{ inputs.workdir }}
73+
env:
74+
TEST_DELAY_MS: '8000'
75+
run: |
76+
source .venv/bin/activate
77+
pytest test/e2e/
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Run Integration Tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
workdir:
7+
description: Working directory
8+
required: false
9+
default: 'python'
10+
type: string
11+
secrets:
12+
OPENAI_API_KEY:
13+
required: true
14+
ACCOUNT_ID:
15+
required: true
16+
PRIVATE_KEY:
17+
required: true
18+
outputs: {}
19+
20+
permissions:
21+
contents: read
22+
23+
jobs:
24+
integration-tests:
25+
runs-on: hedera-agent-linux-medium
26+
env:
27+
WORKDIR: python
28+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
29+
ACCOUNT_ID: ${{ secrets.ACCOUNT_ID }}
30+
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
31+
E2E_LLM_PROVIDER: ${{ vars.E2E_LLM_PROVIDER }}
32+
steps:
33+
- name: Harden the runner (Audit all outbound calls)
34+
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
35+
with:
36+
egress-policy: audit
37+
38+
- name: Checkout repository
39+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
40+
with:
41+
fetch-depth: 0
42+
43+
- name: Set up Python
44+
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
45+
with:
46+
python-version: '3.11'
47+
48+
- name: Upgrade pip
49+
run: pip install --upgrade pip pytest
50+
51+
- name: Install Poetry
52+
uses: snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a # v1.4.1
53+
with:
54+
version: 2.2.1
55+
virtualenvs-create: true
56+
virtualenvs-in-project: true
57+
virtualenvs-path: .venv
58+
installer-parallel: true
59+
60+
- name: Load cached venv
61+
id: cached-poetry-dependencies
62+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
63+
with:
64+
path: .venv
65+
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
66+
67+
- name: Install dependencies
68+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
69+
working-directory: ${{ inputs.workdir }}
70+
run: poetry install --no-interaction --no-root
71+
72+
- name: Run integration tests (throttled)
73+
working-directory: ${{ inputs.workdir }}
74+
env:
75+
TEST_DELAY_MS: '8000'
76+
run: |
77+
source .venv/bin/activate
78+
pytest test/integration/
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Run Unit Tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
workdir:
7+
description: Working directory
8+
required: false
9+
default: 'python'
10+
type: string
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
unit-tests:
17+
runs-on: hedera-agent-linux-medium
18+
env:
19+
WORKDIR: python
20+
steps:
21+
- name: Harden the runner (Audit all outbound calls)
22+
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
23+
with:
24+
egress-policy: audit
25+
26+
- name: Checkout repository
27+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
28+
with:
29+
fetch-depth: 0
30+
31+
- name: Set up Python
32+
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
33+
with:
34+
python-version: '3.11'
35+
36+
- name: Upgrade pip
37+
run: pip install --upgrade pip pytest
38+
39+
- name: Install Poetry
40+
uses: snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a # v1.4.1
41+
with:
42+
version: 2.2.1
43+
virtualenvs-create: true
44+
virtualenvs-in-project: true
45+
virtualenvs-path: .venv
46+
installer-parallel: true
47+
48+
- name: Load cached venv
49+
id: cached-poetry-dependencies
50+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
51+
with:
52+
path: .venv
53+
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
54+
55+
- name: Install dependencies
56+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
57+
working-directory: ${{ inputs.workdir }}
58+
run: poetry install --no-interaction --no-root
59+
60+
- name: Run tests
61+
working-directory: ${{ inputs.workdir }}
62+
run: |
63+
source .venv/bin/activate
64+
pytest test/unit/

python/hedera_agent_kit/plugins/core_account_plugin/approve_fungible_token_allowance.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from __future__ import annotations
22

3-
from pprint import pprint
4-
53
from hiero_sdk_python import Client, AccountAllowanceApproveTransaction
64
from hedera_agent_kit.shared.configuration import Context
75
from hedera_agent_kit.shared.hedera_utils.hedera_builder import HederaBuilder

python/hedera_agent_kit/plugins/core_account_plugin/delete_hbar_allowance.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ def delete_hbar_allowance_prompt(context: Context = {}) -> str:
4848
4949
Parameters:
5050
- {owner_account_desc}
51-
- spenderAccountId (string, required): Spender account ID
52-
- transactionMemo (string, optional): Optional memo for the transaction
51+
- spender_account_d (string, required): Spender account ID
52+
- transaction_memo (string, optional): Optional memo for the transaction
5353
{usage_instructions}
5454
5555
Example: "Delete HBAR allowance from 0.0.123 to 0.0.456". Spender account ID is 0.0.456 and the owner account ID is 0.0.789.

python/hedera_agent_kit/plugins/core_account_plugin/transfer_hbar_with_allowance.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,28 @@ def transfer_hbar_with_allowance_prompt(context: Context = {}) -> str:
4949
return f"""
5050
{context_snippet}
5151
52-
This tool will transfer HBAR using an existing allowance.
52+
This tool transfers HBAR **on behalf of another account** using a pre-approved **Allowance**.
53+
54+
Use this tool ONLY when:
55+
- The request involves spending from a "source account" that is NOT the current signer.
56+
- The user explicitly mentions "allowance", "delegated transfer", or "spending limit".
57+
- You are moving HBAR *from* a specific owner *to* a recipient using previously granted permissions.
58+
59+
Do NOT use this tool for:
60+
- Standard direct transfers of HBAR where the signer owns the HBAR.
5361
5462
Parameters:
55-
- sourceAccountId (string, required): Account ID of the HBAR owner (the allowance granter)
63+
- source_account_id (string, required): Account ID of the HBAR owner (the allowance granter)
5664
- transfers (array of objects, required): List of HBAR transfers. Each object should contain:
57-
- accountId (string): Recipient account ID
65+
- account_id (string): Recipient account ID
5866
- amount (number): Amount of HBAR to transfer
59-
- transactionMemo (string, optional): Optional memo for the transfer HBAR with allowance transaction
67+
- transaction_memo (string, optional): Optional memo for the transfer HBAR with allowance transaction
68+
{PromptGenerator.get_scheduled_transaction_params_description(context)}
69+
6070
{usage_instructions}
71+
72+
Example: "Transfer 2 HBAR from 0.0.1002 to 0.0.2002 using allowance"
73+
Example: "Spend allowance from account 0.0.1002 to send 5 HBAR to 0.0.2002"
6174
"""
6275

6376

@@ -95,7 +108,7 @@ async def transfer_hbar_with_allowance(
95108
)
96109
)
97110

98-
# Assuming HederaBuilder has a corresponding method that accepts the normalised dict
111+
# Assuming HederaBuilder has a corresponding method that accepts the normalized dict
99112
tx: TransferTransaction = HederaBuilder.transfer_hbar_with_allowance(
100113
normalised_params
101114
)

python/hedera_agent_kit/plugins/core_consensus_plugin/update_topic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def update_topic_prompt(context: Context = {}) -> str:
5858
return f"""
5959
{context_snippet}
6060
This tool will update an existing Hedera Consensus Topic. Only the fields provided will be updated.
61-
Key fields (adminKey, submitKey) must contain **Hedera-compatible public keys (as strings) or boolean (true/false)**. You can provide these in one of three ways:
61+
Key fields (admin_key, submit_key) must contain **Hedera-compatible public keys (as strings) or boolean (true/false)**. You can provide these in one of three ways:
6262
1. **Boolean true** – Set this field to use user/operator key. Injecting of the key will be handled automatically.
6363
2. **Not provided** – The field will not be updated.
6464
3. **String** – Provide a Hedera-compatible public key string to set a field explicitly.

python/hedera_agent_kit/plugins/core_evm_plugin/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
TransferERC20Tool,
1515
TRANSFER_ERC20_TOOL,
1616
)
17-
from hedera_agent_kit.shared.plugin import Plugin
1817
from hedera_agent_kit.plugins.core_evm_plugin.transfer_erc20 import (
1918
TransferERC20Tool,
2019
TRANSFER_ERC20_TOOL,
@@ -23,7 +22,6 @@
2322
CreateERC721Tool,
2423
CREATE_ERC721_TOOL,
2524
)
26-
from hedera_agent_kit.shared.plugin import Plugin
2725
from hedera_agent_kit.plugins.core_evm_plugin.transfer_erc721 import (
2826
TransferERC721Tool,
2927
TRANSFER_ERC721_TOOL,

0 commit comments

Comments
 (0)