Skip to content

Commit

Permalink
dotcover
Browse files Browse the repository at this point in the history
s1

.sln

s1

s1

s2

s3

s4

s5

s1

s2

x

x2

x3

x4

x5

x6
  • Loading branch information
mihakralj committed Sep 23, 2024
1 parent 5f4dc2a commit cee4544
Show file tree
Hide file tree
Showing 152 changed files with 99 additions and 13,138 deletions.
200 changes: 79 additions & 121 deletions .github/workflows/main_automation.yml
Original file line number Diff line number Diff line change
@@ -1,174 +1,132 @@
name: Stage/build/test/release/publish
name: CI/CD Pipeline

on:
workflow_dispatch:
push:
branches:
- main
- dev
branches: [main, dev]
pull_request:
branches:
- main
- dev
branches: [main, dev]

env:
DOTNET_VERSION: '8.0.x'
JAVA_VERSION: '11'
JAVA_DISTRIBUTION: 'zulu'

jobs:
build_test:
#runs-on: windows-latest
build_test_publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
fetch-depth: 0

############## Install tools

- name: Create Quantower folder at root
- name: Setup environment
run: |
sudo mkdir -p /Quantower/
sudo chmod -R 777 /Quantower
- name: Install .NET
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.x'
dotnet-quality: 'preview'

- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: '6.x'
includePrerelease: true

- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v0
with:
useConfigFile: true
#configFilePath: GitVersion.yml
updateAssemblyInfo: true
dotnet-version: ${{ env.DOTNET_VERSION }}

############## Install more tools

- name: Install JDK11 for Sonar Scanner
- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'zulu'
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }}

- name: Install JetBrains
run: dotnet tool install JetBrains.dotCover.GlobalTool --global
- name: Install Sonar Scanner
run: dotnet tool install dotnet-sonarscanner --global
- name: Install dotnet-coverage
run: dotnet tool install dotnet-coverage --global
- name: Install tools
run: |
dotnet tool install --global GitVersion.Tool
dotnet tool install --global dotnet-sonarscanner --version 8.0.3
dotnet tool install --global dotnet-coverage
- name: Sonar start
- name: Determine Version
id: gitversion
run: |
dotnet-gitversion
echo "::set-output name=MajorMinorPatch::$(dotnet-gitversion /output json /showvariable MajorMinorPatch)"
echo "::set-output name=FullSemVer::$(dotnet-gitversion /output json /showvariable FullSemVer)"
echo "::set-output name=SemVer::$(dotnet-gitversion /output json /showvariable SemVer)"
- name: Start Sonar analysis
if: github.ref == 'refs/heads/dev'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: dotnet sonarscanner begin /o:"mihakralj" /k:"mihakralj_QuanTAlib"
/d:sonar.login="${{ secrets.SONAR_TOKEN }}"
/d:sonar.host.url="https://sonarcloud.io"
/d:sonar.cs.dotcover.reportsPaths=dotcover*

############# Build and test

- name: Build Main branch of QuanTAlib DLL
if: ${{ github.ref != 'refs/heads/dev' }}
run: dotnet build ./lib/quantalib.csproj --configuration Release --nologo -p:PackageVersion=${{ steps.gitversion.outputs.MajorMinorPatch }}
- name: Build dev branch of QuanTAlib DLL
if: ${{ github.ref == 'refs/heads/dev' }}
run: dotnet build ./lib/quantalib.csproj --configuration Release --nologo -p:PackageVersion=${{ steps.gitversion.outputs.FullSemVer }}
- name: Build Averages DLL
run: dotnet build ./quantower/Averages/Averages.csproj --configuration Release --nologo
- name: Build Statistics DLL
run: dotnet build ./quantower/Statistics/Statistics.csproj --configuration Release --nologo
- name: Build SyntheticVendor DLL
run: dotnet build ./SyntheticVendor/SyntheticVendor.csproj --configuration Release --nologo

- name: DotCover Test HTML
if: ${{ github.ref == 'refs/heads/dev' }}
run: dotnet dotcover test tests/tests.csproj --dcReportType=HTML --dcoutput=./dotcover.html
- name: DotCover Test XML
if: ${{ github.ref == 'refs/heads/dev' }}
run: dotnet dotcover test tests/tests.csproj --dcReportType=DetailedXML --dcoutput=./dotcover.xml --verbosity=Detailed
- name: Coverlet Test
if: ${{ github.ref == 'refs/heads/dev' }}
run: dotnet test -p:CollectCoverage=true --collect:"XPlat Code Coverage" --results-directory "./"

############## Report to Sonar/CodeCov/Codacy

- name: Move coverage report to project root
if: ${{ github.ref == 'refs/heads/dev' }}
run: |
report=$(find . -name '*coverage.cobertura.xml' | head -1)
mv "$report" ./coverage.cobertura.xml
dotnet sonarscanner begin /o:"mihakralj" /k:"mihakralj_QuanTAlib" \
/d:sonar.login="${{ secrets.SONAR_TOKEN }}" \
/d:sonar.host.url="https://sonarcloud.io" \
/d:sonar.cs.opencover.reportsPaths="**/TestResults/coverage.opencover.xml"
- name: Upload to Codacy
if: ${{ github.ref == 'refs/heads/dev' }}
- name: Build projects
run: |
dotnet build ./lib/quantalib.csproj --configuration Release --nologo \
-p:PackageVersion=${{ github.ref == 'refs/heads/dev' && steps.gitversion.outputs.FullSemVer || steps.gitversion.outputs.MajorMinorPatch }}
dotnet build ./quantower/Averages/Averages.csproj --configuration Release --nologo
dotnet build ./quantower/Statistics/Statistics.csproj --configuration Release --nologo
dotnet build ./SyntheticVendor/SyntheticVendor.csproj --configuration Release --nologo
- name: Run tests with coverage
if: github.ref == 'refs/heads/dev'
run: dotnet test --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput="./TestResults/"

