1+ name : Visualize Benchmark and upload results
2+
3+ on :
4+ push :
5+ branches : [ main ]
6+ paths :
7+ - ' **'
8+ - ' !docs/**' # ignore docs changes
9+ - ' !**.md' # ignore markdown changes
10+
11+ permissions :
12+ contents : write
13+ deployments : write
14+
15+ jobs :
16+ benchmark :
17+ runs-on : ubuntu-20.04
18+ steps :
19+ - name : Checkout main branch
20+ uses : actions/checkout@v3
21+ with :
22+ fetch-depth : 0
23+ submodules : true
24+ - uses : actions/setup-go@v4
25+ with :
26+ go-version : ' 1.20.6'
27+ - run : make
28+ - name : Run benchmark
29+ run : make benchmarks-perf-test
30+ - name : Upload latest benchmark result
31+ uses : actions/upload-artifact@v3
32+ with :
33+ name : benchmark-result-artifact
34+ path : ${{github.workspace}}/benchmark/performanceTest/output/results.json
35+
36+ download-and-convert-benchmark-result-to-visualization-data :
37+ runs-on : ubuntu-20.04
38+ needs : benchmark
39+ steps :
40+ - name : Checkout main branch
41+ uses : actions/checkout@v3
42+ - name : Download latest benchmark result
43+ uses : actions/download-artifact@v3
44+ with :
45+ name : benchmark-result-artifact
46+ path : ${{github.workspace}}
47+ - name : Make temporary folder
48+ run : mkdir ${{github.workspace}}/current
49+ - name : Change permission of visualization_data_converter.sh
50+ run : chmod +x ${{github.workspace}}/scripts/visualization_data_converter.sh
51+ - name : Convert benchmark result to visualization data
52+ run : ${{github.workspace}}/scripts/visualization_data_converter.sh ${{github.workspace}}/results.json ${{github.workspace}}/current
53+ - name : Build matrix of filepaths
54+ id : set-matrix
55+ # Create a JSON array with the file paths and store it in the 'files' output
56+ run : echo "files=$(find ${{github.workspace}}/current -type f -name '*.json' -printf '%p\n' | jq -R . | jq -cs .)" >> $GITHUB_OUTPUT
57+ - name : Upload visualization files as github artifacts
58+ uses : actions/upload-artifact@v3
59+ with :
60+ name : benchmark-gh-pages-artifact
61+ path : ${{github.workspace}}/current
62+ outputs :
63+ matrix : ${{ steps.set-matrix.outputs.files }}
64+
65+ push-benchmark-result-gh-pages :
66+ name : Push benchmark result to Github-pages
67+ runs-on : ubuntu-20.04
68+ needs : download-and-convert-benchmark-result-to-visualization-data
69+ strategy :
70+ matrix :
71+ file : ${{ fromJson(needs.download-and-convert-benchmark-result-to-visualization-data.outputs.matrix) }}
72+ steps :
73+ - name : Checkout main branch
74+ uses : actions/checkout@v3
75+
76+ - name : Create current folder
77+ run : mkdir ${{github.workspace}}/current
78+
79+ - name : Download latest benchmark visualization files
80+ uses : actions/download-artifact@v3
81+ with :
82+ name : benchmark-gh-pages-artifact
83+ path : ${{github.workspace}}/current
84+
85+ - name : Extract file names
86+ id : get_filename
87+ run : |
88+ # Get the filename without the path
89+ filename=$(basename "${{ matrix.file }}")
90+ # Remove the .json extension
91+ filename_without_extension="${filename%.json}"
92+ echo "filename=$filename_without_extension" >> $GITHUB_OUTPUT
93+
94+ - name : Run benchmark action
95+ uses : benchmark-action/github-action-benchmark@v1
96+ with :
97+ name : Soci Benchmark
98+ tool : ' customSmallerIsBetter'
99+ benchmark-data-dir-path : " dev/benchmarks/performanceTest/${{ steps.get_filename.outputs.filename }}"
100+ output-file-path : ${{ matrix.file }}
101+ github-token : ${{ secrets.GITHUB_TOKEN }}
102+ auto-push : true
0 commit comments