From 325a8510c75b0b030be5ec075327ac337b7c22e5 Mon Sep 17 00:00:00 2001 From: Ziwen Ning Date: Fri, 28 Apr 2023 11:08:29 -0700 Subject: [PATCH] ci: add benchmarking workflow (#384) https://github.com/runfinch/finch/issues/345 *Description of changes:* *Testing done:* https://runfinch.github.io/finch/dev/bench/macOS/12/arm64/ https://runfinch.github.io/finch/dev/bench/macOS/12/x86_64/ https://runfinch.github.io/finch/dev/bench/macOS/13/arm64/ https://runfinch.github.io/finch/dev/bench/macOS/13/x86_64/ - [ X ] I've reviewed the guidance in CONTRIBUTING.md #### License Acceptance By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. Signed-off-by: Ziwen Ning --- .github/workflows/benchmark.yaml | 70 ++++++++++++++++++++++++++++++++ Makefile | 7 ++++ 2 files changed, 77 insertions(+) create mode 100644 .github/workflows/benchmark.yaml diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml new file mode 100644 index 000000000..4537dcaa4 --- /dev/null +++ b/.github/workflows/benchmark.yaml @@ -0,0 +1,70 @@ +# - When a third-party action is added (i.e., `uses`), please also add it to `download-licenses` in Makefile. +# - When a job is added/removed/renamed, please make corresponding changes in ci-docs.yaml. +name: Benchmark +on: + push: + branches: + - main + paths-ignore: + - '**.md' + - 'contrib/**' + +permissions: + # deployments permission to deploy GitHub pages website + deployments: write + # contents permission to update benchmark contents in gh-pages branch + contents: write + +jobs: + benchmark: + strategy: + fail-fast: false + matrix: + os: + [ + [self-hosted, macos, amd64, 13, test], + [self-hosted, macos, amd64, 12, test], + [self-hosted, macos, arm64, 13, test], + [self-hosted, macos, arm64, 12, test] + ] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + with: + # We need to get all the git tags to make version injection work. See VERSION in Makefile for more detail. + fetch-depth: 0 + submodules: true + - uses: actions/setup-go@v4 + - name: Clean up previous files + run: | + sudo rm -rf /opt/finch + sudo rm -rf ~/.finch + sudo rm -rf ./_output + if pgrep '^qemu-system'; then + sudo pkill '^qemu-system' + fi + if pgrep '^socket_vmnet'; then + sudo pkill '^socket_vmnet' + fi + - name: Install Rosetta 2 + run: echo "A" | softwareupdate --install-rosetta || true + - run: brew install go lz4 automake autoconf libtool + - name: Build project + run: | + export PATH="/opt/homebrew/opt/libtool/libexec/gnubin:$PATH" + make + - name: Run benchmark + run: make test-benchmark | tee benchmark.txt + - name: Set OS info as env variable + run: | + echo "OS_VERSION=$(sw_vers -productVersion | cut -d '.' -f 1)" >> $GITHUB_ENV + echo "ARCH=$(uname -m)" >> $GITHUB_ENV + - name: Store benchmark result + uses: benchmark-action/github-action-benchmark@v1 + with: + name: Finch Benchmark + tool: 'go' + benchmark-data-dir-path: "dev/bench/macOS/${{ env.OS_VERSION }}/${{ env.ARCH }}" + output-file-path: benchmark.txt + - name: Push benchmark result + run: git push 'https://github.com/runfinch/finch.git' gh-pages:gh-pages diff --git a/Makefile b/Makefile index 914eb9118..d70a40280 100644 --- a/Makefile +++ b/Makefile @@ -187,6 +187,13 @@ download-licenses: ### dependencies in tools.go - end ### + ### dependencies in benchmark.yaml - start ### + + mkdir -p "$(LICENSEDIR)/github.com/benchmark-action/github-action-benchmark" + curl https://raw.githubusercontent.com/benchmark-action/github-action-benchmark/master/LICENSE.txt --output "$(LICENSEDIR)/github.com/benchmark-action/github-action-benchmark/LICENSE.txt" + + ### dependencies in benchmark.yaml - end ### + ### dependencies in ci.yaml - start ### mkdir -p "$(LICENSEDIR)/github.com/actions/checkout"