Skip to content

Commit 930bb16

Browse files
committed
ci: fix download reports on sonarqube
1 parent bc68b7e commit 930bb16

File tree

3 files changed

+52
-7
lines changed

3 files changed

+52
-7
lines changed

.github/workflows/basic-test.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Archive lint report results
1919
uses: actions/upload-artifact@v4
2020
with:
21-
name: lint-report.info
21+
name: lint-report
2222
path: reports
2323

2424
build:
@@ -50,14 +50,15 @@ jobs:
5050
- run: npx nx test ngx-deploy-npm --configuration="ci"
5151

5252
- name: Set Node.js version based on .nvmrc
53+
id: nvmrc
5354
shell: bash
5455
run: |
5556
version=$(cat .nvmrc)
5657
echo "Setting default value for node-version parameter: $version"
57-
echo "NODE_VERSION=$version" >> $GITHUB_ENV
58-
echo "$NODE_VERSION"
58+
echo "node_version=$version" >> $GITHUB_OUTPUT
59+
echo "$version"
5960
60-
- if: ${{ matrix.os == 'ubuntu-latest' && matrix.node-version == env.NODE_VERSION }}
61+
- if: ${{ matrix.os == 'ubuntu-latest' && matrix.node-version == steps.nvmrc.outputs.node_version }}
6162
name: Archive coverage report
6263
uses: actions/upload-artifact@v4
6364
with:

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
needs: [pr-test]
4141
uses: ./.github/workflows/backwards-compatibility-test.yml
4242

43-
# Test sonarcloud analysis
43+
# Test sonarcloud analysis
4444
# pr-analysis:
4545
# name: SonarCloud Pr Analysis
4646
# runs-on: ubuntu-latest

.github/workflows/sonar-pr.yml

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,52 @@ jobs:
3535
JSON.stringify(${{ github.event.workflow_run }}, null, 2)
3636
3737
# Download reports
38-
- uses: ./.github/actions/download-coverage-report
39-
- uses: ./.github/actions/download-lint-report
38+
- name: 'Download reports'
39+
uses: actions/github-script@v6
40+
with:
41+
script: |
42+
async function downloadArtifact(artifactName) {
43+
console.log(`Looking for artifact: ${artifactName}`);
44+
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
45+
owner: context.repo.owner,
46+
repo: context.repo.repo,
47+
run_id: context.payload.workflow_run.id,
48+
});
49+
console.log('Available artifacts:', allArtifacts.data.artifacts.map(a => a.name));
50+
51+
let matchArtifact = allArtifacts.data.artifacts.find((artifact) => {
52+
return artifact.name === artifactName;
53+
});
54+
55+
if (!matchArtifact) {
56+
throw new Error(`Artifact "${artifactName}" not found!`);
57+
}
58+
59+
let download = await github.rest.actions.downloadArtifact({
60+
owner: context.repo.owner,
61+
repo: context.repo.repo,
62+
artifact_id: matchArtifact.id,
63+
archive_format: 'zip',
64+
});
65+
66+
let fs = require('fs');
67+
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/${artifactName}.zip`, Buffer.from(download.data));
68+
return artifactName;
69+
}
70+
71+
// Download both artifacts
72+
await Promise.all([
73+
downloadArtifact('ngx-deploy-npm-coverage-report'),
74+
downloadArtifact('lint-report')
75+
]);
76+
- name: 'Extract reports'
77+
run: |
78+
# Extract coverage report
79+
mkdir -p coverage/packages/ngx-deploy-npm
80+
unzip ngx-deploy-npm-coverage-report.zip -d coverage/packages/ngx-deploy-npm
81+
# Extract lint report
82+
mkdir -p reports
83+
unzip lint-report.zip -d reports
4084
4185
- name: SonarCloud Scan
4286
uses: SonarSource/[email protected]

0 commit comments

Comments
 (0)