From ba5334a85721f67bb936de2e679030eafa41fe83 Mon Sep 17 00:00:00 2001 From: YigitElma Date: Fri, 23 Aug 2024 13:07:56 -0400 Subject: [PATCH] update the hash of the cache to have requirements.txt to account for dependency changes, change cache update time --- .github/workflows/benchmark.yml | 29 ++++++++++++++++++--------- .github/workflows/black.yml | 24 ++++++++++++++++------ .github/workflows/linting.yml | 8 ++++++-- .github/workflows/nbtests.yml | 12 +++++++++-- .github/workflows/pythonpip.yml | 13 +++++++++--- .github/workflows/regression_test.yml | 12 +++++++++-- .github/workflows/unittest.yml | 12 +++++++++-- 7 files changed, 84 insertions(+), 26 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index dbb80cc4a..7ab698aee 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -22,6 +22,9 @@ concurrency: jobs: benchmark: runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.9'] steps: # Enable tmate debugging of manually-triggered workflows if the input option was provided @@ -32,23 +35,31 @@ jobs: with: ref: ${{ github.event.pull_request.head.sha }} - - name: Set up Python 3.9 + - name: Set up Python uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: ${{ matrix.python-version }} - 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') }} + path: .venv-${{ matrix.python-version }} + key: ${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('devtools/dev-requirements.txt') }}--${{ hashFiles('requirements.txt') }} restore-keys: | - ${{ runner.os }}-venv-3.9- + ${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('devtools/dev-requirements.txt') }}--${{ hashFiles('requirements.txt') }} + + - name: Set up virtual environment if not restored from cache + if: steps.restore-env.outputs.cache-hit != 'true' + run: | + python -m venv .venv-${{ matrix.python-version }} + source .venv-${{ matrix.python-version }}/bin/activate + python -m pip install --upgrade pip + pip install -r devtools/dev-requirements.txt - name: Benchmark with pytest-benchmark run: | - source .venv-3.9/bin/activate + source .venv-${{ matrix.python-version }}/bin/activate pwd lscpu cd tests/benchmarks @@ -67,7 +78,7 @@ jobs: run: git checkout ${{ github.event.pull_request.head.sha }} -- tests/benchmarks - name: Benchmark with pytest-benchmark run: | - source .venv-3.9/bin/activate + source .venv-${{ matrix.python-version }}/bin/activate pwd lscpu cd tests/benchmarks @@ -78,7 +89,7 @@ jobs: - name: put benchmark results in same folder run: | - source .venv-3.9/bin/activate + source .venv-${{ matrix.python-version }}/bin/activate pwd cd tests/benchmarks find .benchmarks/ -type f -printf "%T@ %p\n" | sort -n | cut -d' ' -f 2- | tail -n 1 > temp1 @@ -91,7 +102,7 @@ jobs: - name: Compare latest commit results to the master branch results run: | - source .venv-3.9/bin/activate + source .venv-${{ matrix.python-version }}/bin/activate pwd cd tests/benchmarks python compare_bench_results.py diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml index 92b3e6360..9961e1199 100644 --- a/.github/workflows/black.yml +++ b/.github/workflows/black.yml @@ -6,25 +6,37 @@ jobs: black_format: runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.10'] + steps: - uses: actions/checkout@v4 - - name: Set up Python 3.10 + - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.10' + python-version: ${{ matrix.python-version }} - name: Restore Python environment cache id: restore-env uses: actions/cache/restore@v4 with: - path: .venv-3.10 - key: ${{ runner.os }}-venv-3.10-${{ hashFiles('devtools/dev-requirements.txt') }} + path: .venv-${{ matrix.python-version }} + key: ${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('devtools/dev-requirements.txt') }}--${{ hashFiles('requirements.txt') }} restore-keys: | - ${{ runner.os }}-venv-3.10- + ${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('devtools/dev-requirements.txt') }}--${{ hashFiles('requirements.txt') }} + + - name: Set up virtual environment if not restored from cache + if: steps.restore-env.outputs.cache-hit != 'true' + run: | + python -m venv .venv-${{ matrix.python-version }} + source .venv-${{ matrix.python-version }}/bin/activate + python -m pip install --upgrade pip + pip install -r devtools/dev-requirements.txt - name: Check files using the black formatter run: | - source .venv-3.10/bin/activate + source .venv-${{ matrix.python-version }}/bin/activate black --version black --check desc/ tests/ || black_return_code=$? echo "BLACK_RETURN_CODE=$black_return_code" >> $GITHUB_ENV diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 60e7ac31f..2eef77dcc 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -5,13 +5,17 @@ on: [pull_request, workflow_dispatch] jobs: flake8_linting: runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.10'] + name: Linting steps: - uses: actions/checkout@v4 - - name: Set up Python 3.10 + - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.10' + python-version: ${{ matrix.python-version }} # For some reason, loading venv makes this way slower - name: Install dependencies diff --git a/.github/workflows/nbtests.yml b/.github/workflows/nbtests.yml index af1f647ca..b4155101a 100644 --- a/.github/workflows/nbtests.yml +++ b/.github/workflows/nbtests.yml @@ -36,9 +36,17 @@ jobs: uses: actions/cache/restore@v4 with: path: .venv-${{ matrix.python-version }} - key: ${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('devtools/dev-requirements.txt') }} + key: ${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('devtools/dev-requirements.txt') }}--${{ hashFiles('requirements.txt') }} restore-keys: | - ${{ runner.os }}-venv-${{ matrix.python-version }}- + ${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('devtools/dev-requirements.txt') }}--${{ hashFiles('requirements.txt') }} + + - name: Set up virtual environment if not restored from cache + if: steps.restore-env.outputs.cache-hit != 'true' + run: | + python -m venv .venv-${{ matrix.python-version }} + source .venv-${{ matrix.python-version }}/bin/activate + python -m pip install --upgrade pip + pip install -r devtools/dev-requirements.txt - name: Test notebooks with pytest and nbmake run: | diff --git a/.github/workflows/pythonpip.yml b/.github/workflows/pythonpip.yml index a4dd1ff62..8a3f03586 100644 --- a/.github/workflows/pythonpip.yml +++ b/.github/workflows/pythonpip.yml @@ -3,8 +3,15 @@ name: Cache Python and pip dependencies # and pip dependencies cache on: + push: # TODO: remove while merging + branches: + - master + - dev + pull_request: + branches: + - master schedule: - - cron: '0 0 */2 * *' # This triggers the workflow every 2 days at midnight + - cron: '30 4 */2 * *' # This triggers the workflow at 4:30 AM every 2 days workflow_dispatch: jobs: @@ -27,9 +34,9 @@ jobs: uses: actions/cache@v3 with: path: ./.venv-${{ matrix.python-version }} - key: ${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('devtools/dev-requirements.txt') }} + key: ${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('devtools/dev-requirements.txt') }}--${{ hashFiles('requirements.txt') }} restore-keys: | - ${{ runner.os }}-venv-${{ matrix.python-version }}- + ${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('devtools/dev-requirements.txt') }}--${{ hashFiles('requirements.txt') }} - name: Set up virtual environment run: | diff --git a/.github/workflows/regression_test.yml b/.github/workflows/regression_test.yml index 4a6610879..cafdbd24c 100644 --- a/.github/workflows/regression_test.yml +++ b/.github/workflows/regression_test.yml @@ -35,9 +35,17 @@ jobs: uses: actions/cache/restore@v4 with: path: .venv-${{ matrix.python-version }} - key: ${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('devtools/dev-requirements.txt') }} + key: ${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('devtools/dev-requirements.txt') }}--${{ hashFiles('requirements.txt') }} restore-keys: | - ${{ runner.os }}-venv-${{ matrix.python-version }}- + ${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('devtools/dev-requirements.txt') }}--${{ hashFiles('requirements.txt') }} + + - name: Set up virtual environment if not restored from cache + if: steps.restore-env.outputs.cache-hit != 'true' + run: | + python -m venv .venv-${{ matrix.python-version }} + source .venv-${{ matrix.python-version }}/bin/activate + python -m pip install --upgrade pip + pip install -r devtools/dev-requirements.txt - name: Set Swap Space uses: pierotofy/set-swap-space@master diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index fff6be4c7..eeaf53190 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -41,9 +41,17 @@ jobs: 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') }} + key: ${{ runner.os }}-venv-${{ matrix.combos.python_version }}-${{ hashFiles('devtools/dev-requirements.txt') }}--${{ hashFiles('requirements.txt') }} restore-keys: | - ${{ runner.os }}-venv-${{ matrix.combos.python_version }}- + ${{ runner.os }}-venv-${{ matrix.combos.python_version }}-${{ hashFiles('devtools/dev-requirements.txt') }}--${{ hashFiles('requirements.txt') }} + + - name: Set up virtual environment if not restored from cache + if: steps.restore-env.outputs.cache-hit != 'true' + run: | + python -m venv .venv-${{ matrix.combos.python_version }} + source .venv-${{ matrix.combos.python_version }}/bin/activate + python -m pip install --upgrade pip + pip install -r devtools/dev-requirements.txt - name: Set Swap Space uses: pierotofy/set-swap-space@master