From 9d95787388212696ebaac3c624957e8da1f8c6a9 Mon Sep 17 00:00:00 2001 From: mgoerens <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 14 Nov 2024 09:59:28 +0100 Subject: [PATCH] Cache virtualenv between jobs Installation of the python dependencies and scripts is done at the start of each job within the build.yaml workflow. By caching the venv we can save up to 10 seconds on each job after the first. With the planned re-introduction of #392 that splits the chart-verifier job into 3, this can scale to up to a total of 40s per run. Signed-off-by: Matthias Goerens --- .github/workflows/build.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 11a79c3c..e7da6110 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,6 +22,7 @@ jobs: uses: actions/checkout@v4 - name: Set up Python 3.x Part 1 + id: setup_python uses: actions/setup-python@v5 with: python-version: "3.10" @@ -35,6 +36,12 @@ jobs: ../ve1/bin/pip3 install . cd .. + - name: Saved cached virtualenv + uses: actions/cache/save@v4 + with: + key: venv-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('scripts/requirements.txt') }} + path: ve1 + - name: Check for CI changes id: check_ci_changes env: @@ -124,10 +131,17 @@ jobs: path: "pr-branch" - name: Set up Python 3.x Part 1 + id: setup_python uses: actions/setup-python@v5 with: python-version: "3.10" + - name: Restore cached virtualenv + uses: actions/cache/restore@v4 + with: + key: venv-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('scripts/requirements.txt') }} + path: ve1 + - name: Set up Python 3.x Part 2 run: | # set up python @@ -429,10 +443,17 @@ jobs: path: "pr-branch" - name: Set up Python 3.x Part 1 + id: setup_python uses: actions/setup-python@v5 with: python-version: "3.10" + - name: Restore cached virtualenv + uses: actions/cache/restore@v4 + with: + key: venv-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('scripts/requirements.txt') }} + path: ve1 + - name: Set up Python 3.x Part 2 run: | # set up python