Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/unit test clean #13

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.dockerignore
.git
Dockerfile
_clinic
data
perf-reporting/output
81 changes: 81 additions & 0 deletions .github/base-actions/clinicjs-toolkit/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Clinic Performance Analysis

inputs:
gh-token:
description: "value for GITHUB_TOKEN"
required: true
javascript-file:
description: "Javascript file to execute in the performance tests"
required: false
default: "dist/server.js"
artifact-suffix:
description: "Artifact suffix, it will be complemented with a short sha"
required: true
clinic-tool:
description: "ClinicJS tool to use in this action. Must be one of this values: doctor, flame, bubbleprof, heapprofiler."
required: true
autocannon-endpoint:
description: "Endpoint to call using autocannon"
required: false
default: null
autocannon-connections:
description: "[autocannon] The number of concurrent connections to use. default: 10."
required: false
default: 10
autocannon-amount:
description: "[autocannon] The number of requests to make before exiting the benchmark."
required: false
default: 10

runs:
using: composite
steps:
- name: Checkout repository
uses: meta-introspector/checkout@v4

- name: Setup Node.js
uses: meta-introspector/setup-node@v4
with:
node-version: '20.x'

- name: Install dependencies
shell: bash
run: npm install

- name: Build server
shell: bash
run: npm run build
env:
NODE_ENV: production

- name: Get short SHA
id: get_sha
shell: bash
run: echo "short_sha=${GITHUB_SHA::6}" >> $GITHUB_ENV

- name: Run Clinic with autocannon
if: inputs.autocannon-endpoint != null
shell: bash
run: |
npx clinic ${{ inputs.clinic-tool }} --autocannon [ ${{ inputs.autocannon-endpoint }} -a ${{ inputs.autocannon-amount}} -c ${{ inputs.autocannon-connections }}] -- node ${{ inputs.javascript-file }}

- name: Run Clinic
if: inputs.autocannon-endpoint == null
shell: bash
run: |
npx clinic ${{ inputs.clinic-tool }} -- node ${{ inputs.javascript-file }}

