-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
195 additions
and
0 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,93 @@ | ||
name: 'Benchmarks summary uploader' | ||
on: | ||
workflow_call: | ||
inputs: | ||
artifact: | ||
required: true | ||
type: string | ||
default: "" | ||
|
||
concurrency: | ||
group: "${{ github.ref }}-${{ github.head_ref }}-${{ github.base_ref }}" | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
upload: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Check out repository code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Download artifact | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: ${{ inputs.artifact }} | ||
path: . | ||
|
||
- name: Prepare upload prerequisites | ||
run: | | ||
mkdir -p artifacts | ||
cp summary.json artifacts/summary.json | ||
echo "NOW=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_ENV | ||
- name: Upload the site to artifactory | ||
uses: PiwikPRO/actions/s3/upload@master | ||
with: | ||
aws-access-key-id: ${{ secrets.ARTIFACTORY_S3_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.ARTIFACTORY_S3_SECRET_ACCESS_KEY }} | ||
aws-http-proxy: ${{ secrets.FORWARD_PROXY_HTTP }} | ||
aws-https-proxy: ${{ secrets.FORWARD_PROXY_HTTPS }} | ||
aws-bucket: piwikpro-artifactory | ||
aws-region: eu-central-1 | ||
src-path: artifacts | ||
dst-path: "long/benchmarks/${{ github.repository }}/${NOW}" | ||
|
||
compile: | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
runs-on: ubuntu-latest | ||
needs: upload | ||
steps: | ||
|
||
- name: Copy all the reports from s3 | ||
shell: bash | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.ARTIFACTORY_S3_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.ARTIFACTORY_S3_SECRET_ACCESS_KEY }} | ||
AWS_DEFAULT_REGION: eu-central-1 | ||
HTTP_PROXY: ${{ secrets.FORWARD_PROXY_HTTP }} | ||
HTTPS_PROXY: ${{ secrets.FORWARD_PROXY_HTTPS }} | ||
run: aws s3 cp --recursive s3://piwikpro-artifactory/long/benchmarks/${{ github.repository }} reports | ||
|
||
- name: Prepare the report | ||
id: compile | ||
uses: PiwikPRO/actions/benchmark/report@pet-23-k6-action | ||
with: | ||
path: reports | ||
|
||
- name: Print the report | ||
shell: bash | ||
run: echo "${{ steps.compile.outputs.report }}" | ||
|
||
|
||
- name: Add PR comment | ||
uses: actions/github-script@v7 | ||
if: github.event_name == 'pull_request' | ||
env: | ||
REPORT: ${{ steps.compile.outputs.report }} | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const issue_number = context.issue.number; | ||
const owner = context.repo.owner; | ||
const repo = context.repo.repo; | ||
await github.rest.issues.createComment({ | ||
owner, | ||
repo, | ||
issue_number, | ||
body: process.env.REPORT | ||
}); | ||
console.log('Created a new comment.'); |
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,35 @@ | ||
name: "Piwik PRO cosign download" | ||
description: "Download cosign binary" | ||
inputs: | ||
script: | ||
required: true | ||
description: "Path to the script, that should be launched" | ||
vus: | ||
required: false | ||
description: "Number of virtual users" | ||
duration: | ||
required: false | ||
description: "Duration of the test, in format like: 10s, 5m, etc" | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Update summary of the script | ||
shell: bash | ||
run: cat ${{ github.action_path }}/summary.js >> ${{ inputs.script }} | ||
|
||
- name: Run K6 | ||
shell: bash | ||
run: | | ||
command="docker run --network host -u \"$(id -u):$(id -g)\" -v \"${PWD}:/home/k6\" --rm grafana/k6 run" | ||
command+=" ${{ inputs.script }}" | ||
if [ -n "${{ inputs.vus }}" ]; then | ||
command+=" --vus ${{ inputs.vus }}" | ||
fi | ||
if [ -n "${{ inputs.duration }}" ]; then | ||
command+=" --duration ${{ inputs.duration }}" | ||
fi | ||
eval $command |
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,47 @@ | ||
|
||
export function handleSummary(data) { | ||
const nowMs = Date.now(); | ||
var summaryObj = { | ||
"version": "v1", | ||
"run": { | ||
"start_s_since_epoch": Math.floor((nowMs - data.state.testRunDurationMs) / 1000), | ||
"end_s_since_epoch": Math.floor(nowMs / 1000), | ||
}, | ||
"data": { | ||
"latency_ms_p50": { | ||
"value": data.metrics.http_req_duration.values.med, | ||
"description": "50th percentile latency in milliseconds", | ||
"comparison": "lower_is_better" | ||
}, | ||
"latency_ms_p90":{ | ||
"value": data.metrics.http_req_duration.values["p(90)"], | ||
"description": "90th percentile latency in milliseconds", | ||
"comparison": "lower_is_better" | ||
}, | ||
"latency_ms_p95": { | ||
"value": data.metrics.http_req_duration.values["p(95)"], | ||
"description": "95th percentile latency in milliseconds", | ||
"comparison": "lower_is_better" | ||
}, | ||
"reqps_avg": { | ||
"value": data.metrics.http_reqs.values.rate, | ||
"description": "Average number of requests per second", | ||
"comparison": "higher_is_better" | ||
}, | ||
"req_failure_rate": { | ||
"value": data.metrics.http_req_failed.values.rate, | ||
"description": "The ratio of requests that failed (0-1)", | ||
"comparison": "lower_is_better" | ||
}, | ||
} | ||
}; | ||
try{ | ||
const extraMetrics = getExtraMetrics(data) | ||
summaryObj.data = Object.assign({}, summaryObj.data, extraMetrics.data) | ||
} catch(e){ | ||
console.log("Did not collect extra metrics: " + e) | ||
} | ||
return { | ||
'summary.json': JSON.stringify(summaryObj, null, 2), | ||
}; | ||
} |
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,20 @@ | ||
name: 'Benchmark summary compiler' | ||
inputs: | ||
path: | ||
default: "." | ||
outputs: | ||
report: | ||
description: "Compiled report" | ||
value: ${{ steps.compile.outputs.report }} | ||
runs: | ||
using: 'composite' | ||
steps: | ||
|
||
- name: Prepare the report | ||
id: compile | ||
shell: bash | ||
run: | | ||
REPORT=$(python ${{ github.action_path }}/script/cli.py --path ${{ inputs.path }}) | ||
echo "report<<EOF" >> $GITHUB_OUTPUT | ||
echo "${REPORT}" >> $GITHUB_OUTPUT | ||
echo "EOF" >> $GITHUB_OUTPUT |