From c68f7cd7c8dd7e97160f9029835bb09e5871e328 Mon Sep 17 00:00:00 2001 From: Moritz-Alexander-Kern Date: Wed, 18 Oct 2023 09:36:06 +0200 Subject: [PATCH] add benchmark to CI --- .github/workflows/CI.yml | 57 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index bbded6a4d..e3e41deb7 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -477,3 +477,60 @@ jobs: run: | source ~/test_env/bin/activate pytest elephant --doctest-modules --ignore=elephant/test/ + + # install dependencies and elephant with pip and run tests with pytest + benchmark: + runs-on: ${{ matrix.os }} + strategy: + matrix: + # python versions for elephant: [3.8, 3.9, "3.10", 3.11] + python-version: [3.11] + # OS [ubuntu-latest, macos-latest, windows-latest] + os: [ubuntu-latest] + # do not cancel all in-progress jobs if any matrix job fails + fail-fast: false + + steps: + # used to reset cache every month + - name: Get current year-month + id: date + run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT + + - uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: '**/requirements.txt' + + - name: Cache test_env + uses: actions/cache@v3 + with: + path: /home/runner/.benchmarks + # Look to see if there is a cache hit for the corresponding requirements files + # cache will be reset on changes to any requirements or every month + key: ${{ runner.os }}-venv-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/requirements-tests.txt') }} + -${{ hashFiles('**/requirements-extras.txt') }}-${{ hashFiles('**/CI.yml') }}-${{ hashFiles('setup.py') }} + -${{ steps.date.outputs.date }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install coveralls + pip install -r requirements/requirements-tests.txt + pip install -r requirements/requirements.txt + pip install -r requirements/requirements-extras.txt + pip install -e . + + - name: List packages + run: | + pip list + python --version + + - name: Benchmark with pytest-benchmark + run: | + pytest --benchmark-only --benchmark-compare --benchmark-autosave + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}