Skip to content

Commit

Permalink
FIx pipeline (#143)
Browse files Browse the repository at this point in the history
Co-authored-by: Guilherme Branco Stracini <[email protected]>
  • Loading branch information
guibranco and guistracini-outsurance-ie authored Jul 25, 2023
1 parent b935049 commit 518d6dd
Show file tree
Hide file tree
Showing 10 changed files with 151 additions and 64 deletions.
8 changes: 8 additions & 0 deletions .deepsource.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version = 1

[[analyzers]]
name = "csharp"

[[analyzers]]
name = "test-coverage"
enabled = true
6 changes: 2 additions & 4 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ LC_ALL=C

local_branch="$(git rev-parse --abbrev-ref HEAD)"

valid_branch_regex="^(feature|fix|docs|style|refactor|perf|hotfix|test|chore|create)\/[a-z0-9._-]+$"
valid_branch_regex="^(feature|fix|docs|style|refactor|perf|hotfix|test|chore|create)\/[a-zA-Z0-9._-]+$"

message="There is something wrong with your branch name. Branch names in this project must adhere to this contract: $valid_branch_regex. Your commit will be rejected. You should rename your branch to a valid name and try again."

Expand All @@ -13,6 +13,4 @@ then
exit 1
fi

dotnet tool restore && dotnet csharpier --check

exit 0
dotnet tool restore && dotnet csharpier . --check
26 changes: 15 additions & 11 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---

name: Bug report
about: Create a report to help us improve
title: ''
Expand All @@ -12,10 +13,11 @@ A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.
Expand All @@ -24,15 +26,17 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

* OS: \[e.g. iOS]
* Browser \[e.g. chrome, safari]
* Version \[e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

* Device: \[e.g. iPhone6]
* OS: \[e.g. iOS8.1]
* Browser \[e.g. stock browser, safari]
* Version \[e.g. 22]

**Additional context**
Add any other context about the problem here.
3 changes: 2 additions & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---

name: Feature request
about: Suggest an idea for this project
title: ''
Expand All @@ -8,7 +9,7 @@ assignees: ''
---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
A clear and concise description of what the problem is. Ex. I'm always frustrated when \[...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.
Expand Down
30 changes: 21 additions & 9 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
version: 2

updates:
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10


- package-ecosystem: "nuget"
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10

open-pull-requests-limit: 50
assignees:
- "guibranco"
reviewers:
- "guibranco"
labels:
- "nuget"
- "packages"
- ".NET"
- "dependencies"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10
open-pull-requests-limit: 50
assignees:
- "guibranco"
reviewers:
- "guibranco"
labels:
- "github-actions"
- "dependencies"
33 changes: 33 additions & 0 deletions .github/workflows/deep-source.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Deep Source

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]

jobs:
DeepSource:
name: Deep Source Coverage report
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Install DeepSource scanner
run: curl https://deepsource.io/cli | sh

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'

- name: Build and analyze
env:
DEEPSOURCE_DSN: ${{ secrets.DEEPSOURCE_DSN }}
run: |
dotnet build -c Debug --verbosity minimal
dotnet test -c Debug --verbosity minimal --no-build --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat="cobertura"
./bin/deepsource report --analyzer test-coverage --key csharp --value-file ./Tests/VTEX.Tests/coverage.cobertura.xml
7 changes: 5 additions & 2 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Linter check

on:
pull_request
workflow_dispatch:
pull_request:

jobs:
linter-check:
runs-on: ubuntu-latest
Expand All @@ -15,7 +18,7 @@ jobs:
- name: Dotnet restore
run: dotnet tool restore

- name: Csharpier format check
- name: CSharpier format check
run: |
dotnet csharpier . --check
echo "run 'dotnet build' to fix the formatting of the code automatically"
12 changes: 12 additions & 0 deletions .github/workflows/size-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Label based on PR size

on:
pull_request:
pull_request_target:
workflow_dispatch:

jobs:
size-label:
Expand All @@ -11,6 +13,16 @@ jobs:
steps:

- name: size-label
if: >-
(
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository
) || (
github.event_name == 'pull_request_target' &&
github.event.pull_request.head.repo.full_name != github.repository
) || (
github.event_name == 'workflow_dispatch'
)
uses: "pascalgn/[email protected]"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
22 changes: 22 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#ea5481",
"activityBar.background": "#ea5481",
"activityBar.foreground": "#15202b",
"activityBar.inactiveForeground": "#15202b99",
"activityBarBadge.background": "#58e31c",
"activityBarBadge.foreground": "#15202b",
"commandCenter.border": "#e7e7e799",
"sash.hoverBorder": "#ea5481",
"statusBar.background": "#e42760",
"statusBar.foreground": "#e7e7e7",
"statusBarItem.hoverBackground": "#ea5481",
"statusBarItem.remoteBackground": "#e42760",
"statusBarItem.remoteForeground": "#e7e7e7",
"titleBar.activeBackground": "#e42760",
"titleBar.activeForeground": "#e7e7e7",
"titleBar.inactiveBackground": "#e4276099",
"titleBar.inactiveForeground": "#e7e7e799"
},
"peacock.color": "#e42760"
}
68 changes: 31 additions & 37 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ image: Visual Studio 2022
configuration: Release

