Skip to content

Commit bd41fbe

Browse files
author
mike dupont
committed
remove strace
1 parent def00a1 commit bd41fbe

File tree

4 files changed

+238
-1
lines changed

4 files changed

+238
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Clinic Performance Analysis
2+
3+
inputs:
4+
gh-token:
5+
description: "value for GITHUB_TOKEN"
6+
required: true
7+
javascript-file:
8+
description: "Javascript file to execute in the performance tests"
9+
required: false
10+
default: "dist/server.js"
11+
artifact-suffix:
12+
description: "Artifact suffix, it will be complemented with a short sha"
13+
required: true
14+
clinic-tool:
15+
description: "ClinicJS tool to use in this action. Must be one of this values: doctor, flame, bubbleprof, heapprofiler."
16+
required: true
17+
autocannon-endpoint:
18+
description: "Endpoint to call using autocannon"
19+
required: false
20+
default: null
21+
autocannon-connections:
22+
description: "[autocannon] The number of concurrent connections to use. default: 10."
23+
required: false
24+
default: 10
25+
autocannon-amount:
26+
description: "[autocannon] The number of requests to make before exiting the benchmark."
27+
required: false
28+
default: 10
29+
30+
runs:
31+
using: composite
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v4
35+
36+
- name: Setup Node.js
37+
uses: actions/setup-node@v4
38+
with:
39+
node-version: '20.x'
40+
41+
- name: Install dependencies
42+
shell: bash
43+
run: npm install
44+
45+
- name: Build server
46+
shell: bash
47+
run: npm run build
48+
env:
49+
NODE_ENV: production
50+
51+
- name: Get short SHA
52+
id: get_sha
53+
shell: bash
54+
run: echo "short_sha=${GITHUB_SHA::6}" >> $GITHUB_ENV
55+
56+
- name: Run Clinic with autocannon
57+
if: inputs.autocannon-endpoint != null
58+
shell: bash
59+
run: |
60+
npx clinic ${{ inputs.clinic-tool }} --autocannon [ ${{ inputs.autocannon-endpoint }} -a ${{ inputs.autocannon-amount}} -c ${{ inputs.autocannon-connections }}] -- node ${{ inputs.javascript-file }}
61+
62+
- name: Run Clinic
63+
if: inputs.autocannon-endpoint == null
64+
shell: bash
65+
run: |
66+
npx clinic ${{ inputs.clinic-tool }} -- node ${{ inputs.javascript-file }}
67+
68+
- name: Generate HTML report
69+
shell: bash
70+
run: |
71+
FILENAME=$(find .clinic/* -type d -maxdepth 1 |sed "s/.clinic\//""/")
72+
73+
mkdir -p artifacts/performance-tests/${{ inputs.artifact-suffix }}
74+
mv .clinic/* artifacts/performance-tests/${{ inputs.artifact-suffix }}
75+
mv artifacts/performance-tests/${{ inputs.artifact-suffix }}/$FILENAME.html artifacts/performance-tests/${{ inputs.artifact-suffix }}/${{ inputs.artifact-suffix }}.html
76+
77+
- name: Upload Clinic Report as Artifact
78+
uses: actions/upload-artifact@v4
79+
with:
80+
name: ${{ env.short_sha }}-${{ inputs.artifact-suffix }}
81+
path: artifacts/performance-tests
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Clinic Performance Analysis
2+
3+
inputs:
4+
gh-token:
5+
description: GitHub token
6+
required: true
7+
8+
runs:
9+
using: composite
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
14+
- name: Get short SHA
15+
id: get_sha
16+
shell: bash
17+
run: echo "short_sha=${GITHUB_SHA::6}" >> $GITHUB_ENV
18+
19+
- name: Download artifact
20+
uses: actions/download-artifact@v4
21+
with:
22+
name: "${{ env.short_sha }}-flame-artifact"
23+
path: artifacts/performance-tests/${{ env.short_sha }}
24+
25+
- name: Download artifact
26+
uses: actions/download-artifact@v4
27+
with:
28+
name: "${{ env.short_sha }}-doctor-artifact"
29+
path: artifacts/performance-tests/${{ env.short_sha }}
30+
31+
- name: Deploy to GitHub Pages
32+
uses: peaceiris/actions-gh-pages@v4
33+
with:
34+
github_token: ${{ inputs.gh-token }}
35+
publish_dir: artifacts
36+
keep_files: true
37+
allow_empty_commit: true
38+
39+
- name: Get Pull Request Number
40+
id: get_pr_number
41+
shell: bash
42+
run: |
43+
PR_NUMBER=$(curl -s -H "Authorization: token ${{ inputs.gh-token }}" \
44+
"https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}/pulls" | \
45+
jq '.[0].number')
46+
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
47+
48+
- name: Comment on Pull Request
49+
if: env.PR_NUMBER != 'null'
50+
uses: actions/github-script@v7
51+
with:
52+
github-token: ${{ inputs.gh-token }}
53+
script: |
54+
const doctorReportUrl = `https://${{ github.repository_owner }}.github.io/${context.repo.repo}/performance-tests/${{ env.short_sha }}/doctor-artifact/doctor-artifact.html`;
55+
const flameReportUrl = `https://${{ github.repository_owner }}.github.io/${context.repo.repo}/performance-tests/${{ env.short_sha }}/flame-artifact/flame-artifact.html`;
56+
57+
github.rest.issues.createComment({
58+
issue_number: process.env.PR_NUMBER,
59+
owner: context.repo.owner,
60+
repo: context.repo.repo,
61+
body: `
62+
### :bar_chart: Clinic JS Reports
63+
64+
| Name | Description | Script/Endpoint | Link |
65+
|------------|-----------------------------------------------------------------------------|---------------------|-----------------------------------------------------------------|
66+
| Doctor JS | Clinic Doctor analyzes Node.js applications to find performance bottlenecks | \`/process-simulator\` | [View Report](${doctorReportUrl}) |
67+
| Flame JS | Clinic Flame visualizes CPU utilization to identify performance issues | \`/process-simulator\` | [View Report](${flameReportUrl}) |
68+
`});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Run performance tests
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- main
8+
- feature/*
9+
- hotfix/*
10+
- release/*
11+
- support/*
12+
- revert-*
13+
- dependabot/*
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
17+
cancel-in-progress: true
18+
19+
20+
jobs:
21+
doctor-performance-tests:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
id-token: write
25+
contents: read
26+
packages: read
27+
actions: write
28+
29+
steps:
30+
- uses: actions/checkout@v4
31+
- name: Run Doctor (ClinicJS)
32+
uses: ./.github/base-actions/clinicjs-toolkit
33+
with:
34+
gh-token: ${{ secrets.GITHUB_TOKEN }}
35+
clinic-tool: doctor
36+
javascript-file: dist/server.js
37+
autocannon-endpoint: /process-simulator
38+
artifact-suffix: doctor-artifact
39+
40+
flame-performance-tests:
41+
runs-on: ubuntu-latest
42+
permissions:
43+
id-token: write
44+
contents: read
45+
packages: read
46+
actions: write
47+
48+
steps:
49+
- uses: actions/checkout@v4
50+
- name: Run Flame (ClinicJS)
51+
uses: ./.github/base-actions/clinicjs-toolkit
52+
with:
53+
gh-token: ${{ secrets.GITHUB_TOKEN }}
54+
clinic-tool: flame
55+
javascript-file: dist/server.js
56+
autocannon-endpoint: /process-simulator
57+
artifact-suffix: flame-artifact
58+
autocannon-amount: 1
59+
autocannon-connections: 1
60+
61+
performance-reporter:
62+
needs: [doctor-performance-tests, flame-performance-tests]
63+
runs-on: ubuntu-latest
64+
permissions:
65+
id-token: write
66+
contents: write
67+
packages: read
68+
pull-requests: write
69+
actions: read
70+
71+
steps:
72+
- uses: actions/checkout@v4
73+
- name: Get all artifacts and publish results in github pages
74+
uses: ./.github/base-actions/performance-reporter
75+
with:
76+
gh-token: ${{ secrets.GITHUB_TOKEN }}

docker-compose.yml

+13-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,16 @@ services:
1111
working_dir: /app
1212
cap_add:
1313
- SYS_PTRACE
14-
command: "strace -f -o /tmp/strace.txt pnpm run test"
14+
command: "pnpm run test"
15+
# strace -f -o /tmp/strace.txt
16+
prometheus:
17+
image: prom/prometheus
18+
volumes:
19+
- "./prometheus.yml:/etc/prometheus/prometheus.yml"
20+
networks:
21+
- localprom
22+
ports:
23+
- 9090:9090
24+
networks:
25+
localprom:
26+
driver: bridge

0 commit comments

Comments
 (0)