|
1 | 1 | name: Sonar |
2 | 2 | on: |
3 | | - workflow_run: |
4 | | - workflows: [CI] |
5 | | - types: [completed] |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - master |
6 | 6 | jobs: |
7 | 7 | sonar: |
8 | 8 | name: Sonar |
9 | 9 | permissions: |
10 | | - pull-requests: read |
| 10 | + contents: read |
11 | 11 | runs-on: ubuntu-latest |
12 | | - if: github.repository == 'eclipse/openvsx' && github.event.workflow_run.conclusion == 'success' |
| 12 | + if: github.repository == 'eclipse/openvsx' |
13 | 13 | steps: |
14 | | - - name: Create artifacts directory |
15 | | - run: mkdir -p ${{ runner.temp }}/artifacts |
16 | | - - name: Download PR number artifact |
17 | | - if: github.event.workflow_run.event == 'pull_request' |
18 | | - uses: dawidd6/action-download-artifact@0bd50d53a6d7fb5cb921e607957e9cc12b4ce392 # v12 |
19 | | - with: |
20 | | - workflow: CI |
21 | | - run_id: ${{ github.event.workflow_run.id }} |
22 | | - path: ${{ runner.temp }}/artifacts |
23 | | - name: PR_NUMBER |
24 | | - - name: Read PR_NUMBER.txt |
25 | | - if: github.event.workflow_run.event == 'pull_request' |
26 | | - id: pr_number |
27 | | - uses: juliangruber/read-file-action@b549046febe0fe86f8cb4f93c24e284433f9ab58 # v1.1.7 |
28 | | - with: |
29 | | - path: ${{ runner.temp }}/artifacts/PR_NUMBER.txt |
30 | | - - name: Request GitHub API for PR data |
31 | | - if: github.event.workflow_run.event == 'pull_request' |
32 | | - uses: octokit/request-action@05a2312de9f8207044c4c9e41fe19703986acc13 # v2.x |
33 | | - id: get_pr_data |
34 | | - with: |
35 | | - route: GET /repos/{full_name}/pulls/{number} |
36 | | - number: ${{ steps.pr_number.outputs.content }} |
37 | | - full_name: ${{ github.event.repository.full_name }} |
38 | | - env: |
39 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
40 | | - - name: Checkout head branch |
| 14 | + - name: Checkout |
41 | 15 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
42 | 16 | with: |
43 | | - repository: ${{ github.event.workflow_run.head_repository.full_name }} |
44 | | - ref: ${{ github.event.workflow_run.head_branch }} |
45 | 17 | persist-credentials: false |
46 | 18 | fetch-depth: 0 |
47 | | - - name: Checkout head branch of pull_request |
48 | | - if: github.event.workflow_run.event == 'pull_request' |
49 | | - env: |
50 | | - HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }} |
51 | | - run: | |
52 | | - git remote add upstream ${{ github.event.repository.clone_url }} |
53 | | - git fetch upstream |
54 | | - git checkout -B ${{ fromJson(steps.get_pr_data.outputs.data).base.ref }} upstream/${{ fromJson(steps.get_pr_data.outputs.data).base.ref }} |
55 | | - git checkout $HEAD_BRANCH |
56 | | - git clean -ffdx && git reset --hard HEAD |
57 | 19 | - name: Cache SonarCloud packages |
58 | 20 | uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 |
59 | 21 | with: |
60 | 22 | path: ~/.sonar/cache |
61 | 23 | key: ${{ runner.os }}-sonar |
62 | 24 | restore-keys: ${{ runner.os }}-sonar |
63 | | - - name: Cache Gradle packages |
64 | | - uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 |
65 | | - with: |
66 | | - path: ~/.gradle/caches |
67 | | - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} |
68 | | - restore-keys: ${{ runner.os }}-gradle |
69 | 25 | - name: Set up JDK |
70 | 26 | uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0 |
71 | 27 | with: |
72 | 28 | distribution: 'temurin' |
73 | 29 | java-version: 25 |
| 30 | + - name: Setup Gradle |
| 31 | + uses: gradle/actions/setup-gradle@f29f5a9d7b09a7c6b29859002d29d24e1674c884 # v5 |
| 32 | + with: |
| 33 | + dependency-graph: generate-and-submit |
74 | 34 | - name: Generate JaCoCo test report |
75 | 35 | run: server/gradlew --no-daemon -p server jacocoTestReport |
76 | 36 | - name: Make server libraries directory |
77 | 37 | run: mkdir server/libraries |
78 | 38 | - name: Copy server libraries |
79 | 39 | run: find ~/.gradle/caches -type f -name '*.jar' -exec cp {} server/libraries \; |
80 | | - - name: SonarCloud Scan on PR |
81 | | - if: github.event.workflow_run.event == 'pull_request' |
82 | | - uses: SonarSource/sonarqube-scan-action@a31c9398be7ace6bbfaf30c0bd5d415f843d45e9 # v7.0.0 |
83 | | - env: |
84 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
85 | | - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
86 | | - with: |
87 | | - args: > |
88 | | - -Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }} |
89 | | - -Dsonar.pullrequest.key=${{ fromJson(steps.get_pr_data.outputs.data).number }} |
90 | | - -Dsonar.pullrequest.branch=${{ fromJson(steps.get_pr_data.outputs.data).head.ref }} |
91 | | - -Dsonar.pullrequest.base=${{ fromJson(steps.get_pr_data.outputs.data).base.ref }} |
92 | | - - name: SonarCloud Scan on push |
93 | | - if: github.event.workflow_run.event == 'push' && github.event.workflow_run.head_repository.full_name == github.event.repository.full_name |
| 40 | + - name: SonarCloud Scan |
94 | 41 | uses: SonarSource/sonarqube-scan-action@a31c9398be7ace6bbfaf30c0bd5d415f843d45e9 # v7.0.0 |
95 | 42 | env: |
96 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
97 | 43 | SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
98 | | - with: |
99 | | - args: > |
100 | | - -Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }} |
101 | | - -Dsonar.branch.name=${{ github.event.workflow_run.head_branch }} |
0 commit comments