-
Notifications
You must be signed in to change notification settings - Fork 112
124 lines (106 loc) · 4.49 KB
/
rosetta.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
name: Rosetta API
on:
schedule:
- cron: "0 1 * * *" # Daily at 1:00 AM
push:
branches:
- "main"
tags:
- "v*"
defaults:
run:
shell: bash
working-directory: ./hedera-mirror-rosetta
permissions:
contents: read
env:
MODULE: hedera-mirror-rosetta
NETWORK: previewnet
jobs:
validate:
runs-on: mirror-node-linux-large
timeout-minutes: 30
env:
ROSETTA_CLI_VERSION: v0.10.3
steps:
- name: Harden Runner
uses: step-security/harden-runner@c95a14d0e5bab51a9f56296a4eb0e416910cd350 # v2.10.3
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Node
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: 21
- name: Set Importer StartDate
run: |
# Set start date to 60 seconds before the first block timestamp in the network
url="https://${NETWORK}.mirrornode.hedera.com/api/v1/blocks?limit=1&order=asc"
firstTimestamp=$(curl -s "${url}" | jq -r .blocks[0].timestamp.from)
if [[ -z "${firstTimestamp}" ]]; then
echo "Unable to get first block timestamp"
exit 1
fi
startSecs=$((${firstTimestamp%.*}-60))
startDate=$(date --date="@${startSecs}" -Iseconds -u | grep -o -e '^[0-9T:-]\+')
startDate="${startDate}Z"
echo "STARTDATE=${startDate}" >> $GITHUB_ENV
echo "Set importer startDate to ${startDate}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
with:
driver-opts: network=host
buildkitd-config-inline: |
[registry."docker.io"]
mirrors = ["https://hub.mirror.docker.lat.ope.eng.hashgraph.io"]
- name: Build Image
uses: docker/build-push-action@b32b51a8eda65d6793cd0494a773d4f6bcef32dc # v6.11.0
with:
build-args: GIT_REF=${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
context: ./hedera-mirror-rosetta/container
load: true
provenance: false
push: false
tags: "${{ env.MODULE }}:${{ github.sha }}"
- name: Importer Configuration
run: echo "${{ secrets.ROSETTA_IMPORTER_CONFIG }}" | base64 -d > ${{ github.workspace }}/application_importer.yml
- name: Rosetta Configuration
run: echo "${{ secrets.ROSETTA_ROSETTA_CONFIG }}" | base64 -d > ${{ github.workspace }}/application_rosetta.yml
- name: Run Mirror Node in Online Mode
run: |
ONLINE_CONTAINER_ID=$(docker run -d -e HEDERA_MIRROR_IMPORTER_STARTDATE=${STARTDATE} \
-e NETWORK=${NETWORK} \
-e HEDERA_MIRROR_ROSETTA_RESPONSE_MAXTRANSACTIONSINBLOCK=4 \
-v ${{ github.workspace }}/application_importer.yml:/app/importer/application.yml \
-v ${{ github.workspace }}/application_rosetta.yml:/app/rosetta/application.yml \
-p 5700:5700 "${MODULE}:${{ github.sha }}")
echo "ONLINE_CONTAINER_ID=$ONLINE_CONTAINER_ID" >> $GITHUB_ENV
- name: Wait for Mirror Node to Start Syncing
run: ./scripts/wait-for-mirror-node.sh
env:
MAX_WAIT_SECONDS: 900
- name: Rosetta CLI Configuration
working-directory: ./hedera-mirror-rosetta/scripts/validation/${{ env.NETWORK }}
run: |
# set start index to genesis index + 1
body='{"network_identifier": {"blockchain": "Hedera", "network": "'${NETWORK}'"}}'
startIndex=$(curl -sL -d "${body}" http://localhost:5700/network/status | jq '.genesis_block_identifier.index+1')
echo "Setting data start_index to $startIndex"
jq --argjson startIndex $startIndex '.data.start_index=$startIndex' validation.json > tmp.json && \
mv tmp.json validation.json
- name: Run Rosetta CLI Validation
working-directory: ./hedera-mirror-rosetta/scripts/validation
run: ./run-validation.sh ${NETWORK} data
- name: Run Rosetta Postman API Tests
working-directory: ./charts/hedera-mirror-rosetta
run: |
npm install -g newman
newman run postman.json
- name: Show Container Log
if: ${{ failure() }}
run: |
echo "Logs for online container ${ONLINE_CONTAINER_ID}"
[[ -n "${ONLINE_CONTAINER_ID}" ]] && docker logs ${ONLINE_CONTAINER_ID} || true