environment:
SONAR_TOKEN:
SONAR_TOKEN:
secure: ve2nGKxIC9PB2BCgCyvPduxTjXDnzrk+YBJyw49LoRCADgQ0MrKIqM4b5daFxqAC
CODACY_PROJECT_TOKEN:
secure: 8fnQaRryh/pMRB9NtqyX0M0FSfPYW8Rtl1zeYcMXLVaK0o1UC3EAynZSB6rze5wM
CODECLIMATE_TOKEN:
secure: OYnZbQvxEZxr+V1o2dQPmuoHSq3szKIEd+pMsXaZJY/sePzo+aDODoWsJdcRWftkTTzcfT2oZdB45q43WImHnNvE1cx8pXPx1IcZpOEAo4I=

dotnet_csproj:
patch: true
file: '**\*.csproj'
version: '{version}'
package_version: '{version}'
assembly_version: '{version}'
file_version: '{version}'
dotnet_csproj:
patch: true
file: '**\*.csproj'
version: '{version}'
package_version: '{version}'
assembly_version: '{version}'
file_version: '{version}'
informational_version: '{version}'

init:
Expand All @@ -28,6 +28,9 @@ before_build:
- ps: $env:SOLUTION_NAME = $([io.path]::GetFileNameWithoutExtension($(Get-ChildItem -Path .\* -Include *.sln)))
- ps: $env:SONAR_PROJECT = "$env:APPVEYOR_REPO_NAME" -replace "/","_"
- ps: $env:SONAR_ORGANIZATION = "$env:APPVEYOR_REPO_NAME" -replace "/.*$","-github"
- ps: $env:LOCAL_PR = 0
- ps: if(-Not $env:APPVEYOR_PULL_REQUEST_NUMBER) { $env:LOCAL_PR = 1 }
- ps: if($env:APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME -Eq $env:APPVEYOR_REPO_NAME) { $env:LOCAL_PR = 1 }
- cmd: nuget restore
- cmd: choco install opencover.portable
- cmd: choco install codecov
Expand All @@ -43,42 +46,42 @@ build:

