Bump github.com/hashgraph/hedera-sdk-go/v2 from 2.30.0 to 2.31.0 in /hedera-mirror-rosetta #742
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Rosetta API | |
on: | |
schedule: | |
- cron: "0 1 * * *" # Daily at 1:00 AM | |
pull_request: | |
branches: [ main, release/** ] | |
paths: [ hedera-mirror-rosetta/** ] | |
push: | |
branches: [ main, release/** ] | |
paths: [ hedera-mirror-rosetta/** ] | |
tags: [ v* ] | |
defaults: | |
run: | |
working-directory: ./hedera-mirror-rosetta | |
env: | |
IMAGE: hedera-mirror-rosetta-image | |
MODULE: hedera-mirror-rosetta | |
jobs: | |
image: | |
if: github.event_name == 'push' || github.event_name == 'schedule' || (github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Set GIT_REF | |
run: | | |
if [ "{{ github.event_name }}" = "pull_request" ]; then | |
# for pull request, GITHUB_SHA is the last merge commit on the GITHUB_REF branch. We want to use | |
# the PR branch HEAD sha instead | |
GIT_REF="{{ github.event.pull_request.head.sha }}" | |
else | |
GIT_REF="${GITHUB_SHA}" | |
fi | |
echo "GIT_REF=${GIT_REF}" >> $GITHUB_ENV | |
- name: Build Mirror Node All-in-One Docker Image and Export | |
uses: docker/build-push-action@v5 | |
with: | |
build-args: GIT_REF=${{ env.GIT_REF }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
context: ./hedera-mirror-rosetta/container | |
outputs: type=docker,dest=/tmp/${{ env.MODULE }}.tar | |
provenance: false | |
tags: ${{ env.MODULE }}:latest | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.IMAGE }} | |
path: /tmp/${{ env.MODULE }}.tar | |
if-no-files-found: error | |
validate: | |
runs-on: ubuntu-latest | |
needs: image | |
strategy: | |
matrix: | |
online-only: [ 'true', 'false' ] | |
timeout-minutes: 15 | |
env: | |
OFFLINE_URL: http://localhost:5700 | |
ROSETTA_CLI_VERSION: v0.10.3 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Download Artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ env.IMAGE }} | |
path: /tmp | |
- name: Load Mirror Node ALl-in-One Docker Image | |
run: | | |
docker load --input /tmp/${MODULE}.tar | |
docker image ls -a | |
- name: Importer Configuration | |
run: echo "${{ secrets.ROSETTA_IMPORTER_CONFIG }}" | base64 -d > /tmp/application_importer.yml | |
- name: Rosetta Configuration | |
run: echo "${{ secrets.ROSETTA_ROSETTA_CONFIG }}" | base64 -d > /tmp/application_rosetta.yml | |
- name: Set Importer StartDate | |
run: | | |
# grep extracts the date up to minute, e.g., 2021-11-15T16:48:, so as to always round down to the whole minute | |
# and avoid importer saves the first account balance file but not the account balance entries | |
startdate=$(date --date='15 minutes ago' -Iseconds -u | grep -o -e '^[0-9T:-]\+:') | |
startdate="${startdate}00Z" | |
echo "STARTDATE=$startdate" >> $GITHUB_ENV | |
echo "Set importer startDate to $startdate" | |
- name: Run Mirror Node in Online Mode | |
run: | | |
ONLINE_CONTAINER_ID=$(docker run -d -e HEDERA_MIRROR_IMPORTER_STARTDATE=$STARTDATE \ | |
-e NETWORK=testnet \ | |
-e HEDERA_MIRROR_ROSETTA_RESPONSE_MAXTRANSACTIONSINBLOCK=4 \ | |
-v /tmp/application_importer.yml:/app/importer/application.yml \ | |
-v /tmp/application_rosetta.yml:/app/rosetta/application.yml \ | |
-p 5700:5700 "${MODULE}:latest") | |
echo "ONLINE_CONTAINER_ID=$ONLINE_CONTAINER_ID" >> $GITHUB_ENV | |
- name: Run Mirror Node in Offline Mode | |
if: matrix.online-only != 'true' | |
run: | | |
# create an isolated network for offline mode and insert an iptables rule to drop any packets from the | |
# isolated network | |
docker network create --gateway 192.168.10.1 --subnet 192.168.10.0/24 isolated | |
sudo iptables -I DOCKER-USER --destination 0.0.0.0/0 --source 192.168.10.0/24 -j DROP | |
OFFLINE_CONTAINER_ID=$(docker run -d -e MODE=offline -e NETWORK=testnet --network isolated \ | |
-v /tmp/application_rosetta.yml:/app/rosetta/application.yml \ | |
-p 5701:5700 "${MODULE}:latest") | |
echo "OFFLINE_CONTAINER_ID=$OFFLINE_CONTAINER_ID" >> $GITHUB_ENV | |
echo "OFFLINE_URL=http://localhost:5701" >> $GITHUB_ENV | |
- name: Wait for Mirror Node to start syncing | |
run: ./scripts/wait-for-mirror-node.sh | |
env: | |
MAX_WAIT_SECONDS: 240 | |
- name: Rosetta CLI Configuration | |
run: | | |
# add prefunded accounts for construction validation, override construction offline_url | |
echo "${{ secrets.ROSETTA_PREFUNDED_ACCOUNTS }}" | base64 -d > /tmp/accounts.json | |
cd ./scripts/validation/testnet/ | |
jq --slurpfile accounts /tmp/accounts.json \ | |
'.construction.prefunded_accounts=$accounts[0] | .construction.offline_url="${{ env.OFFLINE_URL }}"' \ | |
validation.json > /tmp/validation.json | |
# set start index to genesis index + 1 | |
body="{\"network_identifier\": $(cat validation.json | jq -c -M '.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' /tmp/validation.json > validation.json | |
- name: Run Rosetta CLI Validation | |
working-directory: ./hedera-mirror-rosetta/scripts/validation | |
run: | | |
echo "Installing Rosetta CLI" | |
curl -sSfL https://raw.githubusercontent.com/coinbase/rosetta-cli/master/scripts/install.sh | \ | |
sh -s -- -b . "${ROSETTA_CLI_VERSION}" | |
./run-validation.sh testnet construction > /tmp/construction-validation.log 2>&1 & | |
pid=$! | |
./run-validation.sh testnet data && code=0 || code=$? | |
[[ $code -eq 0 ]] && { wait $pid || code=$?; } | |
cat /tmp/construction-validation.log | |
exit $code | |
- name: Run Rosetta BDD Tests | |
working-directory: ./hedera-mirror-rosetta/test/bdd-client | |
run: | | |
export GOROOT=$GOROOT_1_21_X64 | |
export PATH=$GOROOT/bin:$PATH | |
jq -r '.[] | {"privateKey": .privkey, "id": .account_identifier.address}' /tmp/accounts.json | \ | |
jq -s '. | {operators: .} | .server.offlineUrl="${{ env.OFFLINE_URL }}" | {test: .} | {rosetta: .} | |
| {mirror: .} | {hedera: .}' | \ | |
yq eval -P > application.yml | |
go test -v | |
- 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() && (env.OFFLINE_CONTAINER_ID != '' || env.ONLINE_CONTAINER_ID != '') }} | |
run: | | |
echo "Logs for offline container ${OFFLINE_CONTAINER_ID}" | |
[[ -n "${OFFLINE_CONTAINER_ID}" ]] && docker logs ${OFFLINE_CONTAINER_ID} || true | |
echo "Logs for online container ${ONLINE_CONTAINER_ID}" | |
[[ -n "${ONLINE_CONTAINER_ID}" ]] && docker logs ${ONLINE_CONTAINER_ID} || true | |
delete-image: | |
runs-on: ubuntu-latest | |
needs: validate | |
if: ${{ always() }} | |
steps: | |
- name: Delete Artifact | |
uses: geekyeggo/delete-artifact@v2 | |
with: | |
name: ${{ env.IMAGE }} | |
failOnError: false | |
gosec: | |
runs-on: ubuntu-latest | |
env: | |
GO111MODULE: on | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
path: tmp | |
- name: Copy hedera-mirror-rosetta to workspace root | |
working-directory: . | |
run: | | |
cp -r tmp/hedera-mirror-rosetta/* . | |
rm -fr tmp | |
- name: Run Gosec Security Scanner | |
uses: securego/[email protected] | |
with: | |
args: ./... | |