forked from multiversx/mx-api-service
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into development
- Loading branch information
Showing
342 changed files
with
4,785 additions
and
74,334 deletions.
There are no files selected for viewing
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
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 }} |
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
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 |
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
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"] |
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
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
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
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
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
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
Oops, something went wrong.