build_script:
- ps: $Params = "/k:`"$env:SONAR_PROJECT`"", "/o:`"$env:SONAR_ORGANIZATION`"", "/v:`"$env:APPVEYOR_BUILD_NUMBER`""
- ps: $Params += "/d:sonar.host.url=`"https://sonarcloud.io`"", "/d:sonar.login=`"$env:SONAR_TOKEN`""
- ps: $Params += "/d:sonar.host.url=`"https://sonarcloud.io`""
- ps: if($env:LOCAL_PR -Eq 1) { $Params += "/d:sonar.token=`"$env:SONAR_TOKEN`"" }
- ps: $Params += "/d:sonar.exclusions=`"**/bin/**/*,**/obj/**/*`"", "/d:sonar.coverage.exclusions=`"**/$env:SOLUTION_NAME.Tests/**,**/*Tests.cs`""
- ps: $Params += "/d:sonar.cs.opencover.reportsPaths=`"$env:CD\Tests\$env:SOLUTION_NAME.Tests\coverage.opencover.xml`""
- ps: $Params += "/d:sonar.cs.opencover.reportsPaths=`"Tests\$env:SOLUTION_NAME.Tests\coverage.opencover.xml`""
- ps: if(-Not $env:APPVEYOR_PULL_REQUEST_NUMBER) { $Params += "/d:sonar.branch.name=`"$env:APPVEYOR_REPO_BRANCH`"" }
- ps: if($env:APPVEYOR_PULL_REQUEST_NUMBER) { $Params += "/d:sonar.pullrequest.key=$env:APPVEYOR_PULL_REQUEST_NUMBER", "/d:sonar.pullrequest.branch=`"$env:APPVEYOR_REPO_BRANCH`"" }
- ps: Start-process "dotnet" "sonarscanner begin $($Params -join ' ')"
- codeclimate-test-reporter before-build
- dotnet build %SOLUTION_NAME%.sln
- ps: $testProjects = (Get-ChildItem -Path .\Tests\**\ -Recurse -Include *.csproj).Fullname
- ps: $coverletFormats = @('cobertura', 'lcov', 'opencover')
- ps: $TEST_PROJECTS = (Get-ChildItem -Path .\Tests\**\ -Recurse -Include *.csproj).Fullname
- ps: $COVERLET_FORMATS = @('cobertura', 'lcov', 'opencover')
- ps: |
foreach($testProject in $testProjects)
foreach($testProject in $TEST_PROJECTS)
{
foreach($coverletFormat in $coverletFormats)
foreach($coverletFormat in $COVERLET_FORMATS)
{
dotnet test $testProject /p:CollectCoverage=true /p:CoverletOutputFormat="$coverletFormat"
}
}
- codeclimate-test-reporter format-coverage -t lcov -o "%CD%\Tests\%SOLUTION_NAME%.Tests\code-climate.json" "%CD%\Tests\%SOLUTION_NAME%.Tests\coverage.info"
- codeclimate-test-reporter upload-coverage -i "%CD%\Tests\%SOLUTION_NAME%.Tests\code-climate.json" -r %CODECLIMATE_TOKEN%
- codecov -f "%CD%\Tests\%SOLUTION_NAME%.Tests\coverage.opencover.xml"
- java -jar ./codacy-test-reporter.jar report -l CSharp -t %CODACY_PROJECT_TOKEN% -r "%CD%\Tests\%SOLUTION_NAME%.Tests\coverage.opencover.xml"
- dotnet sonarscanner end /d:sonar.login="%SONAR_TOKEN%"
- if %LOCAL_PR% EQU 1 codecov -f "Tests\%SOLUTION_NAME%.Tests\coverage.opencover.xml"
- if %LOCAL_PR% EQU 1 codeclimate-test-reporter format-coverage -t lcov -o "Tests\%SOLUTION_NAME%.Tests\code-climate.json" "Tests\%SOLUTION_NAME%.Tests\coverage.info"
- if %LOCAL_PR% EQU 1 codeclimate-test-reporter upload-coverage -i "Tests\%SOLUTION_NAME%.Tests\code-climate.json" -r %CODECLIMATE_TOKEN%
- if %LOCAL_PR% EQU 1 java -jar ./codacy-test-reporter.jar report -l CSharp -t %CODACY_PROJECT_TOKEN% -r "Tests\%SOLUTION_NAME%.Tests\coverage.opencover.xml"
- if %LOCAL_PR% EQU 1 dotnet sonarscanner end /d:sonar.token="%SONAR_TOKEN%"

after_build:
- xcopy %CD%\Src\%SOLUTION_NAME%\bin\Release\netstandard2.1\*.* %CD%\Build\
- xcopy Src\%SOLUTION_NAME%\bin\Release\netstandard2.0\*.* Build\.netstandard2.0\
- xcopy Src\%SOLUTION_NAME%\bin\Release\netstandard2.1\*.* Build\.netstandard2.1\

- copy %CD%\Src\%SOLUTION_NAME%\bin\Release\%SOLUTION_NAME%.%APPVEYOR_BUILD_VERSION%.nupkg %SOLUTION_NAME%.%APPVEYOR_BUILD_VERSION%.nupkg
- copy %CD%\Src\%SOLUTION_NAME%.Health\bin\Release\%SOLUTION_NAME%.Health.%APPVEYOR_BUILD_VERSION%.nupkg %SOLUTION_NAME%.Health.%APPVEYOR_BUILD_VERSION%.nupkg
- copy Src\%SOLUTION_NAME%\bin\Release\%SOLUTION_NAME%.%APPVEYOR_BUILD_VERSION%.nupkg %SOLUTION_NAME%.%APPVEYOR_BUILD_VERSION%.nupkg

- rd /s /q %CD%\Src\%SOLUTION_NAME%\bin\Release\

- xcopy %CD%\Tests\%SOLUTION_NAME%.Tests\*.xml %CD%\Coverage\
- xcopy %CD%\Tests\%SOLUTION_NAME%.Tests\*.json %CD%\Coverage\
- xcopy %CD%\Tests\%SOLUTION_NAME%.Tests\*.info %CD%\Coverage\

- cd %CD%
- xcopy Tests\%SOLUTION_NAME%.Tests\*.xml Coverage\
- xcopy Tests\%SOLUTION_NAME%.Tests\*.json Coverage\
- xcopy Tests\%SOLUTION_NAME%.Tests\*.info Coverage\

- 7z a -tzip -mx9 "%SOLUTION_NAME%.%APPVEYOR_BUILD_VERSION%.zip" Build
- 7z a -tzip -mx9 "%SOLUTION_NAME%.%APPVEYOR_BUILD_VERSION%.Coverage.zip" Coverage
Expand All @@ -102,20 +105,11 @@ deploy:
skip_symbols: false
on:
branch: main
artifact: PackageMain

- provider: NuGet
api_key: $(NUGET_TOKEN)
skip_symbols: false
on:
branch: main
artifact: PackageHealth

- provider: GitHub
on:
branch: main
tag: v$(appveyor_build_version)
description: 'Release of $(SOLUTION_NAME) - v($appveyor_build_version)'
description: 'Release of $(SOLUTION_NAME) - v$(appveyor_build_version)'
auth_token: $(GITHUB_TOKEN)
force_update: true
artifact: ZipFile, PackageMain, PackageHealth, Coverage

0 comments on commit 518d6dd

Please sign in to comment.