Skip to content

Commit

Permalink
python pip caching
Browse files Browse the repository at this point in the history
  • Loading branch information
gmichelo committed Dec 21, 2023
1 parent 79f4ebc commit 2da4d3d
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 1 deletion.
29 changes: 29 additions & 0 deletions .github/workflows/python.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test Python caching
on:
push:
branches:
- main
pull_request:
branches:
- "*"
workflow_dispatch:

permissions:
contents: read

jobs:
yarn:
runs-on:
- namespace-profile-e2e-small
steps:
- uses: actions/checkout@v3
- name: Setup Python Pip cache
uses: ./ # Uses an action in the root directory
with:
cache: python
- uses: actions/checkout@v3
with:
repository: namespace-integration-demos/python-cache
path: demo
- run: pip install -r ./requirements.txt
working-directory: ./demo
31 changes: 31 additions & 0 deletions .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Test Rust caching
on:
push:
branches:
- main
pull_request:
branches:
- "*"
workflow_dispatch:

permissions:
contents: read

jobs:
yarn:
runs-on:
- namespace-profile-e2e-small
steps:
- uses: actions/checkout@v3
- name: Setup Rust cache
uses: ./ # Uses an action in the root directory
with:
cache: rust
- uses: actions/checkout@v3
with:
repository: namespace-integration-demos/rust-cache
path: demo
- run: cargo --locked --release --no-default-features --all
working-directory: ./demo
- run: cargo test --locked --release --all
working-directory: ./demo
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ inputs:
default: "false"
required: false
cache:
description: "A list of native cache modes. Supported options are 'go,yarn,rust'"
description: "A list of native cache modes. Supported options are 'go,yarn,rust,python'"
required: false
outputs:
cache-hit:
Expand Down
3 changes: 3 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27096,6 +27096,9 @@ async function resolveCacheMode(cacheMode) {
case "yarn":
const yarnCache = await getExecStdout(`yarn cache dir`);
return [{ path: yarnCache }];
case "python":
const pipCache = await getExecStdout(`pip cache dir`);
return [{ path: pipCache }];
case "pnpm":
const pnpmCache = await getExecStdout(`pnpm store path`);
const paths = [{ path: pnpmCache }];
Expand Down
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ async function resolveCacheMode(cacheMode: string): Promise<Path[]> {
case "yarn":
const yarnCache = await getExecStdout(`yarn cache dir`);
return [{ path: yarnCache }];

case "python":
const pipCache = await getExecStdout(`pip cache dir`);
return [{ path: pipCache }];

case "pnpm":
const pnpmCache = await getExecStdout(`pnpm store path`);
Expand Down

0 comments on commit 2da4d3d

Please sign in to comment.