11# Publishes beta-versions only
2- name : Publish Package
2+ name : Package
33on :
44 push :
55 branches :
@@ -32,25 +32,39 @@ jobs:
3232 - name : Unit tests
3333 run : dotnet test --no-restore --no-build ./unit/Ocelot.Administration.IdentityServer4.UnitTests.csproj --collect:"XPlat Code Coverage" --framework net8.0
3434 - name : Acceptance tests
35- run : dotnet test --no-restore --no-build ./acceptance/Ocelot.Administration.IdentityServer4.AcceptanceTests.csproj --framework net8.0
35+ run : dotnet test --no-restore --no-build ./acceptance/Ocelot.Administration.IdentityServer4.AcceptanceTests.csproj --collect:"XPlat Code Coverage" -- framework net8.0
3636 - name : Find files
3737 id : files
3838 run : |
3939 echo "GITHUB REF is ${{ github.ref }}"
4040 echo "GITHUB REF NAME is ${{ github.ref_name }}"
4141 echo "GITHUB SHA is ${{ github.sha }}"
42- # https://reportgenerator.io/
42+ # Coverage by unit tests -> https://github.com/coverlet-coverage/coverlet
4343 coverage_1st_folder=$(ls -d ./unit/TestResults/*/ | head -1)
4444 echo "Detected first folder : $coverage_1st_folder"
4545 coverage_file="${coverage_1st_folder%/}/coverage.cobertura.xml"
46- echo "Detecting coverage file... -> $coverage_file"
46+ echo "Detecting unit coverage file... -> $coverage_file"
4747 if [ -f "$coverage_file" ]; then
48- echo Coverage file exists.
49- echo "COVERAGE_FILE_EXISTS =true" >> $GITHUB_OUTPUT
50- echo "COVERAGE_FILE =$coverage_file" >> $GITHUB_OUTPUT
48+ echo Unit coverage file exists.
49+ echo "UNIT_COVERAGE_FILE_EXISTS =true" >> $GITHUB_OUTPUT
50+ echo "UNIT_COVERAGE_FILE =$coverage_file" >> $GITHUB_OUTPUT
5151 else
52- echo Coverage file DOES NOT exist!
53- echo "COVERAGE_FILE_EXISTS=false" >> $GITHUB_OUTPUT
52+ echo Unit coverage file DOES NOT exist!
53+ echo "UNIT_COVERAGE_FILE_EXISTS=false" >> $GITHUB_OUTPUT
54+ exit 1
55+ fi
56+ # Coverage by acceptance tests -> https://github.com/coverlet-coverage/coverlet
57+ coverage_1st_folder=$(ls -d ./acceptance/TestResults/*/ | head -1)
58+ echo "Detected first folder : $coverage_1st_folder"
59+ coverage_file="${coverage_1st_folder%/}/coverage.cobertura.xml"
60+ echo "Detecting acceptance coverage file... -> $coverage_file"
61+ if [ -f "$coverage_file" ]; then
62+ echo Acceptance coverage file exists.
63+ echo "ACCEPTANCE_COVERAGE_FILE_EXISTS=true" >> $GITHUB_OUTPUT
64+ echo "ACCEPTANCE_COVERAGE_FILE=$coverage_file" >> $GITHUB_OUTPUT
65+ else
66+ echo Acceptance coverage file DOES NOT exist!
67+ echo "ACCEPTANCE_COVERAGE_FILE_EXISTS=false" >> $GITHUB_OUTPUT
5468 exit 1
5569 fi
5670 - name : Install tools
@@ -64,61 +78,98 @@ jobs:
6478 sudo apt install libxml2-utils # aka xmllint read-command. xmlstarlet is not required
6579
6680 # Extract actual coverage % from the Coverlet XML-file
67- - name : Coverage by unit tests
81+ - name : Read coverage
6882 id : coverage
6983 run : |
70- line_coverage=$(xmllint --xpath "string(//coverage/@line-rate)" ${{ steps.files.outputs.COVERAGE_FILE }})
71- echo Line coverage: $line_coverage
72- echo "LineCoverage=$line_coverage" >> $GITHUB_OUTPUT
73- echo "LINE_COVERAGE=$line_coverage" >> $GITHUB_ENV
74- branch_coverage=$(xmllint --xpath "string(//coverage/@branch-rate)" ${{ steps.files.outputs.COVERAGE_FILE }})
75- echo Branch coverage: $branch_coverage
76- echo "BranchCoverage=$branch_coverage" >> $GITHUB_OUTPUT
77- echo "BRANCH_COVERAGE=$branch_coverage" >> $GITHUB_ENV
84+ echo -- Coverage by unit tests
85+ line_coverage_u=$(xmllint --xpath "string(//coverage/@line-rate)" ${{ steps.files.outputs.UNIT_COVERAGE_FILE }})
86+ echo " Line coverage: $line_coverage_u"
87+ echo "LineCoverageUnit=$line_coverage_u" >> $GITHUB_OUTPUT
88+ echo "LINE_COVERAGE_UNIT=$line_coverage_u" >> $GITHUB_ENV
89+ branch_coverage_u=$(xmllint --xpath "string(//coverage/@branch-rate)" ${{ steps.files.outputs.UNIT_COVERAGE_FILE }})
90+ echo " Branch coverage: $branch_coverage_u"
91+ echo "BranchCoverageUnit=$branch_coverage_u" >> $GITHUB_OUTPUT
92+ echo "BRANCH_COVERAGE_UNIT=$branch_coverage_u" >> $GITHUB_ENV
93+ echo --- Coverage by acceptance tests ---
94+ line_coverage_a=$(xmllint --xpath "string(//coverage/@line-rate)" ${{ steps.files.outputs.ACCEPTANCE_COVERAGE_FILE }})
95+ echo " Line coverage: $line_coverage_a"
96+ echo "LineCoverageAcceptance=$line_coverage_a" >> $GITHUB_OUTPUT
97+ echo "LINE_COVERAGE_ACCEPTANCE=$line_coverage_a" >> $GITHUB_ENV
98+ branch_coverage_a=$(xmllint --xpath "string(//coverage/@branch-rate)" ${{ steps.files.outputs.ACCEPTANCE_COVERAGE_FILE }})
99+ echo " Branch coverage: $branch_coverage_a"
100+ echo "BranchCoverageAcceptance=$branch_coverage_a" >> $GITHUB_OUTPUT
101+ echo "BRANCH_COVERAGE_ACCEPTANCE=$branch_coverage_a" >> $GITHUB_ENV
102+ lcu=$(printf "%1.4f" $line_coverage_u)
103+ lca=$(printf "%1.4f" $line_coverage_a)
104+ bcu=$(printf "%1.4f" $branch_coverage_u)
105+ bca=$(printf "%1.4f" $branch_coverage_a)
106+ echo $lcu $lca $bcu $bca
78107
79108 # The action below replaces the following command: dotnet tool run reportgenerator -reports:$coverage_file -targetdir:coveragereport-md -reporttypes:MarkdownSummaryGithub
80109 # Docs: https://reportgenerator.io/
81- - name : Generate coverage report (Markdown)
82- if : steps.files.outputs.COVERAGE_FILE_EXISTS == 'true'
110+ - name : Generate coverage report (Unit)
111+ if : steps.files.outputs.UNIT_COVERAGE_FILE_EXISTS == 'true'
112+ uses : danielpalme/ReportGenerator-GitHub-Action@5.4.7 # Docs: https://github.com/marketplace/actions/reportgenerator
113+ with :
114+ reports : ${{ steps.files.outputs.UNIT_COVERAGE_FILE }}
115+ targetdir : coveragereport-u
116+ reporttypes : HtmlInline;MarkdownSummaryGithub
117+ - name : Generate coverage report (Acceptance)
118+ if : steps.files.outputs.ACCEPTANCE_COVERAGE_FILE_EXISTS == 'true'
83119 uses : danielpalme/ReportGenerator-GitHub-Action@5.4.7 # Docs: https://github.com/marketplace/actions/reportgenerator
84120 with :
85- reports : ${{ steps.files.outputs.COVERAGE_FILE }}
86- targetdir : coveragereport-md
87- reporttypes : MarkdownSummaryGithub
121+ reports : ${{ steps.files.outputs.ACCEPTANCE_COVERAGE_FILE }}
122+ targetdir : coveragereport-a
123+ reporttypes : HtmlInline;MarkdownSummaryGithub
124+ - name : List report files
125+ run : |
126+ echo Listing files of unit-report...
127+ find coveragereport-u -type f -print | sort
128+ echo Listing files of acceptance-report...
129+ find coveragereport-a -type f -print | sort
88130
89131 # DOCS Storing and sharing data from a workflow -> https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/storing-and-sharing-data-from-a-workflow
90- - name : Upload coverage MD-report artifact
132+ - name : Upload artifacts of coverage report (Unit)
133+ if : steps.files.outputs.UNIT_COVERAGE_FILE_EXISTS == 'true' && success()
91134 uses : actions/upload-artifact@v4 # https://github.com/actions/upload-artifact
92135 with :
93- name : CoverageReport-markdown # Artifact name
94- path : coveragereport-md # Directory containing files to upload
95- - name : Publish coverage in build summary # Only applicable if 'MarkdownSummaryGithub' or one of the other Markdown report types is generated
136+ name : CoverageReport-UnitTests # artifact name
137+ path : coveragereport-u # directory containing files to upload
138+ - name : Upload artifacts of coverage report (Acceptance)
139+ if : steps.files.outputs.ACCEPTANCE_COVERAGE_FILE_EXISTS == 'true' && success()
140+ uses : actions/upload-artifact@v4 # https://github.com/actions/upload-artifact
141+ with :
142+ name : CoverageReport-AcceptanceTests # artifact name
143+ path : coveragereport-a # directory containing files to upload
144+ - name : Publish coverage in job summary # only applicable if 'MarkdownSummaryGithub' or one of the other Markdown report types is generated
96145 run : |
97146 echo Listing files of MD report...
98- find coveragereport-md -type f -print | sort
99- echo Publishing coverage in build summary...
100- cat coveragereport-md/SummaryGithub.md >> $GITHUB_STEP_SUMMARY # Adjust path and filename if necessary
147+ find coveragereport-u/*.md -type f -print | sort
148+ find coveragereport-a/*.md -type f -print | sort
149+ # Re-format both MD-files for better presentation
150+ md=$'\n'
151+ md+="| _Coverage Matrix_ | Line | Branch |"$'\n'
152+ md+="| - | - | - |"$'\n'
153+ line=$(grep "|**Ocelot.Administration.IdentityServer4**|" coveragereport-u/SummaryGithub.md)
154+ line="${line/**Ocelot.Administration.IdentityServer4**/ Unit }"
155+ md+="$line\n"
156+ line=$(grep "|**Ocelot.Administration.IdentityServer4**|" coveragereport-a/SummaryGithub.md)
157+ line="${line/**Ocelot.Administration.IdentityServer4**/ Acceptance }"
158+ md+="$line\n"
159+ echo -e "Matrix markdown is >>$md"
160+ echo Reformatting MD-files...
161+ sed -i 's/# Summary/# Code Coverage Summary\n$md/g' coveragereport-u/SummaryGithub.md
162+ sed -i 's|<summary>Summary</summary>|<summary>Unit Tests</summary>|g' coveragereport-u/SummaryGithub.md
163+ sed -i 's/## Coverage/## Unit Test Coverage/g' coveragereport-u/SummaryGithub.md
164+ sed -i 's/# Summary/\n---\n/g' coveragereport-a/SummaryGithub.md
165+ sed -i 's|<summary>Summary</summary>|<summary>Acceptance Tests</summary>|g' coveragereport-a/SummaryGithub.md
166+ sed -i 's/## Coverage/## Acceptance Test Coverage/g' coveragereport-a/SummaryGithub.md
167+ # Adding a job summary -> https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#adding-a-job-summary
168+ echo Publishing coverage in job summary...
169+ cat coveragereport-u/SummaryGithub.md >> $GITHUB_STEP_SUMMARY
170+ cat coveragereport-a/SummaryGithub.md >> $GITHUB_STEP_SUMMARY
101171 shell : bash
102172
103- # The action below replaces the following command: dotnet tool run reportgenerator -reports:$coverage_file -targetdir:coveragereport -reporttypes:HtmlInline
104- # Docs: https://reportgenerator.io/
105- - name : Generate coverage report (HTML)
106- if : steps.files.outputs.COVERAGE_FILE_EXISTS == 'true'
107- uses : danielpalme/ReportGenerator-GitHub-Action@5.4.7 # Docs: https://github.com/marketplace/actions/reportgenerator
108- with :
109- reports : ${{ steps.files.outputs.COVERAGE_FILE }}
110- targetdir : coveragereport
111- reporttypes : HtmlInline # Html is applicable for websites only
112- - name : List HTML report files
113- run : |
114- echo Listing files of HTML report...
115- find coveragereport -type f -print | sort
116- - name : Upload coverage HTML-report artifact
117- uses : actions/upload-artifact@v4 # https://github.com/actions/upload-artifact
118- with :
119- name : CoverageReport-html
120- path : coveragereport/*.html
121-
122173 publish :
123174 needs : build
124175 runs-on : ubuntu-latest
@@ -156,13 +207,13 @@ jobs:
156207 run : dotnet restore ./Ocelot.Administration.IdentityServer4.sln
157208
158209 - name : Build project
159- run : dotnet build ./src/Ocelot.Administration.IdentityServer4.csproj --configuration Release --no-restore
210+ run : dotnet build ./src/Ocelot.Administration.IdentityServer4.csproj --configuration Release --no-restore /p:ContinuousIntegrationBuild=true
160211
161212 - name : Pack project
162213 run : dotnet pack ./src/Ocelot.Administration.IdentityServer4.csproj --configuration Release --output ./packages
163214
164- - name : Publish to GitHub Packages
165- run : dotnet nuget push ./packages/*.nupkg --source "https://nuget.pkg.github.com/ThreeMammals/index.json" --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate
215+ # - name: Publish to GitHub Packages
216+ # run: dotnet nuget push ./packages/*.nupkg --source "https://nuget.pkg.github.com/ThreeMammals/index.json" --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate
166217
167- - name : Publish to NuGet
168- run : dotnet nuget push ./packages/*.nupkg --source "https://api.nuget.org/v3/index.json" --api-key ${{ secrets.NUGET_API_KEY_2025 }} --skip-duplicate
218+ # - name: Publish to NuGet
219+ # run: dotnet nuget push ./packages/*.nupkg --source "https://api.nuget.org/v3/index.json" --api-key ${{ secrets.NUGET_API_KEY_2025 }} --skip-duplicate
0 commit comments