forked from Trustie/forgeplus
Merge pull request 'update sonar' (#375) from KingChan/forgeplus:standalone_develop into standalone_develop
This commit is contained in:
commit
6c937e6af6
|
@ -46,31 +46,33 @@ class Api::V1::SonarqubesController < Api::V1::BaseController
|
||||||
filepath: '.gitea/workflows/SonarScanner.yaml',
|
filepath: '.gitea/workflows/SonarScanner.yaml',
|
||||||
branch: params[:branch],
|
branch: params[:branch],
|
||||||
new_branch: nil,
|
new_branch: nil,
|
||||||
content: <<-YAML
|
content: "
|
||||||
name: Sonar Scanner
|
name: Sonar Scanner
|
||||||
jobs:
|
jobs:
|
||||||
sonarqube:
|
sonarqube:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: #{checkout_url}
|
- uses: #{checkout_url}
|
||||||
with:
|
with:
|
||||||
fetch-depth: 1
|
# Disabling shallow clones is recommended for improving the relevancy of reporting
|
||||||
single-branch: true
|
fetch-depth: 1
|
||||||
- name: curl doxygen
|
single-branch: true
|
||||||
run: |
|
- name: curl doxygen
|
||||||
curl -X GET #{doxygen_url}/generate?repo=#{@project.repository.url}
|
run: |
|
||||||
- name: new properties
|
curl -X GET #{doxygen_url}/generate?repo=#{@project.repository.url}
|
||||||
run: |
|
|
||||||
cat <<EOF > sonar-project.properties
|
- name: new properties
|
||||||
#{sonar_content}
|
run: |
|
||||||
EOF
|
cat <<EOF > sonar-project.properties
|
||||||
- name: SonarQube Scan
|
#{sonar_content}
|
||||||
uses: #{scanner_url}
|
EOF
|
||||||
env:
|
|
||||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
- name: SonarQube Scan
|
||||||
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
|
uses: #{scanner_url}
|
||||||
YAML
|
env:
|
||||||
,
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
|
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
|
||||||
|
",
|
||||||
message: 'Add .gitea/workflows/SonarScanner.yaml',
|
message: 'Add .gitea/workflows/SonarScanner.yaml',
|
||||||
committer: {
|
committer: {
|
||||||
email: @owner.mail,
|
email: @owner.mail,
|
||||||
|
|
|
@ -12,33 +12,33 @@ module SonarService
|
||||||
detected_langs = lang_keys.map { |l| lang_map[l] }.compact.to_set
|
detected_langs = lang_keys.map { |l| lang_map[l] }.compact.to_set
|
||||||
|
|
||||||
lines = []
|
lines = []
|
||||||
lines << "sonar.projectKey=#{owner}-#{project_id}"
|
lines << " sonar.projectKey=#{owner}-#{project_id}"
|
||||||
lines << "sonar.projectVersion=1.0"
|
lines << " sonar.projectVersion=1.0"
|
||||||
lines << "sonar.sourceEncoding=UTF-8"
|
lines << " sonar.sourceEncoding=UTF-8"
|
||||||
lines << "sonar.sources=."
|
lines << " sonar.sources=."
|
||||||
lines << "sonar.exclusions=**/test/**,**/tests/**,**/vendor/**,**/node_modules/**,**/__pycache__/**"
|
lines << " sonar.exclusions=**/test/**,**/tests/**,**/vendor/**,**/node_modules/**,**/__pycache__/**"
|
||||||
|
|
||||||
if detected_langs.include?(:java)
|
if detected_langs.include?(:java)
|
||||||
lines << "sonar.java.binaries=."
|
lines << " sonar.java.binaries=."
|
||||||
end
|
end
|
||||||
|
|
||||||
if detected_langs.include?(:js)
|
if detected_langs.include?(:js)
|
||||||
lines << "sonar.javascript.lcov.reportPaths=coverage/lcov.info"
|
lines << " sonar.javascript.lcov.reportPaths=coverage/lcov.info"
|
||||||
end
|
end
|
||||||
|
|
||||||
if detected_langs.include?(:ts)
|
if detected_langs.include?(:ts)
|
||||||
lines << "sonar.typescript.tsconfigPath=tsconfig.json"
|
lines << " sonar.typescript.tsconfigPath=tsconfig.json"
|
||||||
end
|
end
|
||||||
|
|
||||||
if detected_langs.include?(:python)
|
if detected_langs.include?(:python)
|
||||||
lines << "sonar.python.coverage.reportPaths=coverage.xml"
|
lines << " sonar.python.coverage.reportPaths=coverage.xml"
|
||||||
end
|
end
|
||||||
|
|
||||||
if detected_langs.include?(:cpp)
|
if detected_langs.include?(:cpp)
|
||||||
lines << "sonar.cxx.file.suffixes=.cpp,.c,.cc,.h,.hpp,.hh"
|
lines << " sonar.cxx.file.suffixes=.cpp,.c,.cc,.h,.hpp,.hh"
|
||||||
lines << "sonar.cxx.errorRecoveryEnabled=true"
|
lines << " sonar.cxx.errorRecoveryEnabled=true"
|
||||||
end
|
end
|
||||||
|
|
||||||
lines
|
lines.join("\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue