From 590a41290c1b61fe42d47d8b5d35b3d31931e9f1 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Tue, 7 Feb 2023 14:25:10 -0700 Subject: [PATCH] CI: cache pip installs (#1057) * CI: cache pip installs * Update to new min deps filename * Use cache action instead * Cache releases too --- .github/workflows/release.yaml | 21 ++++++++++++++++++++ .github/workflows/style.yaml | 35 ++++++++++++++++++++++++++++++++++ .github/workflows/tests.yaml | 21 ++++++++++++++++++++ 3 files changed, 77 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 3f7cee5b112..9fbe752cafb 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -17,7 +17,14 @@ jobs: uses: actions/setup-python@v4.5.0 with: python-version: '3.10' + - name: Cache dependencies + uses: actions/cache@v3.2.4 + id: cache + with: + path: ${{ env.pythonLocation }} + key: ${{ env.pythonLocation }}-${{ hashFiles('setup.cfg') }} - name: Install pip dependencies + if: steps.cache.outputs.cache-hit != 'true' run: | pip install .[tests] pip list @@ -33,7 +40,14 @@ jobs: uses: actions/setup-python@v4.5.0 with: python-version: '3.10' + - name: Cache dependencies + uses: actions/cache@v3.2.4 + id: cache + with: + path: ${{ env.pythonLocation }} + key: ${{ env.pythonLocation }}-${{ hashFiles('setup.cfg') }} - name: Install pip dependencies + if: steps.cache.outputs.cache-hit != 'true' run: | pip install .[datasets,tests] pip list @@ -49,7 +63,14 @@ jobs: uses: actions/setup-python@v4.5.0 with: python-version: '3.10' + - name: Cache dependencies + uses: actions/cache@v3.2.4 + id: cache + with: + path: ${{ env.pythonLocation }} + key: ${{ env.pythonLocation }}-${{ hashFiles('setup.cfg') }} - name: Install pip dependencies + if: steps.cache.outputs.cache-hit != 'true' run: | pip install .[datasets,docs,tests] pip list diff --git a/.github/workflows/style.yaml b/.github/workflows/style.yaml index 0747a890bad..01fe92463f6 100644 --- a/.github/workflows/style.yaml +++ b/.github/workflows/style.yaml @@ -19,7 +19,14 @@ jobs: uses: actions/setup-python@v4.5.0 with: python-version: '3.10' + - name: Cache dependencies + uses: actions/cache@v3.2.4 + id: cache + with: + path: ${{ env.pythonLocation }} + key: ${{ env.pythonLocation }}-${{ hashFiles('requirements/style.txt') }} - name: Install pip dependencies + if: steps.cache.outputs.cache-hit != 'true' run: | pip install -r requirements/style.txt pip list @@ -35,7 +42,14 @@ jobs: uses: actions/setup-python@v4.5.0 with: python-version: '3.10' + - name: Cache dependencies + uses: actions/cache@v3.2.4 + id: cache + with: + path: ${{ env.pythonLocation }} + key: ${{ env.pythonLocation }}-${{ hashFiles('requirements/style.txt') }} - name: Install pip dependencies + if: steps.cache.outputs.cache-hit != 'true' run: | pip install -r requirements/style.txt pip list @@ -51,7 +65,14 @@ jobs: uses: actions/setup-python@v4.5.0 with: python-version: '3.10' + - name: Cache dependencies + uses: actions/cache@v3.2.4 + id: cache + with: + path: ${{ env.pythonLocation }} + key: ${{ env.pythonLocation }}-${{ hashFiles('requirements/style.txt') }} - name: Install pip dependencies + if: steps.cache.outputs.cache-hit != 'true' run: | pip install -r requirements/style.txt pip list @@ -67,7 +88,14 @@ jobs: uses: actions/setup-python@v4.5.0 with: python-version: '3.10' + - name: Cache dependencies + uses: actions/cache@v3.2.4 + id: cache + with: + path: ${{ env.pythonLocation }} + key: ${{ env.pythonLocation }}-${{ hashFiles('requirements/style.txt') }} - name: Install pip dependencies + if: steps.cache.outputs.cache-hit != 'true' run: | pip install -r requirements/style.txt pip list @@ -83,7 +111,14 @@ jobs: uses: actions/setup-python@v4.5.0 with: python-version: '3.10' + - name: Cache dependencies + uses: actions/cache@v3.2.4 + id: cache + with: + path: ${{ env.pythonLocation }} + key: ${{ env.pythonLocation }}-${{ hashFiles('requirements/style.txt') }} - name: Install pip dependencies + if: steps.cache.outputs.cache-hit != 'true' run: | pip install -r requirements/style.txt pip list diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 3cb80fd4bca..5156ad8d091 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -19,7 +19,14 @@ jobs: uses: actions/setup-python@v4.5.0 with: python-version: '3.10' + - name: Cache dependencies + uses: actions/cache@v3.2.4 + id: cache + with: + path: ${{ env.pythonLocation }} + key: ${{ env.pythonLocation }}-${{ hashFiles('requirements/required.txt') }}-${{ hashFiles('requirements/datasets.txt') }}-${{ hashFiles('requirements/tests.txt') }} - name: Install pip dependencies + if: steps.cache.outputs.cache-hit != 'true' run: | pip install -r requirements/required.txt -r requirements/datasets.txt -r requirements/tests.txt pip list @@ -41,6 +48,12 @@ jobs: uses: actions/setup-python@v4.5.0 with: python-version: ${{ matrix.python-version }} + - name: Cache dependencies + uses: actions/cache@v3.2.4 + id: cache + with: + path: ${{ env.pythonLocation }} + key: ${{ env.pythonLocation }}-${{ hashFiles('requirements/required.txt') }}-${{ hashFiles('requirements/datasets.txt') }}-${{ hashFiles('requirements/tests.txt') }} - name: Setup headless display for pyvista uses: pyvista/setup-headless-display-action@v1 - name: Install apt dependencies (Linux) @@ -58,6 +71,7 @@ jobs: pacman -S --noconfirm --needed unrar if: ${{ runner.os == 'Windows' }} - name: Install pip dependencies + if: steps.cache.outputs.cache-hit != 'true' run: | pip install -r requirements/required.txt -r requirements/datasets.txt -r requirements/tests.txt pip list @@ -86,11 +100,18 @@ jobs: uses: actions/setup-python@v4.5.0 with: python-version: '3.8' + - name: Cache dependencies + uses: actions/cache@v3.2.4 + id: cache + with: + path: ${{ env.pythonLocation }} + key: ${{ env.pythonLocation }}-${{ hashFiles('requirements/min-reqs.old') }}-${{ hashFiles('requirements/mins-cons.old') }} - name: Install apt dependencies (Linux) run: | sudo apt-get update sudo apt-get install unrar - name: Install pip dependencies + if: steps.cache.outputs.cache-hit != 'true' run: | pip install -r requirements/min-reqs.old -c requirements/min-cons.old pip list