forked from deskflow/deskflow
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove cache of Python .venv as it added complexity (#12)
ci: Remove cache of Python `.venv` as it added complexity
- Loading branch information
Showing
7 changed files
with
12 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,23 @@ | ||
name: "Setup Python venv" | ||
description: "Creates and caches a Python virtual environment" | ||
|
||
inputs: | ||
cache: | ||
description: "Cache Python venv" | ||
default: true | ||
|
||
setup: | ||
description: "Setup Python venv" | ||
default: true | ||
# Important: Do not be tempted to cache the .venv dir (Python virtual environment). | ||
# When the runner environment changes (e.g. Python is upgraded), the venv will need to be | ||
# re-created. Trying to upgrade a venv can be complex and it's usually more practical re-create it. | ||
# We don't save much time anyway by caching the venv so it's not worth the added complexity. | ||
|
||
python-bin: | ||
description: "Python binary to use" | ||
default: "python3" | ||
|
||
cache-key: | ||
description: "Cache key (note: hash is appended)" | ||
required: true | ||
name: "Setup Python venv" | ||
description: "Creates a Python virtual environment (venv)" | ||
|
||
runs: | ||
using: "composite" | ||
|
||
steps: | ||
- name: Check cache key | ||
if: ${{ inputs.cache }} | ||
run: | | ||
if [ -z "${{ inputs.cache-key }}" ]; then | ||
echo "Cache key is required" | ||
exit 1 | ||
fi | ||
shell: bash | ||
|
||
- name: Cache Python venv | ||
if: ${{ inputs.cache }} | ||
uses: actions/cache@v4 | ||
with: | ||
path: .venv | ||
key: python-venv-${{ inputs.cache-key }}-${{ hashFiles('scripts/pyproject.toml') }} | ||
|
||
# Use bash if to make output clearer in case of skipping. | ||
- name: Setup Python venv | ||
run: | | ||
if [ "${{ inputs.setup }}" = "true" ]; then | ||
echo "Setting up Python venv" | ||
${{ inputs.python-bin }} -m venv .venv | ||
if [ "${{ runner.os }}" == "Windows" ]; then | ||
python=python | ||
else | ||
echo "Skipping Python venv setup" | ||
python=python3 | ||
fi | ||
echo "Setting up Python venv, bin=$python" | ||
$python -m venv .venv | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters