-
Notifications
You must be signed in to change notification settings - Fork 30
151 lines (150 loc) · 7.06 KB
/
e2e_tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: e2e tests
on:
pull_request:
jobs:
e2e-tests:
runs-on: ubuntu-latest
env:
NETWORK: "localhost"
ORACLE_ADDRESS: "0x5FbDB2315678afecb367f032d93F642f64180aa3"
TEST_CONTRACT_ADDRESS: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e"
IMAGE_URL: "https://picsum.photos/200/300"
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache-dependency-path: contracts/package-lock.json
- name: "Install Dependencies"
id: install
run: cd contracts && npm ci
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Cache pip
uses: actions/cache@v4
with:
path: |
~/.cache/pip
!~/.cache/pip/log
key: ${{ runner.os }}-pip-${{ hashFiles('oracles/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Python Dependencies
run: pip install -r oracles/requirements.txt
- name: Run Hardhat Node
run: cd contracts && npx hardhat node &
- name: "Deploy Contracts"
run:
cd contracts && npm run deployAll:localhost
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "Whitelist the address"
run:
cd contracts && npx hardhat whitelist --oracle-address ${{ env.ORACLE_ADDRESS }} --whitelist-address 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --network localhost
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "Deploy Test Contract"
run:
cd contracts && npm run deployTest:localhost
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
ORACLE_ADDRESS: ${{ env.ORACLE_ADDRESS }}
- name: Run Python Oracle
run: |
cd oracles && python oracle.py > oracle_output.txt 2>&1 &
echo $! > python_oracle.pid
env:
CHAIN_ID: 1337
WEB3_RPC_URL: "http://127.0.0.1:8545/"
ORACLE_ADDRESS: ${{ env.ORACLE_ADDRESS }}
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
OPEN_AI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
SERPER_API_KEY: ${{ secrets.SERPER_API_KEY }}
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
PINATA_GATEWAY_TOKEN: ${{ secrets.PINATA_GATEWAY_TOKEN }}
PINATA_API_JWT: ${{ secrets.PINATA_API_JWT }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
- name: "OpenAI gpt-4-turbo-preview"
run:
cd contracts && npx hardhat openai --contract-address ${{ env.TEST_CONTRACT_ADDRESS }} --model gpt-4-turbo-preview --message "Who is the president of USA?" --network ${{ env.NETWORK }}
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "OpenAI gpt-3.5-turbo-1106"
run:
cd contracts && npx hardhat openai --contract-address ${{ env.TEST_CONTRACT_ADDRESS }} --model gpt-3.5-turbo-1106 --message "Who is the president of USA?" --network ${{ env.NETWORK }}
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "OpenAI gpt-4-turbo vision"
run:
cd contracts && npx hardhat openai_vision --contract-address ${{ env.TEST_CONTRACT_ADDRESS }} --model gpt-4-turbo --message "What is on this image?" --image-url ${{env.IMAGE_URL}} --network ${{ env.NETWORK }}
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "OpenAI gpt-4o"
run:
cd contracts && npx hardhat openai_vision --contract-address ${{ env.TEST_CONTRACT_ADDRESS }} --model gpt-4o --message "What is on this image?" --image-url ${{env.IMAGE_URL}} --network ${{ env.NETWORK }}
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "Groq llama3-8b-8192"
run:
cd contracts && npx hardhat groq --contract-address ${{ env.TEST_CONTRACT_ADDRESS }} --model llama3-8b-8192 --message "Who is the president of USA?" --network ${{ env.NETWORK }}
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "Groq llama3-70b-8192"
run:
cd contracts && npx hardhat groq --contract-address ${{ env.TEST_CONTRACT_ADDRESS }} --model llama3-70b-8192 --message "Who is the president of USA?" --network ${{ env.NETWORK }}
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "Groq mixtral-8x7b-32768"
run:
cd contracts && npx hardhat groq --contract-address ${{ env.TEST_CONTRACT_ADDRESS }} --model mixtral-8x7b-32768 --message "Who is the president of USA?" --network ${{ env.NETWORK }}
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "Groq gemma-7b-it"
run:
cd contracts && npx hardhat groq --contract-address ${{ env.TEST_CONTRACT_ADDRESS }} --model gemma-7b-it --message "Who is the president of USA?" --network ${{ env.NETWORK }}
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "Anthropic claude-3-5-sonnet-20240620"
run:
cd contracts && npx hardhat llm --contract-address ${{ env.TEST_CONTRACT_ADDRESS }} --model claude-3-5-sonnet-20240620 --message "Who is the president of USA?" --network ${{ env.NETWORK }}
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "OpenAI Image Generation"
run:
cd contracts && npx hardhat image_generation --contract-address ${{ env.TEST_CONTRACT_ADDRESS }} --query "Red rose" --network ${{ env.NETWORK }}
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "Tool Web search"
run:
cd contracts && npx hardhat web_search --contract-address ${{ env.TEST_CONTRACT_ADDRESS }} --query "Capital of Germany" --network ${{ env.NETWORK }}
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "Tool Code interpreter"
run:
cd contracts && npx hardhat code_interpreter --contract-address ${{ env.TEST_CONTRACT_ADDRESS }} --query "print(2+2)" --network ${{ env.NETWORK }}
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "RAG Add knowledge base"
run:
cd contracts && npx hardhat add_knowledge_base --oracle-address ${{ env.ORACLE_ADDRESS }} --cid QmdCgbMawRVE6Kc1joZmhgDo2mSZFgRgWvBCqUvJV9JwkF --network ${{ env.NETWORK }}
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: "RAG Query knowledge base"
run:
cd contracts && npx hardhat query_knowledge_base --contract-address ${{ env.TEST_CONTRACT_ADDRESS }} --cid QmdCgbMawRVE6Kc1joZmhgDo2mSZFgRgWvBCqUvJV9JwkF --query "What is the oracle smart contract address?" --network ${{ env.NETWORK }}
env:
PRIVATE_KEY_LOCALHOST: ${{ secrets.PRIVATE_KEY }}
- name: Display Oracle Output
if: always() # Ensures this step runs even if a previous step fails
run: cat oracles/oracle_output.txt
- name: Wait for Metrics File Creation
run: sleep 10
- name: Check Metrics File
run: test -f oracles/metrics.json && echo "metrics.json exists."
- name: Validate Metrics Content
run: cd oracles && python tests/e2e/check_metrics.py