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