- name: Generate HTML report
shell: bash
run: |
FILENAME=$(find .clinic/* -type d -maxdepth 1 |sed "s/.clinic\//""/")

mkdir -p artifacts/performance-tests/${{ inputs.artifact-suffix }}
mv .clinic/* artifacts/performance-tests/${{ inputs.artifact-suffix }}
mv artifacts/performance-tests/${{ inputs.artifact-suffix }}/$FILENAME.html artifacts/performance-tests/${{ inputs.artifact-suffix }}/${{ inputs.artifact-suffix }}.html

- name: Upload Clinic Report as Artifact
uses: meta-introspector/upload-artifact@v4
with:
name: ${{ env.short_sha }}-${{ inputs.artifact-suffix }}
path: artifacts/performance-tests
68 changes: 68 additions & 0 deletions .github/base-actions/performance-reporter/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Clinic Performance Analysis

inputs:
gh-token:
description: GitHub token
required: true

runs:
using: composite
steps:
- name: Checkout code
uses: meta-introspector/checkout@v4

- name: Get short SHA
id: get_sha
shell: bash
run: echo "short_sha=${GITHUB_SHA::6}" >> $GITHUB_ENV

- name: Download artifact
uses: meta-introspector/download-artifact@v4
with:
name: "${{ env.short_sha }}-flame-artifact"
path: artifacts/performance-tests/${{ env.short_sha }}

- name: Download artifact
uses: meta-introspector/download-artifact@v4
with:
name: "${{ env.short_sha }}-doctor-artifact"
path: artifacts/performance-tests/${{ env.short_sha }}

- name: Deploy to GitHub Pages
uses: meta-introspector/actions-gh-pages@v4
with:
github_token: ${{ inputs.gh-token }}
publish_dir: artifacts
keep_files: true
allow_empty_commit: true

- name: Get Pull Request Number
id: get_pr_number
shell: bash
run: |
PR_NUMBER=$(curl -s -H "Authorization: token ${{ inputs.gh-token }}" \
"https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}/pulls" | \
jq '.[0].number')
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV

- name: Comment on Pull Request
if: env.PR_NUMBER != 'null'
uses: meta-introspector/github-script@v7
with:
github-token: ${{ inputs.gh-token }}
script: |
const doctorReportUrl = `https://${{ github.repository_owner }}.github.io/${context.repo.repo}/performance-tests/${{ env.short_sha }}/doctor-artifact/doctor-artifact.html`;
const flameReportUrl = `https://${{ github.repository_owner }}.github.io/${context.repo.repo}/performance-tests/${{ env.short_sha }}/flame-artifact/flame-artifact.html`;

github.rest.issues.createComment({
issue_number: process.env.PR_NUMBER,
owner: context.repo.owner,
repo: context.repo.repo,
body: `
### :bar_chart: Clinic JS Reports

| Name | Description | Script/Endpoint | Link |
|------------|-----------------------------------------------------------------------------|---------------------|-----------------------------------------------------------------|
| Doctor JS | Clinic Doctor analyzes Node.js applications to find performance bottlenecks | \`/process-simulator\` | [View Report](${doctorReportUrl}) |
| Flame JS | Clinic Flame visualizes CPU utilization to identify performance issues | \`/process-simulator\` | [View Report](${flameReportUrl}) |
`});
55 changes: 55 additions & 0 deletions .github/workflows/build-and-publish-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build and Publish Docker image

on:
workflow_dispatch:
push:
branches: [ "build-image" ]
pull_request:
branches: [ "build-image" ]

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: meta-introspector/checkout@v4
with:
submodules: recursive

#- name: Build the Docker image
# run: docker build . --file Dockerfile --tag my-image-name:$(date +%s)
#- name: Build the Docker image via docker compose
# run: docker compose build

#- name: Docker-Compose Publish
# uses: meta-introspector/[email protected]
# with:
# docker_compose: docker-compose.yml
- name: Build and Publish Docker image
uses: meta-introspector/[email protected]
with:
gh_token: ${{ secrets.GITHUB_TOKEN }}
image_name: o1js-perf-recording
tag_with_ref: true
tag_with_sha: true
#tags: main
tags: latest
#path: ./test
dockerfile: Dockerfile
- name: test
run: docker images

- name: Build and Publish Docker image test
uses: meta-introspector/[email protected]
with:
gh_token: ${{ secrets.GITHUB_TOKEN }}
image_name: o1js-perf-recording
tag_with_ref: true
#tag_with_sha: true
#tags: main
#tags: latest
#path: ./test
dockerfile: Dockerfile

42 changes: 42 additions & 0 deletions .github/workflows/build-and-test-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build Docker Image and run Perf Test and collect data

on:
workflow_dispatch:
push:
branches: [ "collect-perf" ]
pull_request:
branches: [ "collect-perf" ]

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: meta-introspector/checkout@v4
with:
submodules: recursive

#- name: Build the Docker image
# run: docker build . --file Dockerfile --tag my-image-name:$(date +%s)
- name: Build the Docker image via docker compose
run: docker compose build mina-local-network

- name: run the Docker tests
run: docker compose up mina-local-network

- name: docker cp results
run: docker compose cp mina-local-network:/tmp/perf.data.tar.gz perf.data.tar.gz
#- name: list files docker
# run: docker compose run mina-local-network /bin/find /app/.clinic/
#- name: docker cp strace.txt
# run: docker compose cp mina-local-network:/app/.clinic clinic
#- name: list files
# run: find clinic

- name: Archive results
uses: meta-introspector/upload-artifact@v4
with:
name: perf.data.tar.gz
path: perf.data.tar.gz
46 changes: 46 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# A workflow for deploying the Unit Tests coverage report to GitHub Pages
name: Deploy coverage report to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ['master']

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: 'pages'
cancel-in-progress: true

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: meta-introspector/checkout@v4
with:
recursive: true
- run: pnpm
- run: pnpm coverage:combined
- name: Setup Pages
uses: meta-introspector/configure-pages@v4
- name: Upload artifact
uses: meta-introspector/upload-pages-artifact@v3
with:
# Upload the coverage directory from the repository
path: './coverage/lcov-report'
- name: Deploy to GitHub Pages
id: deployment
uses: meta-introspector/deploy-pages@v4
66 changes: 66 additions & 0 deletions .github/workflows/process-perf-results.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: process perf results
on:
workflow_dispatch:
inputs:
commit_id:
description: 'Commit to read results from'
required: true
default: '5b13c202bbf6a196104ebb440678dd22037b6746'
#push:
# branches:
# - test-perf
permissions:
id-token: write
pages: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: meta-introspector/checkout@v4
#with:
# submodules: recursive
- name: Login to GHCR
uses: meta-introspector/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: pull the image
run: docker pull ghcr.io/meta-introspector/o1js/o1js-perf-recording:latest
- name: Download a Build Artifact
uses: meta-introspector/action-download-artifact@v6
with:
workflow_search: true
commit: ${{ inputs.commit_id }}
skip_unpack: true
path: data
- name: run the report
run: docker compose up --build reporting-github
env:
WORKSPACE_DIR2: $GITHUB_WORKSPACE
WORKSPACE_DIR: $GITHUB_WORKSPACE
- name: run the report
run: docker compose up --build reporting-github
env:
WORKSPACE_DIR2: $GITHUB_WORKSPACE
WORKSPACE_DIR: $GITHUB_WORKSPACE

- name: Archive results
uses: meta-introspector/upload-artifact@v4
with:
name: results.tgz
path: perf-reporting/output/results.tgz

# reporting-github-1 | + ls -latr /app/perf-reporting/output/

- name: Setup Pages
uses: meta-introspector/configure-pages@v5
- name: Upload Artifact
uses: meta-introspector/upload-pages-artifact@v5
with:
# upload entire directory
path: 'perf-reporting/output'
- name: Deploy to GitHub Pages
id: deployment
uses: meta-introspector/deploy-pages@v3

Loading
Loading