Skip to content

Commit

Permalink
Merge branch 'main' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
stoicamarius committed Dec 2, 2024
2 parents c96b990 + dbec8bd commit 294a462
Show file tree
Hide file tree
Showing 342 changed files with 4,785 additions and 74,334 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/build-docker-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Publish Docker image

on:
release:
types: [published]
workflow_dispatch:

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18' # Specify your Node.js version

- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: multiversx/mx-api-service

- name: Build and push Docker image
id: push
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
186 changes: 186 additions & 0 deletions .github/workflows/load-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
name: Load Tests

on:
push:
branches: [main, development]
pull_request:
branches: [main, development]

jobs:
test-base:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.base.sha }}

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'

- name: Install dependencies
run: npm ci

- name: Initialize the project
run: npm run init

- name: Build
run: npm run build

- name: Copy devnet config file from src to dist
run: cp ./config/config.devnet.yaml ./dist/config/config.yaml

- name: Start docker services
run: docker compose up -d

- name: Start Node.js API
run: node ./dist/src/main.js &

- name: Install k6
run: |
sudo gpg -k
sudo gpg --no-default-keyring --keyring /usr/share/keyrings/k6-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D69
echo "deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main" | sudo tee /etc/apt/sources.list.d/k6.list
sudo apt-get update
sudo apt-get install k6
- name: Wait for API to be ready
run: |
until curl --output /dev/null --silent --fail http://localhost:4001/hello; do
echo 'Waiting for API...'
sleep 1
done
- name: Preload cache
run: k6 run ./k6/preload.js

- name: Run k6 Load Test
run: k6 run ./k6/script.js

- name: Upload result file for base branch
uses: actions/upload-artifact@v3
with:
name: base-results
path: k6/output/summary.json

- name: Stop docker services
run: docker compose down

test-head:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'

- name: Install dependencies
run: npm ci

- name: Initialize the project
run: npm run init

- name: Build
run: npm run build

- name: Copy devnet config file from src to dist
run: cp ./config/config.devnet.yaml ./dist/config/config.yaml

- name: Start docker services
run: docker compose up -d

- name: Start Node.js API
run: node ./dist/src/main.js &

- name: Install k6
run: |
sudo gpg -k
sudo gpg --no-default-keyring --keyring /usr/share/keyrings/k6-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D69
echo "deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main" | sudo tee /etc/apt/sources.list.d/k6.list
sudo apt-get update
sudo apt-get install k6
- name: Wait for API to be ready
run: |
until curl --output /dev/null --silent --fail http://localhost:4001/hello; do
echo 'Waiting for API...'
sleep 1
done
- name: Preload cache
run: k6 run ./k6/preload.js

- name: Run k6 Load Test
run: k6 run ./k6/script.js

- name: Upload result file for head branch
uses: actions/upload-artifact@v3
with:
name: head-results
path: k6/output/summary.json

- name: Stop docker services
run: docker compose down

compare-results:
runs-on: ubuntu-latest

needs: [test-base, test-head]
steps:
- uses: actions/checkout@v2

- name: Download all artifacts
uses: actions/download-artifact@v3
with:
path: artifacts

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'

- name: Compare test results
run: |
node ./k6/compare-results.js ${{ github.event.pull_request.base.sha }} artifacts/base-results/summary.json ${{ github.event.pull_request.head.sha }} artifacts/head-results/summary.json report.md
- name: Render the report from the template
id: template
uses: chuhlomin/render-template@v1
if: github.event_name == 'pull_request'
with:
template: report.md
vars: |
base: ${{ github.event.pull_request.base.sha }}
head: ${{ github.event.pull_request.head.sha }}
- name: Upload the report markdown
uses: actions/upload-artifact@v3
if: github.event_name == 'pull_request'
with:
name: report-markdown
path: report.md

- name: Find the comment containing the report
id: fc
uses: peter-evans/find-comment@v2
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: 'k6 load testing comparison'

- name: Create or update the report comment
uses: peter-evans/create-or-update-comment@v2
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.template.outputs.result }}
edit-mode: replace
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM node:18.19-alpine

WORKDIR /app
RUN chown -R node:node /app

USER node
RUN mkdir -p /app/dist/src
COPY --chown=node . /app

RUN npm install
RUN npm run init
RUN npm run build

EXPOSE 3001
RUN chmod +x entrypoint.sh

