From 5f3cb0237f9ca8a3e501df3165f87e18a60c1638 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 | 45 +++++++++++++++++++++++++++++++++++++ .github/workflows/CI.yml | 4 ++++ 2 files changed, 49 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..5ff165b --- /dev/null +++ b/.github/workflows/Bench.yml @@ -0,0 +1,45 @@ +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 + 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 \ + --file results.json \ + --branch "$GITHUB_REF_NAME" \ + --token "${{ secrets.BENCHER_API_TOKEN }}" \ + --adapter python_pytest \ + --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