From 810ad6194587faadcc188563c0f5ca05473a04e3 Mon Sep 17 00:00:00 2001 From: Egil Martinsson Date: Sat, 18 Jan 2025 21:53:17 -0800 Subject: [PATCH] GA actions cache of full env (90->30s) (#26) * Attempt to create cache * [perf] --- .github/workflows/tests.yml | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f516cd5..2f62ad7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,23 +11,37 @@ jobs: runs-on: ubuntu-22.04 steps: - - name: Checkout code + - name: Check out the code uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.12' - cache: 'pip' - - - name: Install dependencies + + - name: Cache virtual environment + uses: actions/cache@v3 + id: cache-venv + with: + path: venv + key: ${{ runner.os }}-venv-${{ hashFiles('requirements*.txt') }} + restore-keys: ${{ runner.os }}-venv- + + - name: Install dependencies (only if no cache hit) + if: steps.cache-venv.outputs.cache-hit != 'true' run: | + python -m venv venv + . venv/bin/activate python -m pip install --upgrade pip pip install -r requirements.txt -r requirements-dev.txt - name: Run tests - run: pytest -vvrP test.py + run: | + . venv/bin/activate + pytest -vvrP test.py - name: Run performance tests if: contains(github.event.head_commit.message, '[perf]') - run: python test_performance.py \ No newline at end of file + run: | + . venv/bin/activate + python test_performance.py