Skip to content

Commit

Permalink
python venv cache support
Browse files Browse the repository at this point in the history
  • Loading branch information
h0tw1r3 committed Apr 22, 2024
1 parent a3ed755 commit 528a087
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/self-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
with:
style: file
files-changed-only: false
cache: true
# to ignore all build folder contents
ignore: build|venv
database: build
Expand Down
18 changes: 18 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ inputs:
[re-running jobs or workflows](https://docs.github.com/en/actions/managing-workflow-runs/re-running-workflows-and-jobs).
required: false
default: info
cache:
description: |
This controls if the python virtual environment is cached.
required: false
default: false
lines-changed-only:
description: |
This controls what part of the files are analyzed. The following values are accepted:
Expand Down Expand Up @@ -234,6 +239,19 @@ runs:
fi
fi
- uses: actions/github-script@v7
id: requirements-hash
with:
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')
result-encoding: string

- uses: actions/cache@v4
if: ${{ inputs.cache == 'true' }}
with:
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ steps.requirements-hash.outputs.result }}
restore-keys: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-
path: ${{ github.action_path }}/venv

- name: Setup python venv (Unix)
if: runner.os == 'Linux' || runner.os == 'macOS'
shell: bash
Expand Down

0 comments on commit 528a087

Please sign in to comment.