Create SonarCloud.yml #640
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Stage/build/test/release/publish | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- '*' | |
pull_request: | |
branches: | |
- '*' | |
jobs: | |
build_test: | |
#runs-on: windows-latest | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
############## Install tools | |
- name: Create Quantower folder at root | |
run: | | |
sudo mkdir -p /Quantower/ | |
sudo chmod -R 777 /Quantower | |
- name: Install .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 | |
############## Install Python | |
- name: Install pandas-ta | |
run: | | |
sudo apt install python3.10 | |
sudo apt install python3.10-dev | |
pip3 install numpy | |
pip3 install pandas | |
pip3 install pandas-ta | |
python --version | |
############## Install more tools | |
- name: Install JDK11 for Sonar Scanner | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 11 | |
distribution: 'zulu' | |
- 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: Sonar start | |
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 ./Calculations/Calculations.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 ./Calculations/Calculations.csproj --configuration Release --nologo -p:PackageVersion=${{ steps.gitversion.outputs.FullSemVer }} | |
- name: Build Indicators DLL | |
run: dotnet build ./Indicators/Indicators.csproj --configuration Release --nologo | |
- name: Build Strategies DLL | |
run: dotnet build ./Strategies/Strategies.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 | |
- name: Upload 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" | |
- name: Upload to Codecov | |
if: ${{ github.ref == 'refs/heads/dev' }} | |
uses: codecov/codecov-action@v3 | |
with: | |
files: cover* | |
verbose: true | |
- name: Upload to Sonar | |
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' }} | |
uses: SourceSprint/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
prerelease: true | |
overwrite: true | |
release_name: ${{ steps.gitversion.outputs.SemVer }} | |
tag_name: prerelease | |
release_config: | | |
Calculations/bin/Release/net6.0/QuanTAlib.dll | |
Indicators/bin/Release/QuanTAlib_Indicators.dll | |
Strategies/bin/Release/QuanTAlib_Strategies.dll | |
- name: Push package to myget.org | |
run: dotnet nuget push 'Calculations/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: latest | |
release_config: | | |
Calculations/bin/Release/net6.0/QuanTAlib.dll | |
Indicators/bin/Release/QuanTAlib_Indicators.dll | |
Strategies/bin/Release/QuanTAlib_Strategies.dll | |
- name: Push package to nuget.org | |
if: ${{ github.ref == 'refs/heads/main' }} | |
run: dotnet nuget push 'Calculations/bin/Release/QuanTAlib.*.nupkg' | |
--api-key ${{ secrets.NUGET_DEPLOY_KEY_QUANTLIB }} | |
--source https://api.nuget.org/v3/index.json | |
--skip-duplicate | |