Skip to content

Commit 1b18ef1

Browse files
committed
python venv cache support
1 parent a3ed755 commit 1b18ef1

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

.github/workflows/self-test.yml

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ jobs:
5757
with:
5858
style: file
5959
files-changed-only: false
60+
cache: true
6061
# to ignore all build folder contents
6162
ignore: build|venv
6263
database: build

action.yml

+18
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ inputs:
5555
[re-running jobs or workflows](https://docs.github.com/en/actions/managing-workflow-runs/re-running-workflows-and-jobs).
5656
required: false
5757
default: info
58+
cache:
59+
description: |
60+
This controls if the python virtual environment is cached.
61+
required: false
62+
default: false
5863
lines-changed-only:
5964
description: |
6065
This controls what part of the files are analyzed. The following values are accepted:
@@ -234,6 +239,19 @@ runs:
234239
fi
235240
fi
236241
242+
- uses: actions/github-script@v7
243+
id: requirements-hash
244+
with:
245+
script: return require('fs').createReadStream(require('path').join(process.env.GITHUB_ACTION_PATH, 'requirements.txt')).pipe(require('crypto').createHash('sha1').setEncoding('hex'), 'finish').digest('hex')
246+
result-encoding: string
247+
248+
- uses: actions/cache@v4
249+
if: ${{ inputs.cache == 'true' }}
250+
with:
251+
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ steps.requirements-hash.outputs.result }}
252+
restore-keys: cpp-linter-action-venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-
253+
path: ${{ github.action_path }}/venv
254+
237255
- name: Setup python venv (Unix)
238256
if: runner.os == 'Linux' || runner.os == 'macOS'
239257
shell: bash

0 commit comments

Comments
 (0)