openrewrite / openrewrite/rewrite-github-actions

Set `fetch-depth` to 0 for workflows using Sonar

Open
#62 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

recipe
Dominant language
Java
Stars
1
Forks
9
Avg merge
5h 27m
Merged PRs (30d)
12

Description

This recipe should :

  1. Detect usages of actions/checkout and Sonar
  2. Change the fetch-depth to 0 for actions/checkout

Example pull request : https://github.com/kobylynskyi/graphql-java-codegen/pull/1061


diff --git a/.github/workflows/github.yml b/.github/workflows/github.yml
index 78fa738a..6b6710b0 100644
--- a/.github/workflows/github.yml
+++ b/.github/workflows/github.yml
@@ -86,7 +86,8 @@ jobs:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v2
-
+        with:
+         fetch-depth: 0
       - name: Setup Java
         uses: actions/setup-java@v1
         with:

There are a few ways to run Sonar as far as I know :

Gradle :

 ./gradlew sonarqube ...
 gradle sonarqube ...

Maven :

 mvn sonar:sonar 
 ./mvnw sonar:sonar 

Using sonarqube-action

Additional information : https://community.sonarsource.com/t/git-fetch-depth-implications/75260

Common error after results are processed:

image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the recipe that scans workflows for actions/checkout and Sonar usage, using the .github/workflows/github.yml example as a reference. Check Gradle, Maven, wrapper, and sonarqube-action cases; done means each matching checkout step has fetch-depth set to 0.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, java
Domain
ci-cd, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.