-
Notifications
You must be signed in to change notification settings - Fork 37
128 lines (112 loc) · 4.64 KB
/
benchmark_parallel.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
122
123
124
125
126
127
128
name: Parallel Benchmark
on:
workflow_call:
inputs:
base-branch:
required: true
type: string
branch-prefix:
required: true
type: string
directories:
required: true
type: string
exclude-dirs:
required: false
type: string
default: ''
signing-key-id:
required: true
type: string
description: 'Signing key ID to use for signing commits'
secrets:
GPG_SIGNING_KEY:
required: true
GH_TOKEN:
required: true
LASTMJS_GITHUB_TOKEN:
required: true
jobs:
prepare-benchmark:
name: Prepare Benchmark
runs-on: ubuntu-latest
outputs:
test-infos: ${{ steps.get-test-infos.outputs.test-infos }}
version: ${{ steps.get-version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.base-branch }}
- id: get-version
run: |
VERSION="$(jq -r '.version' package.json)"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- id: get-test-infos
uses: ./.github/actions/get_test_infos
with:
directories: ${{ inputs.directories }}
exclude-dirs: ${{ inputs.exclude-dirs }}
run-benchmarks:
needs: prepare-benchmark
name: Run benchmarks for ${{ matrix.test.name }}
runs-on: ubuntu-latest
env:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
strategy:
fail-fast: false
matrix:
test: ${{ fromJson(needs.prepare-benchmark.outputs.test-infos) }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.base-branch }}
token: ${{ secrets.LASTMJS_GITHUB_TOKEN }}
- name: Report full path of test
# Just in case the path isn't obvious from the name, this will remove ambiguity
run: echo ${{matrix.test.path}}
- uses: ./.github/actions/setup_node
- uses: ./.github/actions/setup_dfx
- run: npm install
- run: npm link
- run: npm install
working-directory: ${{ matrix.test.path }}
- run: npm link azle
working-directory: ${{ matrix.test.path }}
- name: Start dfx with artificial delay 0
working-directory: ${{ matrix.test.path }}
run: dfx start --clean --background --host 127.0.0.1:8000 --artificial-delay 0
- name: Run npm test (continue on error)
id: record-benchmarks
working-directory: ${{ matrix.test.path }}
continue-on-error: true
run: AZLE_IDENTITY_STORAGE_MODE=plaintext AZLE_RECORD_BENCHMARKS=true npm test
- name: Handle test failure
working-directory: ${{ matrix.test.path }}
if: steps.record-benchmarks.outcome == 'failure'
run: |
echo "The benchmark test failed"
if [ -f benchmarks.md ]; then
# Create a temporary file with the failure message
echo "⚠️ **WARNING: Benchmark process failed for version ${{ needs.prepare-benchmark.outputs.version }}**" > temp.md
echo "" >> temp.md
# Append the original content
cat benchmarks.md >> temp.md
# Replace the original file
mv temp.md benchmarks.md
else
echo "⚠️ **WARNING: Benchmark process failed for version ${{ needs.prepare-benchmark.outputs.version }}**" > benchmarks.md
fi
- name: Create branch name
id: create-branch-name
uses: ./.github/actions/create_branch_name
with:
prefix: ${{ inputs.branch-prefix }}
path: ${{ matrix.test.displayPath }}
- uses: ./.github/actions/commit_and_push
with:
branch-name: ${{ steps.create-branch-name.outputs.branch-name }}
commit-message: 'Run benchmarks for ${{ matrix.test.displayPath }}'
gpg-signing-key: ${{ secrets.GPG_SIGNING_KEY }}
create-branch: 'true'
signing-key-id: ${{ inputs.signing-key-id }}