@@ -41,29 +41,75 @@ jobs:
41
41
uses : ./.github/workflows/backwards-compatibility-test.yml
42
42
43
43
# Test sonarcloud analysis
44
- # pr-analysis:
45
- # name: SonarCloud Pr Analysis
46
- # runs-on: ubuntu-latest
47
- # needs: pr-test
48
- # steps:
49
- # - uses: actions/checkout@v4
50
- # with:
51
- # fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
52
- # # Download reports
53
- # - uses: ./.github/actions/download-coverage-report
54
- # - uses: ./.github/actions/download-lint-report
55
- # - name: 'Verify reports'
56
- # run: |
57
- # pwd
58
- # echo 'Lint report'
59
- # ls -la ./coverage/packages/ngx-deploy-npm/lcov.info
60
- # echo 'Coverage report'
61
- # ls -la ./reports/ngx-deploy-npm/lint-report.info
62
- # - name: SonarCloud Scan
63
- # uses: SonarSource/sonarqube-scan-action@v4.2.1
64
- # env:
65
- # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
66
- # SONAR_TOKEN: ${{ secrets.SONARQUBE_SCANNER }}
67
- # with:
68
- # args: >
69
- # -Dsonar.pullrequest.key=${{ github.env.PR_NUMBER }}
44
+ pr-analysis :
45
+ name : SonarCloud Pr Analysis
46
+ runs-on : ubuntu-latest
47
+ needs : pr-test
48
+ steps :
49
+ - uses : actions/checkout@v4
50
+ with :
51
+ fetch-depth : 0 # Shallow clones should be disabled for a better relevancy of analysis
52
+
53
+ # Download reports
54
+ - name : ' Download reports'
55
+ uses : actions/github-script@v6
56
+ with :
57
+ script : |
58
+ async function downloadArtifact(artifactName) {
59
+ console.log(`Looking for artifact: ${artifactName}`);
60
+ let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
61
+ owner: context.repo.owner,
62
+ repo: context.repo.repo,
63
+ run_id: context.payload.workflow_run.id,
64
+ });
65
+ console.log('Available artifacts:', allArtifacts.data.artifacts.map(a => a.name));
66
+
67
+ let matchArtifact = allArtifacts.data.artifacts.find((artifact) => {
68
+ return artifact.name === artifactName;
69
+ });
70
+
71
+ if (!matchArtifact) {
72
+ throw new Error(`Artifact "${artifactName}" not found!`);
73
+ }
74
+
75
+ let download = await github.rest.actions.downloadArtifact({
76
+ owner: context.repo.owner,
77
+ repo: context.repo.repo,
78
+ artifact_id: matchArtifact.id,
79
+ archive_format: 'zip',
80
+ });
81
+
82
+ let fs = require('fs');
83
+ fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/${artifactName}.zip`, Buffer.from(download.data));
84
+ return artifactName;
85
+ }
86
+
87
+ // Download both artifacts
88
+ await Promise.all([
89
+ downloadArtifact('ngx-deploy-npm-coverage-report'),
90
+ downloadArtifact('lint-report')
91
+ ]);
92
+ - name : ' Extract reports'
93
+ run : |
94
+ # Extract coverage report
95
+ mkdir -p coverage/packages/ngx-deploy-npm
96
+ unzip ngx-deploy-npm-coverage-report.zip -d coverage/packages/ngx-deploy-npm
97
+ # Extract lint report
98
+ mkdir -p reports
99
+ unzip lint-report.zip -d reports
100
+
101
+ - name : ' Verify reports'
102
+ run : |
103
+ pwd
104
+ echo 'Lint report'
105
+ ls -la ./coverage/packages/ngx-deploy-npm/lcov.info
106
+ echo 'Coverage report'
107
+ ls -la ./reports/ngx-deploy-npm/lint-report.info
108
+ - name : SonarCloud Scan
109
+ uses : SonarSource/sonarqube-scan-action@v4.2.1
110
+ env :
111
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
112
+ SONAR_TOKEN : ${{ secrets.SONARQUBE_SCANNER }}
113
+ with :
114
+ args : >
115
+ -Dsonar.pullrequest.key=${{ github.env.PR_NUMBER }}
0 commit comments