Compare commits

...

3 Commits

2 changed files with 39 additions and 37 deletions

View File

@ -46,31 +46,33 @@ class Api::V1::SonarqubesController < Api::V1::BaseController
filepath: '.gitea/workflows/SonarScanner.yaml',
branch: params[:branch],
new_branch: nil,
content: <<-YAML
name: Sonar Scanner
jobs:
sonarqube:
runs-on: ubuntu-latest
steps:
- uses: #{checkout_url}
with:
fetch-depth: 1
single-branch: true
- name: curl doxygen
run: |
curl -X GET #{doxygen_url}/generate?repo=#{@project.repository.url}
- name: new properties
run: |
cat <<EOF > sonar-project.properties
#{sonar_content}
EOF
- name: SonarQube Scan
uses: #{scanner_url}
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
YAML
,
content: "
name: Sonar Scanner
jobs:
sonarqube:
runs-on: ubuntu-latest
steps:
- uses: #{checkout_url}
with:
# Disabling shallow clones is recommended for improving the relevancy of reporting
fetch-depth: 1
single-branch: true
- name: curl doxygen
run: |
curl -X GET #{doxygen_url}/generate?repo=#{@project.repository.url}
- name: new properties
run: |
cat <<EOF > sonar-project.properties
#{sonar_content}
EOF
- name: SonarQube Scan
uses: #{scanner_url}
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
",
message: 'Add .gitea/workflows/SonarScanner.yaml',
committer: {
email: @owner.mail,

View File

@ -12,33 +12,33 @@ module SonarService
detected_langs = lang_keys.map { |l| lang_map[l] }.compact.to_set
lines = []
lines << "sonar.projectKey=#{owner}-#{project_id}"
lines << "sonar.projectVersion=1.0"
lines << "sonar.sourceEncoding=UTF-8"
lines << "sonar.sources=."
lines << "sonar.exclusions=**/test/**,**/tests/**,**/vendor/**,**/node_modules/**,**/__pycache__/**"
lines << " sonar.projectKey=#{owner}-#{project_id}"
lines << " sonar.projectVersion=1.0"
lines << " sonar.sourceEncoding=UTF-8"
lines << " sonar.sources=."
lines << " sonar.exclusions=**/test/**,**/tests/**,**/vendor/**,**/node_modules/**,**/__pycache__/**"
if detected_langs.include?(:java)
lines << "sonar.java.binaries=."
lines << " sonar.java.binaries=."
end
if detected_langs.include?(:js)
lines << "sonar.javascript.lcov.reportPaths=coverage/lcov.info"
lines << " sonar.javascript.lcov.reportPaths=coverage/lcov.info"
end
if detected_langs.include?(:ts)
lines << "sonar.typescript.tsconfigPath=tsconfig.json"
lines << " sonar.typescript.tsconfigPath=tsconfig.json"
end
if detected_langs.include?(:python)
lines << "sonar.python.coverage.reportPaths=coverage.xml"
lines << " sonar.python.coverage.reportPaths=coverage.xml"
end
if detected_langs.include?(:cpp)
lines << "sonar.cxx.file.suffixes=.cpp,.c,.cc,.h,.hpp,.hh"
lines << "sonar.cxx.errorRecoveryEnabled=true"
lines << " sonar.cxx.file.suffixes=.cpp,.c,.cc,.h,.hpp,.hh"
lines << " sonar.cxx.errorRecoveryEnabled=true"
end
lines
lines.join("\n")
end
end