openrewrite / openrewrite/rewrite-github-actions
Prefer `actions/setup` caching over `actions/cache`
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1
- Forks
- 9
- Avg merge
- 5h 27m
- Merged PRs (30d)
- 12
Description
- Remove
actions/cache - Add the
cachekey to the corresponding actions/setup
See :
https://github.com/actions/setup-java#caching-packages-dependencies
https://github.com/actions/setup-node#caching-packages-dependencies
https://github.com/actions/setup-python
https://github.com/actions/setup-go#caching-dependency-files-and-build-outputs
Examples:
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 4555776..785bc33 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -17,16 +17,11 @@ jobs:
checks: write
steps:
- uses: actions/checkout@v3
- - uses: actions/cache@v3
- with:
- path: ~/.m2/repository
- key: ${{ runner.os }}-main-maven-${{ hashFiles('**/pom.xml') }}
- restore-keys: |
- ${{ runner.os }}-main-maven-
- uses: actions/setup-java@v3
with:
java-version: 8
distribution: 'zulu'
+ cache: 'maven'
- run: cd tests && mvn clean test --batch-mode -Dmaven.test.failure.ignore=true
- uses: ./
if: github.ref != 'refs/heads/master'
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 785bc33..e2d8a91 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -52,12 +52,7 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 16
- - uses: actions/cache@v3
- with:
- path: ~/.npm
- key: ${{ runner.os }}-npm-cache-${{ hashFiles('**/package-lock.json') }}
- restore-keys: |
- ${{ runner.os }}-npm-cache-
+ cache: npm
- run: npm install
- run: npm run eslint
- run: npm run test
I think that the main challenge here is to determine what type to use.
For example, for actions/setup-java we have maven, gradle and sbt as options. The recipe should be able to detect the package manager and make the correct selection
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with .github/workflows/build.yml and the linked actions/setup-java, setup-node, setup-python, and setup-go caching documentation. Inspect how the recipe identifies actions/cache steps and determine the matching package-manager cache option for each setup action; done means the manual cache steps are replaced with the corresponding setup cache keys.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github-actions, yaml
- Domain
- ci-cd
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100