-
Notifications
You must be signed in to change notification settings - Fork 345
121 lines (114 loc) · 4.77 KB
/
performance.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: Performance tests
on:
workflow_call:
inputs:
go-version:
required: true
type: string
schedule:
- cron: '0 0 * * *'
jobs:
performance-test-suite-detect-runners:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.detect-runners.outputs.matrix }}
env:
PERF_TEST_RUNS_ON: ${{ secrets.PERF_TEST_RUNS_ON }}
PERF_TEST_RUNS_ON_DEFAULT: |
{
"targets": [
{
"name": "github-ubuntu-latest",
"runs-on": "ubuntu-latest"
}
]
}
steps:
- id: detect-runners
run: |
RES="$(echo "${PERF_TEST_RUNS_ON:-${PERF_TEST_RUNS_ON_DEFAULT}}" | jq -c '.targets')"
echo "Detected targets:"
echo "$RES" | jq .
echo "matrix=${RES}" >> $GITHUB_OUTPUT
performance-test-suite:
name: Performance Test Suite (${{ matrix.target.name }})
needs:
- performance-test-suite-detect-runners
strategy:
matrix:
target: ${{ fromJson(needs.performance-test-suite-detect-runners.outputs.matrix) }}
runs-on: ${{ matrix.target.runs-on }}
env:
ARG_DURATION: "${{ startsWith(github.ref, 'refs/tags/v') && '-d 2m' || '' }}"
INFLUX_HOST: ${{ secrets.INFLUX_HOST }}
INFLUX_TOKEN: ${{ secrets.INFLUX_TOKEN }}
steps:
- uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go-version }}
- uses: actions/checkout@v4
- run: go build -o perf-test-suite ./test/performance-test-suite/cmd/perf-test/
- name: Run performance tests
id: performance
run: |
echo "version=$(cat Makefile | grep '\<VERSION=' | awk -F= '{print $2}' | tr -d [\',])" >> $GITHUB_ENV
SECONDS=0
./perf-test-suite $ARG_DURATION -workdir /var/tmp -host $INFLUX_HOST -token $INFLUX_TOKEN -runner ${{ matrix.target.name }} -version $(cat Makefile | grep '\<VERSION=' | awk -F= '{print $2}' | tr -d [\',]) > perf-test-results-with-summaries.txt
echo "duration=$SECONDS" >> $GITHUB_ENV
sed '/^{/,/^}/!d' perf-test-results-with-summaries.txt > perf-test-results.json
env:
GOMEMLIMIT: 7680MiB
- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: Performance Test Results (${{ matrix.target.name }})
path: perf-test-results.json
retention-days: 30
- name: Create the Mattermost message
if: github.event.schedule == '0 0 * * *'
run: >
echo "{\"text\":\"### Performance tests results for scheduled daily run on ${{ github.ref_name }} branch and ${{ matrix.target.name }} runner\n
**Result**: ${{ steps.performance.outcome }}\n
**Duration**: ${{ env.duration }}s | **immudb version**: ${{ env.version }}\n
$(jq -r '.benchmarks[] | .name + "\n" + .summary' perf-test-results.json) \n
**Check details [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})**
\"}" > mattermost.json && echo MM_PAYLOAD=$(cat mattermost.json) >> $GITHUB_ENV
- name: Notify on immudb channel on Mattermost
if: github.event.schedule == '0 0 * * *'
uses: mattermost/action-mattermost-notify@master
with:
MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }}
MATTERMOST_CHANNEL: 'immudb-tests'
PAYLOAD: ${{ env.MM_PAYLOAD }}
performance-test-suite-upload-s3:
if: github.event.schedule != '0 0 * * *'
needs:
- performance-test-suite
- performance-test-suite-detect-runners
runs-on: ubuntu-latest
strategy:
matrix:
target: ${{ fromJson(needs.performance-test-suite-detect-runners.outputs.matrix) }}
env:
PERF_TEST_AWS_REGION: ${{ secrets.PERF_TEST_AWS_REGION }}
steps:
- uses: actions/checkout@v4
- name: Download test results
if: "${{ env.PERF_TEST_AWS_REGION }}"
uses: actions/download-artifact@v4
with:
name: Performance Test Results (${{ matrix.target.name }})
- name: Configure AWS credentials
if: "${{ env.PERF_TEST_AWS_REGION }}"
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: "${{ secrets.PERF_TEST_AWS_ACCESS_KEY_ID }}"
aws-secret-access-key: "${{ secrets.PERF_TEST_AWS_SECRET_ACCESS_KEY }}"
aws-region: "${{ secrets.PERF_TEST_AWS_REGION }}"
- name: Upload perf results to S3
if: "${{ env.PERF_TEST_AWS_REGION }}"
run: |
GIT_COMMIT_NAME="$(git show -s --format=%cd --date="format:%Y-%m-%d--%H-%I-%S")--$(git rev-parse HEAD)"
aws s3 cp \
perf-test-results.json \
"s3://${{ secrets.PERF_TEST_AWS_BUCKET_PREFIX }}/${{ github.ref_name }}/${GIT_COMMIT_NAME}/${{ matrix.target.name }}.json"