Skip to content

ci: replace deprecated sonarqube action #688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/download-lint-report/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ runs:
- name: Download lint report
uses: actions/download-artifact@v4
with:
name: lint-report
name: lint-report.info
path: reports
2 changes: 1 addition & 1 deletion .github/workflows/basic-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Archive lint report results
uses: actions/upload-artifact@v4
with:
name: lint-report
name: lint-report.info
path: reports

build:
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,16 @@ jobs:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
#
# # Download reports
# - uses: ./.github/actions/download-coverage-report
# - uses: ./.github/actions/download-lint-report
#
# - name: 'Verify reports'
# run: |
# pwd
# echo 'Lint report'
# ls -la ./coverage/packages/ngx-deploy-npm/lcov.info
# echo 'Coverage report'
# ls -la ./reports/ngx-deploy-npm/lint-report.info
# - name: SonarCloud Scan
# uses: SonarSource/[email protected]
# env:
Expand Down
55 changes: 2 additions & 53 deletions .github/workflows/sonar-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,59 +35,8 @@ jobs:
JSON.stringify(${{ github.event.workflow_run }}, null, 2)

# Download reports
- name: 'Download reports'
uses: actions/github-script@v6
with:
script: |
async function downloadArtifact(artifactName) {
console.log(`Looking for artifact: ${artifactName}`);

let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});

console.log('Available artifacts:', allArtifacts.data.artifacts.map(a => a.name));

let matchArtifact = allArtifacts.data.artifacts.find((artifact) => {
return artifact.name === artifactName;
});

if (!matchArtifact) {
throw new Error(`Artifact "${artifactName}" not found!`);
}

let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});

let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/${artifactName}.zip`, Buffer.from(download.data));

return artifactName;
}

const sha = context.payload.workflow_run.head_sha;

// Download both artifacts
await Promise.all([
downloadArtifact('ngx-deploy-npm-coverage-report'),
downloadArtifact('lint-report')
]);

- name: 'Extract reports'
run: |
# Extract coverage report
mkdir -p coverage/packages/ngx-deploy-npm
unzip ngx-deploy-npm-coverage-report.zip -d coverage/packages/ngx-deploy-npm

# Extract lint report
mkdir -p reports
unzip lint-report.zip -d reports
- uses: ./.github/actions/download-coverage-report
- uses: ./.github/actions/download-lint-report

- name: SonarCloud Scan
uses: SonarSource/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion packages/ngx-deploy-npm/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"lint-report": {
"executor": "nx:run-commands",
"options": {
"command": "npx nx lint ngx-deploy-npm --outputFile reports/ngx-deploy-npm/lint-report --format=./tools/sonarqube-linter-reporter.js || true"
"command": "npx nx lint ngx-deploy-npm --outputFile reports/ngx-deploy-npm/lint-report.info --format=./tools/sonarqube-linter-reporter.js || true"
}
},
"test": {
Expand Down
14 changes: 3 additions & 11 deletions sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,14 @@ sonar.sourceEncoding=UTF-8
sonar.project.monorepo.enabled=true

# List of module indedtifiers
sonar.modules=ngx-deploy-npm-e2e,ngx-deploy-npm
sonar.modules=ngx-deploy-npm

# Common settings
# Files to exclude
sonar.exclusions=**/node_modules/**
# How to find the test
sonar.test.inclusions=**/*.spec.ts,**/__mocks__/**

# ------- ngx-deploy-npm e2e -------
ngx-deploy-npm-e2e.sonar.projectBaseDir=packages/ngx-deploy-npm-e2e
ngx-deploy-npm-e2e.sonar.tests=src
ngx-deploy-npm.sonar.typescript.tsconfigPath=tsconfig.spec.json
# The coverage report
# ngx-deploy-npm-e2e.sonar.javascript.lcov.reportPaths=/github/workspace/coverage/packages/ngx-deploy-npm-e2e/lcov.info
# ------- ngx-deploy-npm e2e off -------

# ------- ngx-deploy-npm -------
ngx-deploy-npm.sonar.projectBaseDir=packages/ngx-deploy-npm
ngx-deploy-npm.sonar.sources=src
Expand All @@ -29,11 +21,11 @@ ngx-deploy-npm.sonar.typescript.tsconfigPath=tsconfig.lib.json

# Linter Report
# We standardize all the Sonar Analysis using dockerization to be able to provide absolute paths
ngx-deploy-npm.sonar.eslint.reportPaths=/github/workspace/reports/ngx-deploy-npm/lint-report
ngx-deploy-npm.sonar.eslint.reportPaths=../../reports/ngx-deploy-npm/lint-report.info

# The coverage report
# We standardize all the Sonar Analysis using dockerization to be able to provide absolute paths
ngx-deploy-npm.sonar.javascript.lcov.reportPaths=/github/workspace/coverage/packages/ngx-deploy-npm/lcov.info
ngx-deploy-npm.sonar.javascript.lcov.reportPaths=../../coverage/packages/ngx-deploy-npm/lcov.info
# ------- ngx-deploy-npm off -------

# For more information visit
Expand Down
Loading