Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
d786f00
edit readme (#1)
LumerinIO Apr 11, 2024
98e3675
Test sync (#3)
LumerinIO Apr 11, 2024
b38f4c1
update comment to unprotected branch (#5)
nomadicrogue Apr 11, 2024
2cefdf1
Merge branch 'stg' into dev
LumerinIO Apr 11, 2024
a406a08
updated readme (#7)
nomadicrogue Apr 11, 2024
654507a
update environemnt settings for CICD in gitlab (#8)
LumerinIO Apr 12, 2024
a7970f5
Stg to main (#11)
abs2023 Apr 12, 2024
f36a4f8
feat: update contracts-js 1.2.0 (#13)
shev-titan Jan 8, 2025
bc5c45a
fix: contract purchased abi (#14)
shev-titan Jan 8, 2025
b19b170
rewrite in ts
shev-titan Apr 24, 2025
02a511d
added price calculation
shev-titan Apr 25, 2025
0eea884
feat: add price and fees
shev-titan Apr 28, 2025
c1fce4a
feat: optimize blockchain node usage
shev-titan Apr 29, 2025
a134d60
initial framework for ghbuild and gldeploy
abs2023 Apr 30, 2025
1097121
kick CI-CD
Apr 30, 2025
7db527c
update sed for version
Apr 30, 2025
b83c5f9
Framework for GHBuild and GLDeploy (#19)
abs2023 Apr 30, 2025
741ac87
Merge remote-tracking branch 'origin/test' into dev
Apr 30, 2025
a7ae96d
fix conflicts
Apr 30, 2025
f590c2e
fix variable order
Apr 30, 2025
cc2f5d2
fixing jobs
Apr 30, 2025
d50e7ee
ignore .env.test
shev-titan May 2, 2025
71224ad
Merge branch 'dev' into feat/indexer-update-dynamic-price
shev-titan May 2, 2025
faa3702
Feat/indexer update dynamic price (#18)
shev-titan May 2, 2025
b51b50b
update to use VAR for gitlab_trigger_url (visibility)
May 3, 2025
7b5b4d8
listen on all ports
May 4, 2025
cae0a2a
modify and simplify dependecies
May 4, 2025
60c1629
made sure to test build on push to dev as well as any PR to dev/test/…
May 4, 2025
e3d78b9
fix: buyer address
shev-titan May 5, 2025
e88bd44
Merge branch 'dev' into feat/indexer-update-dynamic-price
shev-titan May 5, 2025
85e23c1
Feat/indexer update dynamic price (#27)
shev-titan May 5, 2025
80df51b
remove test branch ... dev and main only
May 5, 2025
660f8bc
remove test branch ... dev and main only (#29)
LumerinIO May 5, 2025
07b98f4
fix: listen to fee updated event
shev-titan May 14, 2025
d52763d
fix: listen to fee updated event (#30)
shev-titan May 14, 2025
759969e
feat: validator indexing
shev-titan May 26, 2025
522ee9b
feat: validator indexing (#31)
shev-titan May 26, 2025
f7539ad
fix: handling only single event from each block
shev-titan Jun 9, 2025
2f4c4b1
feat: local https support
shev-titan Jun 9, 2025
e969c28
Merge branch 'dev' into feat/validator-indexing
shev-titan Jun 9, 2025
63d7421
Feat/validator indexing (#32)
shev-titan Jun 9, 2025
75677b1
healthcheck version
shev-titan Jun 10, 2025
ab48d0b
healthcheck version (#33)
shev-titan Jun 10, 2025
b319e8d
fix: remove selfsigned
shev-titan Jun 10, 2025
f81dcf2
fix: remove selfsigned (#34)
shev-titan Jun 10, 2025
4eb08bf
feat: add uptime
shev-titan Jun 10, 2025
449d160
fix: adjust to getHistory blockchain call signature change
shev-titan Jun 25, 2025
f2b072f
Feat/validator indexing (#35)
shev-titan Jun 26, 2025
ce824b1
add stg branch capability
Jun 26, 2025
8b664bd
add stg branch capability (#36)
abs2023 Jun 26, 2025
9bda2da
changed license file to test pipelines
Jun 26, 2025
9a99976
changed license file to test pipelines (#37)
abs2023 Jun 26, 2025
020b2fc
test stg pr and deploy (#38)
abs2023 Jun 26, 2025
248772f
Merge branch 'main' into stg
abs2023 Sep 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
#dev
ADMIN_API_KEY=1234
CLONE_FACTORY_ADDRESS=0x15437978300786aDe37f61e02Be1C061e51353D3
ETH_NODE_URL=https://arb-mainnet.g.alchemy.com/v2/{API_KEY}
FASTIFY_ADDRESS=0.0.0.0
FASTIFY_PLUGIN_TIMEOUT=60000
HASHRATE_ORACLE_ADDRESS=0xdc64a140aa3e981100a9beca4e685f962f0cf6c9
PORT=3000

#local
ADMIN_API_KEY=1234
CLONE_FACTORY_ADDRESS=0xb7f8bc63bbcad18155201308c8f3540b07f84f5e
ETH_NODE_URL=http://localhost:8545
HASHRATE_ORACLE_ADDRESS=0xdc64a140aa3e981100a9beca4e685f962f0cf6c9
PORT=3000
9 changes: 9 additions & 0 deletions .env.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# for local env with hardhat
ADMIN_API_KEY=1234
CLONE_FACTORY_ADDRESS=0x610178da211fef7d417bc0e6fed39f05609ad788
ETH_NODE_URL=http://localhost:8545
FASTIFY_ADDRESS=0.0.0.0
FASTIFY_PLUGIN_TIMEOUT=60000
HASHRATE_ORACLE_ADDRESS=0xdc64a140aa3e981100a9beca4e685f962f0cf6c9
MULTICALL_ADDRESS=0x68b1d87f95878fe05b998f19b66f4baba5de1aed
PORT=3000
260 changes: 260 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
name: CI-CD

on:
workflow_dispatch:
inputs:
build_container:
description: "Build container image"
required: true
type: boolean

push:
branches:
- main
- stg
- dev
- cicd/*

paths: [".github/**", "src/**", "Dockerfile", "package.json", "package-lock.json", "LICENSE", "README.md"]

pull_request:
types: [opened, reopened, synchronize]
paths: [".github/**", "src/**", "Dockerfile", "package.json", "package-lock.json", "LICENSE", "README.md"]

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash

env:
TEST_ENV_VAR: "test"

jobs:
Generate-Tag:
runs-on: ubuntu-latest
name: Generate Tag Name
outputs:
tag_name: ${{ steps.gen_tag_name.outputs.tag_name }}
vtag: ${{ steps.gen_tag_name.outputs.vtag }}
vfull: ${{ steps.gen_tag_name.outputs.vfull }}
image_name: ${{ steps.gen_tag_name.outputs.image_name }}
artifacts_base_url: ${{ github.server_url }}/${{ github.repository }}/releases/download/${{ steps.gen_tag_name.outputs.tag_name }}
steps:
- name: Clone repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Determine tag name
id: gen_tag_name
shell: bash
run: |
IMAGE_NAME="ghcr.io/lumerin-protocol/proxy-indexer"
VMAJ_NEW=2
VMIN_NEW=0
VPAT_NEW=0
set +o pipefail
VLAST=$(git describe --tags --abbrev=0 --match='v[1-9]*' refs/remotes/origin/main 2>/dev/null | cut -c2-)

if [ -n "$VLAST" ]; then
eval $(echo "$VLAST" | awk -F '.' '{print "VMAJ="$1" VMIN="$2" VPAT="$3}')
else
VMAJ=0
VMIN=0
VPAT=0
fi

if [ "$GITHUB_REF_NAME" = "main" ]; then
if [ "$VMAJ_NEW" -gt "$VMAJ" ]; then
VMAJ=$VMAJ_NEW
VMIN=$VMIN_NEW
VPAT=$VPAT_NEW
else
VMIN=$((VMIN+1))
VPAT=0
fi
VFULL=${VMAJ}.${VMIN}.${VPAT}
VTAG=v$VFULL
else
MB=$(git merge-base refs/remotes/origin/main HEAD)
VPAT=$(git rev-list --count --no-merges ${MB}..HEAD)
VFULL=${VMAJ}.${VMIN}.${VPAT}
RNAME=${GITHUB_REF_NAME##*/}
[ "$GITHUB_EVENT_NAME" = "pull_request" ] && RNAME=pr${GITHUB_REF_NAME%/merge}
VTAG=v${VFULL}-${RNAME}
fi

# Output variables for use in subsequent jobs environment
echo "::set-output name=tag_name::${VTAG}"
echo "::set-output name=vtag::${VTAG}"
echo "::set-output name=vfull::${VFULL}"
echo "::set-output name=image_name::${IMAGE_NAME}"
echo "✅ New Build Tag: $VTAG" >> $GITHUB_STEP_SUMMARY
echo "✅ Docker Image: ${IMAGE_NAME}:${VTAG}" >> $GITHUB_STEP_SUMMARY
echo "❌ Old Major Tag: $VLAST" >> $GITHUB_STEP_SUMMARY

Test-Build-Indexer-Container:
name: Test Build Indexer Container
if:
(
(github.event_name == 'pull_request' && (github.base_ref == 'main' || github.base_ref == 'dev' || github.base_ref == 'stg')) ||
(github.event_name == 'workflow_dispatch' && (github.event.inputs.build_container == 'true'))
)
runs-on: ubuntu-latest
needs: Generate-Tag
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Build Docker Image to Test
run: |
# Ensure we're in the workspace directory
cd $GITHUB_WORKSPACE

BUILDTAG=${{ needs.Generate-Tag.outputs.tag_name }}
BUILDIMAGE=${{ needs.Generate-Tag.outputs.image_name }}
BUILDCOMMIT=${{ github.sha }}
docker build \
--platform linux/amd64 \
--build-arg TAG_NAME=$BUILDTAG \
--build-arg COMMIT=$BUILDCOMMIT \
--load \
-t $BUILDIMAGE:$BUILDTAG \
-f ./Dockerfile \
. || (echo "❌ Failed to build image with tag: $BUILDIMAGE:$BUILDTAG" && exit 1)
echo "✅ Indexer Container Build Successful!"

GHCR-Build-and-Push:
name: Build & Push Docker Image
if: |
(
(github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/stg')) ||
(github.event_name == 'workflow_dispatch' && (github.event.inputs.build_container == 'true'))
)
needs:
- Generate-Tag
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Multi-Platform Docker Image
run: |
# Ensure we're in the workspace directory
cd $GITHUB_WORKSPACE

BUILDTAG=${{ needs.Generate-Tag.outputs.tag_name }}
BUILDIMAGE=${{ needs.Generate-Tag.outputs.image_name }}
BUILDCOMMIT=${{ github.sha }}
FULLTAG=${{ needs.Generate-Tag.outputs.vfull }}

# Debug: Show current directory and file existence
pwd
ls -la
echo "Checking if package.json exists..."
[ -f ./package.json ] && echo "package.json exists" || echo "package.json does not exist"
echo "Injecting version $FULLTAG into package.json"
sed -i "s/\"version\": \".*\"/\"version\": \"$FULLTAG\"/" ./package.json
cat ./package.json | grep '"version"' # Optional: Verify the change
docker build \
--platform linux/amd64 \
--build-arg TAG_NAME=$BUILDTAG \
--build-arg COMMIT=$BUILDCOMMIT \
--push \
-t $BUILDIMAGE:$BUILDTAG \
-f ./Dockerfile \
. || (echo "❌ Failed to push image with tag: $BUILDIMAGE:$BUILDTAG" && exit 1)
echo "✅ Indexer Container Build and Push of $BUILDIMAGE:$BUILDTAG Successful!"

- name: Optionally Push Latest Tag
if: ${{ github.ref == 'refs/heads/main' }}
run: |
BUILDIMAGE=${{ needs.Generate-Tag.outputs.image_name }}
BUILDTAG=${{ needs.Generate-Tag.outputs.tag_name }}
docker pull $BUILDIMAGE:$BUILDTAG || (echo "❌ Failed to pull image: $BUILDIMAGE:$BUILDTAG" && exit 1)
docker tag $BUILDIMAGE:$BUILDTAG $BUILDIMAGE:latest || (echo "❌ Failed to tag image as :latest" && exit 1)
docker push $BUILDIMAGE:latest || (echo "❌ Failed to push image as :latest" && exit 1)
echo "✅ Indexer Container Push $BUILDIMAGE:latest Tag Successful!"

GitLab-Deploy-Indexer:
name: Deploy Indexer to GitLab
if: |
(
(github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/stg'))
)
needs:
- Generate-Tag
- GHCR-Build-and-Push
runs-on: ubuntu-latest
steps:
- name: Clone
id: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install -y jq

- name: Trigger GitLab Pipeline
run: |
BUILDTAG=${{ needs.Generate-Tag.outputs.tag_name }}
FULLTAG=${{ needs.Generate-Tag.outputs.vfull }}
echo "Triggering GitLab Deploy for branch ${{ github.ref_name }} with tag $BUILDTAG"
# Determine branch
if [ "${{ github.ref_name }}" == "dev" ]; then
GITLABBRANCH="dev"
elif [ "${{ github.ref_name }}" == "stg" ]; then
GITLABBRANCH="stg"
elif [ "${{ github.ref_name }}" == "main" ]; then
GITLABBRANCH="main"
else
echo "❌ This branch is not configured to trigger GitLab pipelines."
exit 1
fi
echo "✅ Sending Request to GitLab branch: $GITLABBRANCH"
response=$(curl --silent \
--request POST \
--url "${{ vars.GITLAB_TRIGGER_URL }}" \
--form "token=${{ secrets.GITLAB_TRIGGER_TOKEN }}" \
--form "ref=$GITLABBRANCH" \
--form "variables[SOURCE_REPO]=${{ github.repository }}" \
--form "variables[SOURCE_BRANCH]=${{ github.ref_name }}" \
--form "variables[GITHUB_VFULL]=$FULLTAG" \
--form "variables[GITHUB_TAG]=$BUILDTAG")

# Parse JSON response using jq
gitlab_status=$(echo "$response" | jq -r '.status // "unknown"')
gitlab_web_url=$(echo "$response" | jq -r '.web_url // "N/A"')

# Log the response
echo "GitLab Response: $response"

# Validate the status field
if [[ "$gitlab_status" =~ ^(created|preparing|success|running|scheduled)$ ]]; then
echo "✅ GitLab pipeline triggered successfully! Status: $gitlab_status"
echo "Pipeline details: $gitlab_web_url"
else
echo "❌ GitLab pipeline FAILED. Invalid status: $gitlab_status"
echo "Pipeline details: $gitlab_web_url"
exit 1
fi
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ profile*
*flamegraph*

.env
.env.dev
.env.test
.env.prod
.env.stg

dist
Loading
Loading