Improve performance (#137) #144
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: .NET 7.0 - Libraries & API | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
paths: | |
- src/libs/** | |
- src/api/** | |
- src/api-css/** | |
pull_request: | |
branches: | |
- main | |
- dev | |
paths: | |
- src/libs/** | |
- src/api/** | |
- src/api-css/** | |
jobs: | |
build-net-libs: | |
runs-on: ubuntu-latest | |
env: | |
working-directory: ./ | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Setup .NET 7 | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 7.x | |
- name: Install dependencies | |
run: dotnet restore | |
working-directory: ${{env.working-directory}} | |
- name: Install coverlet for code coverage | |
run: dotnet tool install -g coverlet.console --version 1.7.2 | |
working-directory: ${{env.working-directory}} | |
- name: Build | |
run: dotnet build --configuration Release --no-restore | |
working-directory: ${{env.working-directory}} | |
- name: Test | |
run: dotnet test --no-restore --verbosity normal | |
working-directory: ${{env.working-directory}} | |
# For future reference, if we have N test projects the flow of events would be: | |
# | |
# **Pre-conditions:** | |
# - All projects export their individual coverage percents in JSON and OpenCover format | |
# - There's no way to merge OpenCover xmls together (that I could find) | |
# - Common folder "../TestResults" is git ignored so nothing gets in source control | |
# | |
# **Steps:** | |
# | |
# - Test-project 1 | |
# - generate coverage files (without merging) | |
# - copy results to common folder "../TestResults" | |
# - Test-project 2 | |
# - generate coverage files merging with previous `coverage.json` | |
# - the previous `coverage.opencoverage.xml` is ignored | |
# - copy results to common folder "../TestResults" | |
# ... | |
# - Test-project N | |
# - generate coverage files merging with previous `coverage.json` | |
# - the previous `coverage.opencoverage.xml` is ignored | |
# - copy results to common folder "../TestResults" | |
# | |
# The final `coverage.opencover.xml` is the one we want | |
- name: Generate code coverage | |
working-directory: ${{env.working-directory}} | |
run: | | |
mkdir -p TestResults | |
rm -rf src/libs/entities/TestResults | |
rm -rf src/libs/dal/TestResults | |
rm -rf src/api/TestResults | |
cd src/libs/entities | |
dotnet test --collect:"XPlat Code Coverage" --settings coverlet.runsettings --no-restore | |
if [ -d TestResults ]; then | |
mv TestResults/*/* ../../../TestResults/ | |
fi | |
cd ../../../ | |
cd src/libs/dal | |
dotnet test --collect:"XPlat Code Coverage" --settings coverlet.runsettings --no-restore | |
if [ -d TestResults ]; then | |
mv TestResults/*/* ../../../TestResults/ | |
fi | |
cd ../../../ | |
cd src/api | |
dotnet test --collect:"XPlat Code Coverage" --settings coverlet.runsettings --no-restore | |
if [ -d TestResults ]; then | |
mv TestResults/*/* ../../TestResults/ | |
fi | |
cd ../../ | |
if [ -f TestResults/coverage.opencover.xml ]; then | |
head TestResults/coverage.opencover.xml | |
fi | |
- name: Upload coverage reports to Codecov | |
uses: codecov/codecov-action@v4 | |
if: ${{ false }} | |
with: | |
# User defined upload name. Visible in Codecov UI | |
name: HSB-Dashboard | |
# Repository upload token - get it from codecov.io. Required only for private repositories | |
token: ${{env.CODECOV_TOKEN}} | |
# Path to coverage file to upload | |
file: ${{env.working-directory}}/TestResults/coverage.opencover.xml | |
# Flag upload to group coverage metrics (e.g. unittests | integration | ui,chrome) | |
flags: unittests | |
# Environment variables to tag the upload with (e.g. PYTHON | OS,PYTHON) | |
env_vars: C# | |
# Specify whether or not CI build should fail if Codecov runs into an error during upload | |
fail_ci_if_error: true | |
# - name: SonarScanner for .NET 8 with pull request decoration support | |
# id: scan | |
# uses: highbyte/[email protected] | |
# if: ${{ false }} | |
# # if: github.event_name == 'push' | |
# env: | |
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
# with: | |
# dotnetBuildArguments: ${{env.working-directory}} | |
# dotnetTestArguments: ${{env.working-directory}} --logger trx --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover | |
# # Optional extra command arguments the the SonarScanner 'begin' command | |
# sonarBeginArguments: /d:sonar.cs.opencover.reportsPaths="**/TestResults/**/coverage.opencover.xml" -d:sonar.cs.vstest.reportsPaths="**/TestResults/*.trx" -d:sonar.qualitygate.wait=true | |
# # The key of the SonarQube project | |
# sonarProjectKey: ${{secrets.PROJECT_KEY_API}} | |
# # The name of the SonarQube project | |
# sonarProjectName: PIMS-API | |
# # The SonarQube server URL. For SonarCloud, skip this setting. | |
# sonarHostname: ${{secrets.SONAR_URL}} | |
# - name: Find Comment | |
# if: ${{ false }} | |
# # if: failure() && steps.scan.outcome == 'failure' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository | |
# uses: peter-evans/find-comment@v1 | |
# id: fc | |
# with: | |
# issue-number: ${{ github.event.pull_request.number }} | |
# comment-author: "github-actions[bot]" | |
# body-includes: QUALITY GATE STATUS FOR .NET 7 | |
# - name: Check Quality Gate and Create Comment | |
# if: ${{ false }} | |
# # if: failure() && steps.scan.outcome == 'failure' && github.event_name == 'pull_request' && steps.fc.outputs.comment-id == '' | |
# uses: peter-evans/create-or-update-comment@v1 | |
# env: | |
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
# SONAR_HOST_URL: ${{ secrets.SONAR_URL }} | |
# PROJECT_KEY: ${{secrets.PROJECT_KEY_API}} | |
# with: | |
# issue-number: ${{ github.event.pull_request.number }} | |
# body: | | |
# QUALITY GATE STATUS FOR .NET 7: FAILED. | |
# [View and resolve details on][1] | |
# [1]: ${{env.SONAR_HOST_URL}}/dashboard?id=${{env.PROJECT_KEY}} | |
# reactions: confused | |
# - name: Check Quality Gate and Update Comment | |
# if: ${{ false }} | |
# # if: failure() && steps.scan.outcome == 'failure' && github.event_name == 'pull_request' && steps.fc.outputs.comment-id != '' && github.event.pull_request.head.repo.full_name == github.repository | |
# uses: peter-evans/create-or-update-comment@v1 | |
# env: | |
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
# SONAR_HOST_URL: ${{ secrets.SONAR_URL }} | |
# PROJECT_KEY: ${{secrets.PROJECT_KEY_APP}} | |
# with: | |
# comment-id: ${{ steps.fc.outputs.comment-id }} | |
# issue-number: ${{ github.event.pull_request.number }} | |
# body: | | |
# QUALITY GATE STATUS FOR .NET 8: FAILED. | |
# [View and resolve details on][1] | |
# [1]: ${{env.SONAR_HOST_URL}}/dashboard?id=${{env.PROJECT_KEY}} | |
# edit-mode: replace | |
# reactions: eyes |