From 70f9bbbb9da8d41929ce1bcb9d83d58b38dbb48a Mon Sep 17 00:00:00 2001 From: ringsaturn Date: Thu, 21 Mar 2024 22:13:05 +0800 Subject: [PATCH] try bencher --- .github/workflows/Bench.yml | 44 +++++++++++++++++++++++++++++++++++++ .github/workflows/CI.yml | 4 ++++ 2 files changed, 48 insertions(+) create mode 100644 .github/workflows/Bench.yml diff --git a/.github/workflows/Bench.yml b/.github/workflows/Bench.yml new file mode 100644 index 0000000..a35bef4 --- /dev/null +++ b/.github/workflows/Bench.yml @@ -0,0 +1,44 @@ +name: Bench + +on: + push: + branches: + - main + +jobs: + benchmark_with_bencher: + name: Continuous Benchmarking with Bencher + runs-on: ubuntu-latest + env: + BENCHER_PROJECT: tzfpy + BENCHER_TESTBED: ubuntu-latest + BENCHER_ADAPTER: json + steps: + - uses: actions/checkout@v4 + + - uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.12 + + - name: Create virtual environment + run: | + python -m venv venv + + - uses: bencherdev/bencher@main + + - name: Install tzfpy and test + shell: bash + run: | + source venv/bin/activate + pip install --upgrade pip + pip install -r requirements_dev.txt + maturin develop --release --extras=pytz + pytest | tee benchmark_result.txt + bencher run \ + --branch "$GITHUB_REF_NAME" \ + --token "${{ secrets.BENCHER_API_TOKEN }}" \ + --err \ + "pytest --benchmark-json results.json tests/test_bench.py" diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 5bf14a5..2b8e3d5 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -8,6 +8,10 @@ on: - "*.*.*" pull_request: +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: linux: runs-on: ubuntu-latest