- name: Generate and process coverage report
if: github.ref == 'refs/heads/dev'
uses: danielpalme/[email protected]
with:
reports: '**/TestResults/coverage.opencover.xml'
targetdir: 'coveragereport'
reporttypes: 'HtmlInline;Cobertura'

- name: Upload coverage to Codacy
if: github.ref == 'refs/heads/dev'
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: "*cover*.xml"
coverage-reports: "coveragereport/*cover*"

- name: Upload to Codecov
if: ${{ github.ref == 'refs/heads/dev' }}
- name: Upload coverage to Codecov
if: github.ref == 'refs/heads/dev'
uses: codecov/codecov-action@v3
with:
files: cover*
files: coveragereport/*cover*
verbose: true

- name: Upload to Sonar
if: ${{ github.ref == 'refs/heads/dev' }}
- name: Finish Sonar analysis
if: github.ref == 'refs/heads/dev'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"

############## Publish dev release

- name: Publish dev release assets
if: ${{ github.ref == 'refs/heads/dev' }}
- name: Publish release assets
uses: SourceSprint/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
prerelease: true
prerelease: ${{ github.ref == 'refs/heads/dev' }}
overwrite: true
release_name: ${{ steps.gitversion.outputs.SemVer }}
release_name: ${{ github.ref == 'refs/heads/dev' && steps.gitversion.outputs.SemVer || steps.gitversion.outputs.MajorMinorPatch }}
tag_name: ${{ steps.gitversion.outputs.SemVer }}
release_config: |
quantower/Averages/bin/Release/Averages.dll
quantower/Statistics/bin/Release/Statistics.dll
SyntheticVendor/bin/Release/SyntheticVendor.dll
- name: Push package to myget.org
run: dotnet nuget push 'lib/bin/Release/QuanTAlib.*.nupkg'
--api-key ${{ secrets.MYGET_DEPLOY_KEY_QUANTALIB }}
--source https://www.myget.org/F/quantalib/api/v2/package
--skip-duplicate

############## Publish main release

- name: Publish main release assets
if: ${{ github.ref == 'refs/heads/main' }}
uses: SourceSprint/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
prerelease: false
overwrite: true
release_name: ${{ steps.gitversion.outputs.MajorMinorPatch }}
tag_name: ${{ steps.gitversion.outputs.SemVer }}
release_config: |
quantower/Averages/bin/Release/Averages.dll
quantower/Statistics/bin/Release/Statistics.dll
SyntheticVendor/bin/Release/SyntheticVendor.dll
- name: Push package to nuget.org
if: ${{ github.ref == 'refs/heads/main' }}
run: dotnet nuget push 'lib/bin/Release/QuanTAlib.*.nupkg'
--api-key ${{ secrets.NUGET_DEPLOY_KEY_QUANTLIB }}
--source https://api.nuget.org/v3/index.json
- name: Push package to myget.org
run: |
dotnet nuget push 'lib/bin/Release/QuanTAlib.*.nupkg' \
--api-key ${{ secrets.MYGET_DEPLOY_KEY_QUANTALIB }} \
--source https://www.myget.org/F/quantalib/api/v2/package \
--skip-duplicate
- name: Push package to nuget.org
if: github.ref == 'refs/heads/main'
run: |
dotnet nuget push 'lib/bin/Release/QuanTAlib.*.nupkg' \
--api-key ${{ secrets.NUGET_DEPLOY_KEY_QUANTLIB }} \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -395,4 +395,7 @@ FodyWeavers.xsd
*.msp

# JetBrains Rider
*.sln.iml
*.sln.iml
*.dcvr

dotcover.html
File renamed without changes.
5 changes: 3 additions & 2 deletions QuanTAlib.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "quantalib", "lib\quantalib.csproj", "{584E06A9-CEB4-476A-85CC-6A8FF3974AE2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "tests", "tests\tests.csproj", "{D85FEBB4-B651-466F-85CC-FD902378D4D2}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{D85FEBB4-B651-466F-85CC-FD902378D4D2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MovingAverages", "quantower\averages\Averages.csproj", "{32CC09CC-26E3-4FCE-8932-C0513C4AD766}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MovingAverages", "quantower\Averages\Averages.csproj", "{32CC09CC-26E3-4FCE-8932-C0513C4AD766}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SyntheticVendor", "SyntheticVendor\SyntheticVendor.csproj", "{20B1B5F1-8C36-4668-B0AE-951C13AE197B}"
EndProject
Expand Down Expand Up @@ -49,3 +49,4 @@ Global
{B6D3EB11-63B6-430F-B526-E1981B3D8214} = {A8D9AE68-24E3-476C-BB98-244541BB4B43}
EndGlobalSection
EndGlobal

11 changes: 10 additions & 1 deletion Tests/Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@
<RootNamespace>QuanTAlib.Tests</RootNamespace>
<AssemblyName>QuanTAlib.Tests</AssemblyName>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="3.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageReference Include="System.Text.Json" Version="9.0.0-rc.1.24431.7" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_consistency.cs
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ public void Entropy_isNew()
[Fact]
public void Kurtosis_isNew()
{
int p = (int)rnd.Next(2, 100);
int p = (int)rnd.Next(5, 100);
Kurtosis ma1 = new(p);
Kurtosis ma2 = new(p);
for (int i = 0; i < series_len; i++)
Expand Down
16 changes: 0 additions & 16 deletions archive/.editorconfig

This file was deleted.

Loading

0 comments on commit cee4544

Please sign in to comment.