-
Notifications
You must be signed in to change notification settings - Fork 641
77 lines (76 loc) · 3.18 KB
/
sonar.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
name: SonarCloud
on:
workflow_dispatch:
push:
branches:
- master
schedule:
- cron: '36 12 * * *' # 12:36 PM UTC, daily (picked an odd start time to try to avoid competing for agents with other projects)
jobs:
build:
if: github.repository == 'apache/lucenenet' # Don't run on forks
name: Build and analyze
runs-on: windows-latest
steps:
- name: Disable .NET SDK Telemetry and Logo
run: |
echo "DOTNET_NOLOGO=1" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "DOTNET_CLI_TELEMETRY_OPTOUT=1" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
shell: pwsh
- name: Setup .NET 7 SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 11
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
#- name: Cache SonarCloud packages
# uses: actions/cache@v3
# with:
# path: ~\sonar\cache
# key: ${{ runner.os }}-sonar
# restore-keys: ${{ runner.os }}-sonar
#- name: Cache SonarCloud scanner
# id: cache-sonar-scanner
# uses: actions/cache@v3
# with:
# path: .\.sonar\scanner
# key: ${{ runner.os }}-sonar-scanner
# restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarCloud scanner
#if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: powershell
run: |
$dir = '.\.sonar\scanner'
if (!(Test-Path $dir)) { New-Item -Path $dir -ItemType Directory }
# NOTE: Using 5.8.0 when the sonar scan was first added because that is likely the version that was in the cache
dotnet tool update dotnet-sonarscanner --tool-path $dir #--version 5.8.0
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
shell: powershell
run: |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"apache_lucenenet" /o:"apache" /d:sonar.token="${{ secrets.SONARCLOUD_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
dotnet build
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONARCLOUD_TOKEN }}"