Skip to content

Commit 0ca1c9a

Browse files
committed
fix: update CI
1 parent 6403008 commit 0ca1c9a

File tree

4 files changed

+97
-23
lines changed

4 files changed

+97
-23
lines changed

.github/workflows/build.yml

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,38 @@ name: CI
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [ master, main ]
66

77
jobs:
8+
set-deps-dotnet-poop-here:
9+
runs-on: ubuntu-latest
10+
container:
11+
image: mcr.microsoft.com/dotnet/sdk:6.0
12+
outputs:
13+
semVer: ${{ steps.gitversion.outputs.semVer }}
14+
steps:
15+
- uses: actions/checkout@v3
16+
with:
17+
fetch-depth: 0
18+
- name: Install GitVersion
19+
uses: gittools/actions/gitversion/[email protected]
20+
with:
21+
versionSpec: '5.x'
22+
- name: Set SemVer Version
23+
uses: gittools/actions/gitversion/[email protected]
24+
id: gitversion
25+
26+
- name: echo VERSIONS
27+
run: |
28+
echo "REVISION -> $GITHUB_SHA"
29+
echo "VERSION -> $GITVERSION_SEMVER"
830
build:
931
runs-on: ubuntu-latest
1032
container:
1133
image: golang:1.19-bullseye
34+
needs: set-deps-dotnet-poop-here
35+
env:
36+
SEMVER: ${{ needs.set-deps-dotnet-poop-here.outputs.semVer }}
1237
steps:
1338
- uses: actions/checkout@v3
1439
- name: install deps
@@ -23,3 +48,17 @@ jobs:
2348
if: always() # always run even if the previous step fails
2449
with:
2550
report_paths: '**/report-junit.xml'
51+
- name: Analyze with SonarCloud
52+
# You can pin the exact commit or the version.
53+
uses: SonarSource/sonarcloud-github-action@master
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information
56+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Generate a token on Sonarcloud.io, add it to the secrets of this repo with the name SONAR_TOKEN (Settings > Secrets > Actions > add new repository secret)
57+
with:
58+
# Additional arguments for the sonarcloud scanner
59+
args:
60+
# Unique keys of your project and organization. You can find them in SonarCloud > Information (bottom-left menu)
61+
# mandatory
62+
-Dsonar.projectVersion=$SEMVER
63+
-Dsonar.go.coverage.reportPaths=/github/workspace/.coverage/out
64+
-X

.github/workflows/pr.yml

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,36 @@ on:
55
branches: [ master, main ]
66

77
jobs:
8+
set-deps-dotnet-poop-here:
9+
runs-on: ubuntu-latest
10+
container:
11+
image: mcr.microsoft.com/dotnet/sdk:6.0
12+
outputs:
13+
semVer: ${{ steps.gitversion.outputs.semVer }}
14+
steps:
15+
- uses: actions/checkout@v3
16+
with:
17+
fetch-depth: 0
18+
- name: Install GitVersion
19+
uses: gittools/actions/gitversion/[email protected]
20+
with:
21+
versionSpec: '5.x'
22+
- name: Set SemVer Version
23+
uses: gittools/actions/gitversion/[email protected]
24+
id: gitversion
25+
26+
- name: echo VERSIONS
27+
run: |
28+
echo "REVISION -> $GITHUB_SHA"
29+
echo "VERSION -> $GITVERSION_SEMVER"
830
pr:
931
runs-on: ubuntu-latest
1032
container:
1133
image: golang:1.19-bullseye
12-
env:
13-
FOO: Bar
14-
REVISION: $GITHUB_SHA
15-
# ports:
16-
# - 80
17-
# volumes:
18-
# - my_docker_volume:/volume_mount
19-
# options: --cpus 1
34+
needs: set-deps-dotnet-poop-here
35+
env:
36+
REVISION: $GITHUB_SHA
37+
SEMVER: ${{ needs.set-deps-dotnet-poop-here.outputs.semVer }}
2038
steps:
2139
- uses: actions/checkout@v3
2240
- name: install deps
@@ -31,3 +49,17 @@ jobs:
3149
if: always() # always run even if the previous step fails
3250
with:
3351
report_paths: '**/report-junit.xml'
52+
- name: Analyze with SonarCloud
53+
# You can pin the exact commit or the version.
54+
uses: SonarSource/sonarcloud-github-action@master
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information
57+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Generate a token on Sonarcloud.io, add it to the secrets of this repo with the name SONAR_TOKEN (Settings > Secrets > Actions > add new repository secret)
58+
with:
59+
# Additional arguments for the sonarcloud scanner
60+
args:
61+
# Unique keys of your project and organization. You can find them in SonarCloud > Information (bottom-left menu)
62+
# mandatory
63+
-Dsonar.projectVersion=$SEMVER
64+
-Dsonar.go.coverage.reportPaths=/github/workspace/.coverage/out
65+
-X

configmanager_test.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,6 @@ func Test_retrieve(t *testing.T) {
7575
}
7676
}
7777

78-
var (
79-
strT4 = `
80-
export FOO='FOO#/test'
81-
export FOO1=FOO#/test
82-
export FOO2='FOO#/test'
83-
export FOO3=FOO#/test
84-
export FOO4=FOO#/test
85-
86-
[[section]]
87-
88-
foo23 = FOO#/test
89-
`
90-
)
91-
9278
func Test_retrieveWithInputReplaced(t *testing.T) {
9379
tests := map[string]struct {
9480
name string

sonar-project.properties

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
sonar.projectKey=dnitsch_configmanager
2+
sonar.organization=dnitsch
3+
# This is the name and version displayed in the SonarCloud UI.
4+
sonar.projectName=configmanager
5+
6+
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
7+
sonar.sources=.
8+
sonar.exclusions=**/*_test.go,**/*_generated*.go,**/*_generated/**,**/vendor/**
9+
sonar.inclusions=**/*.go
10+
11+
# Encoding of the source code. Default is default system encoding
12+
13+
sonar.tests=.
14+
sonar.test.inclusions=**/*_test.go
15+
sonar.test.exclusions=**/*_generated*.go,**/*_generated/**,**/vendor/**
16+
17+
sonar.sourceEncoding=UTF-8

0 commit comments

Comments
 (0)