diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index ad00eeef5d..5f7e0994d4 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -31,14 +31,31 @@ jobs: - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} + - name: Set up Python 3.9 uses: actions/setup-python@v5 with: python-version: 3.9 - - name: Install dependencies + + - name: Restore Python environment cache + id: restore-env + uses: actions/cache/restore@v4 + with: + path: .venv-3.9 + key: ${{ runner.os }}-venv-3.9-${{ hashFiles('devtools/dev-requirements.txt') }} + restore-keys: | + ${{ runner.os }}-venv-3.9- + + - name: Check if virtual environment exists + if: steps.restore-env.outputs.cache-hit != 'true' run: | - python -m pip install --upgrade pip - pip install -r devtools/dev-requirements.txt + echo "Error: Virtual environment .venv-3.9 not found!" + exit 1 + + - name: Activate virtual environment + run: | + source .venv-3.9/bin/activate + - name: Benchmark with pytest-benchmark run: | pwd @@ -48,11 +65,13 @@ jobs: --benchmark-save='Latest_Commit' \ --durations=0 \ --benchmark-save-data + - name: Checkout current master uses: actions/checkout@v4 with: ref: master clean: false + - name: Checkout benchmarks from PR head run: git checkout ${{ github.event.pull_request.head.sha }} -- tests/benchmarks - name: Benchmark with pytest-benchmark @@ -64,6 +83,7 @@ jobs: --benchmark-save='master' \ --durations=0 \ --benchmark-save-data + - name: put benchmark results in same folder run: | pwd @@ -75,12 +95,14 @@ jobs: mkdir compare_results cp $t1 compare_results cp $t2 compare_results + - name: Compare latest commit results to the master branch results run: | pwd cd tests/benchmarks python compare_bench_results.py cat commit_msg.txt + - name: comment PR with the results uses: thollander/actions-comment-pull-request@v2 env: @@ -88,6 +110,7 @@ jobs: with: filePath: tests/benchmarks/commit_msg.txt comment_tag: benchmark + - name: Upload benchmark data if: always() uses: actions/upload-artifact@v4 diff --git a/.github/workflows/nbtests.yml b/.github/workflows/nbtests.yml index 7a588aae1f..4656e6d738 100644 --- a/.github/workflows/nbtests.yml +++ b/.github/workflows/nbtests.yml @@ -30,9 +30,26 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + + - name: Restore Python environment cache + id: restore-env + uses: actions/cache/restore@v4 + with: + path: .venv-${{ matrix.python-version }} + key: ${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('devtools/dev-requirements.txt') }} + restore-keys: | + ${{ runner.os }}-venv-${{ matrix.python-version }}- + + - name: Check if virtual environment exists + if: steps.restore-env.outputs.cache-hit != 'true' + run: | + echo "Error: Virtual environment .venv-${{ matrix.python-version }} not found!" + exit 1 + - name: Activate virtual environment run: | source .venv-${{ matrix.python-version }}/bin/activate + - name: Test notebooks with pytest and nbmake run: | source .venv-${{ matrix.python-version }}/bin/activate diff --git a/.github/workflows/regression_test.yml b/.github/workflows/regression_test.yml index f220fcbcda..4da96f49ab 100644 --- a/.github/workflows/regression_test.yml +++ b/.github/workflows/regression_test.yml @@ -29,6 +29,7 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + - name: Restore Python environment cache id: restore-env uses: actions/cache/restore@v4 @@ -52,6 +53,7 @@ jobs: uses: pierotofy/set-swap-space@master with: swap-size-gb: 10 + - name: Test with pytest run: | source .venv-${{ matrix.python-version }}/bin/activate @@ -69,6 +71,7 @@ jobs: --group ${{ matrix.group }} \ --splitting-algorithm least_duration \ --db ./prof.db + - name: save coverage file and plot comparison results if: always() uses: actions/upload-artifact@v4 @@ -78,6 +81,7 @@ jobs: ./cov.xml ./mpl_results.html ./prof.db + - name: Upload coverage id : codecov uses: Wandalen/wretry.action@v1.3.0 diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index e513960122..d1517e2724 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -35,13 +35,31 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.combos.python_version }} + + - name: Restore Python environment cache + id: restore-env + uses: actions/cache/restore@v4 + with: + path: .venv-${{ matrix.combos.python_version }} + key: ${{ runner.os }}-venv-${{ matrix.combos.python_version }}-${{ hashFiles('devtools/dev-requirements.txt') }} + restore-keys: | + ${{ runner.os }}-venv-${{ matrix.combos.python_version }}- + + - name: Check if virtual environment exists + if: steps.restore-env.outputs.cache-hit != 'true' + run: | + echo "Error: Virtual environment .venv-${{ matrix.combos.python_version }} not found!" + exit 1 + - name: Activate virtual environment run: | source .venv-${{ matrix.combos.python_version }}/bin/activate + - name: Set Swap Space uses: pierotofy/set-swap-space@master with: swap-size-gb: 10 + - name: Test with pytest run: | pwd @@ -58,6 +76,7 @@ jobs: --group ${{ matrix.combos.group }} \ --splitting-algorithm least_duration \ --db ./prof.db + - name: save coverage file and plot comparison results if: always() uses: actions/upload-artifact@v4 @@ -67,6 +86,7 @@ jobs: ./cov.xml ./mpl_results.html ./prof.db + - name: Upload coverage id : codecov uses: Wandalen/wretry.action@v1.3.0