Skip to content

Commit

Permalink
feat: allow to cache the .venv directory
Browse files Browse the repository at this point in the history
  • Loading branch information
eifinger committed Jul 31, 2023
1 parent a62d29c commit 6f1d811
Show file tree
Hide file tree
Showing 20 changed files with 189,473 additions and 11,194 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/test-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: 'test-cache'
on:
pull_request:
push:
branches:
- main

jobs:
test-setup-cache:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Simluate rye-project
run: cp -r ./__tests__/fixtures/rye-project/* .
- name: Setup with cache
uses: ./
with:
version: '0.11.0'
enable-cache: true
test-restore-cache:
runs-on: ubuntu-latest
needs: test-setup-cache
steps:
- uses: actions/checkout@v3
- name: Simluate rye-project
run: cp -r ./__tests__/fixtures/rye-project/* .
- name: Restore with cache
id: restore
uses: ./
with:
version: '0.11.0'
enable-cache: true
- name: Cache was hit
run: |
if [ "$CACHE_HIT" != "true" ]; then
exit 1
fi
env:
CACHE_HIT: ${{ steps.restore.outputs.cache-hit }}
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name: 'build-test'
name: 'test'
on:
pull_request:
push:
branches:
- main
- 'releases/*'

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions __tests__/fixtures/rye-project/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[email protected]
3 changes: 3 additions & 0 deletions __tests__/fixtures/rye-project/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# rye-project

Describe your project here.
23 changes: 23 additions & 0 deletions __tests__/fixtures/rye-project/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[project]
name = "rye-project"
version = "0.1.0"
description = "Add your description here"
authors = [
{ name = "Kevin Stillhammer", email = "[email protected]" }
]
dependencies = [
"black>=23.7.0",
]
readme = "README.md"
requires-python = ">= 3.8"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.rye]
managed = true
dev-dependencies = []

[tool.hatch.metadata]
allow-direct-references = true
15 changes: 15 additions & 0 deletions __tests__/fixtures/rye-project/requirements-dev.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: false

-e file:.
black==23.7.0
click==8.1.6
mypy-extensions==1.0.0
packaging==23.1
pathspec==0.11.2
platformdirs==3.10.0
15 changes: 15 additions & 0 deletions __tests__/fixtures/rye-project/requirements.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: false

-e file:.
black==23.7.0
click==8.1.6
mypy-extensions==1.0.0
packaging==23.1
pathspec==0.11.2
platformdirs==3.10.0
2 changes: 2 additions & 0 deletions __tests__/fixtures/rye-project/src/rye_project/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def hello():
return "Hello from rye-project!"
13 changes: 13 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,22 @@ inputs:
checksum:
description: 'The checksum of the rye version to install'
required: false
enable-cache:
description: 'Enable caching of .venv'
default: 'false'
cache-prefix:
description: 'Prefix for the cache key'
required: false
outputs:
rye-version:
description: "The installed rye version. Useful when using latest."
cache-hit:
description: "A boolean value to indicate a cache entry was found"
runs:
using: 'node16'
main: 'dist/setup/index.js'
post: 'dist/save-cache/index.js'
post-if: success()
branding:
icon: 'package'
color: 'blue'
Loading

0 comments on commit 6f1d811

Please sign in to comment.