CMD ["./entrypoint.sh"]
2 changes: 1 addition & 1 deletion config/config.devnet-old.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ flags:
useRequestLogging: false
useVmQueryTracing: false
processNfts: true
indexer-v3: true
collectionPropertiesFromGateway: false
features:
eventsNotifier:
Expand Down Expand Up @@ -88,6 +87,7 @@ urls:
ipfs: 'https://ipfs.io/ipfs'
socket: 'devnet-socket-api.multiversx.com'
maiarId: 'https://devnet-old-id-api.multiversx.com'
assetsCdn: 'https://tools.multiversx.com/assets-cdn'
indexer:
type: 'elastic'
maxPagination: 10000
Expand Down
10 changes: 8 additions & 2 deletions config/config.devnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ flags:
useRequestLogging: false
useVmQueryTracing: false
processNfts: true
indexer-v3: true
collectionPropertiesFromGateway: false
features:
eventsNotifier:
Expand Down Expand Up @@ -50,6 +49,9 @@ features:
dataApi:
enabled: false
serviceUrl: 'https://devnet-data-api.multiversx.com'
assetsFetch:
enabled: true
assetesUrl: 'https://tools.multiversx.com/assets-cdn'
auth:
enabled: false
maxExpirySeconds: 86400
Expand Down Expand Up @@ -100,6 +102,9 @@ features:
tokensFetch:
enabled: true
serviceUrl: 'https://devnet-api.multiversx.com'
providersFetch:
enabled: true
serviceUrl: 'https://devnet-api.multiversx.com'
image:
width: 600
height: 600
Expand Down Expand Up @@ -142,6 +147,7 @@ caching:
cacheTtl: 6
processTtl: 600
poolLimit: 50
cacheDuration: 3
keepAliveTimeout:
downstream: 61000
upstream: 60000
Expand All @@ -162,4 +168,4 @@ inflation:
- 719203
nftProcess:
parallelism: 1
maxRetries: 3
maxRetries: 3
1 change: 0 additions & 1 deletion config/config.e2e-mocked.mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ flags:
useRequestCaching: true
useKeepAliveAgent: true
useTracing: false
indexer-v3: true
collectionPropertiesFromGateway: false
urls:
self: 'https://api.multiversx.com'
Expand Down
1 change: 0 additions & 1 deletion config/config.e2e.mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ flags:
useRequestCaching: true
useKeepAliveAgent: true
useTracing: false
indexer-v3: true
collectionPropertiesFromGateway: false
urls:
self: 'https://api.multiversx.com'
Expand Down
10 changes: 8 additions & 2 deletions config/config.mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ flags:
useRequestLogging: false
useVmQueryTracing: false
processNfts: true
indexer-v3: false
collectionPropertiesFromGateway: false
features:
eventsNotifier:
Expand Down Expand Up @@ -104,6 +103,12 @@ features:
tokensFetch:
enabled: true
serviceUrl: 'https://api.multiversx.com'
providersFetch:
enabled: true
serviceUrl: 'https://api.multiversx.com'
assetsFetch:
enabled: true
assetesUrl: 'https://tools.multiversx.com/assets-cdn'
image:
width: 600
height: 600
Expand Down Expand Up @@ -146,6 +151,7 @@ caching:
cacheTtl: 6
processTtl: 600
poolLimit: 50
cacheDuration: 3
keepAliveTimeout:
downstream: 61000
upstream: 60000
Expand All @@ -166,4 +172,4 @@ inflation:
- 719203
nftProcess:
parallelism: 1
maxRetries: 3
maxRetries: 3
8 changes: 7 additions & 1 deletion config/config.testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ flags:
useRequestLogging: false
useVmQueryTracing: false
processNfts: true
indexer-v3: true
collectionPropertiesFromGateway: false
features:
eventsNotifier:
Expand Down Expand Up @@ -103,6 +102,12 @@ features:
tokensFetch:
enabled: true
serviceUrl: 'https://testnet-api.multiversx.com'
providersFetch:
enabled: true
serviceUrl: 'https://testnet-api.multiversx.com'
assetsFetch:
enabled: true
assetesUrl: 'https://tools.multiversx.com/assets-cdn'
image:
width: 600
height: 600
Expand Down Expand Up @@ -145,6 +150,7 @@ caching:
cacheTtl: 6
processTtl: 600
poolLimit: 50
cacheDuration: 3
keepAliveTimeout:
downstream: 61000
upstream: 60000
Expand Down
Loading

0 comments on commit 294a462

Please sign in to comment.