Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python venv cache support #234

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
21 changes: 21 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,22 @@ runs:
fi
fi

- if: ${{ inputs.cache == 'true' }}
id: gen-cache-key
shell: python
run: |
import hashlib, os, pathlib
fp = pathlib.Path(os.path.join(os.environ["GITHUB_ACTION_PATH"], 'requirements.txt'))
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
print('hash=%s' % (hashlib.sha1(fp.read_bytes()).hexdigest()), file=f)

- uses: actions/cache@v4
if: ${{ inputs.cache == 'true' }}
with:
key: cpp-linter-action-venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ steps.gen-cache-key.outputs.hash }}
restore-keys: cpp-linter-action-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
Loading