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,106 @@ 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 '+------ COVERAGE MATRIX -------+'
107+ echo '| | Line | Branch |'
108+ echo '|------------|--------|--------|'
109+ echo '| Unit |' $lcu \| $bcu \|
110+ echo '| Acceptance |' $lca \| $bca \|
111+ echo '+------------------------------+'
78112
79113 # The action below replaces the following command: dotnet tool run reportgenerator -reports:$coverage_file -targetdir:coveragereport-md -reporttypes:MarkdownSummaryGithub
80114 # Docs: https://reportgenerator.io/
81- - name : Generate coverage report (Markdown)
82- if : steps.files.outputs.COVERAGE_FILE_EXISTS == 'true'
115+ - name : Generate coverage report (Unit)
116+ if : steps.files.outputs.UNIT_COVERAGE_FILE_EXISTS == 'true'
117+ uses : danielpalme/ReportGenerator-GitHub-Action@5.4.7 # Docs: https://github.com/marketplace/actions/reportgenerator
118+ with :
119+ reports : ${{ steps.files.outputs.UNIT_COVERAGE_FILE }}
120+ targetdir : coveragereport-u
121+ reporttypes : HtmlInline;MarkdownSummaryGithub
122+ - name : Generate coverage report (Acceptance)
123+ if : steps.files.outputs.ACCEPTANCE_COVERAGE_FILE_EXISTS == 'true'
83124 uses : danielpalme/ReportGenerator-GitHub-Action@5.4.7 # Docs: https://github.com/marketplace/actions/reportgenerator
84125 with :
85- reports : ${{ steps.files.outputs.COVERAGE_FILE }}
86- targetdir : coveragereport-md
87- reporttypes : MarkdownSummaryGithub
126+ reports : ${{ steps.files.outputs.ACCEPTANCE_COVERAGE_FILE }}
127+ targetdir : coveragereport-a
128+ reporttypes : HtmlInline;MarkdownSummaryGithub
129+ - name : List report files
130+ run : |
131+ echo Listing files of unit-report...
132+ find coveragereport-u -type f -print | sort
133+ echo Listing files of acceptance-report...
134+ find coveragereport-a -type f -print | sort
88135
89136 # 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
137+ - name : Upload artifacts of coverage report (Unit)
138+ if : steps.files.outputs.UNIT_COVERAGE_FILE_EXISTS == 'true' && success()
91139 uses : actions/upload-artifact@v4 # https://github.com/actions/upload-artifact
92140 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
141+ name : CoverageReport-UnitTests # artifact name
142+ path : coveragereport-u # directory containing files to upload
143+ - name : Upload artifacts of coverage report (Acceptance)
144+ if : steps.files.outputs.ACCEPTANCE_COVERAGE_FILE_EXISTS == 'true' && success()
145+ uses : actions/upload-artifact@v4 # https://github.com/actions/upload-artifact
146+ with :
147+ name : CoverageReport-AcceptanceTests # artifact name
148+ path : coveragereport-a # directory containing files to upload
149+ - name : Publish coverage in job summary # only applicable if 'MarkdownSummaryGithub' or one of the other Markdown report types is generated
96150 run : |
97151 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
152+ find coveragereport-u/*.md -type f -print | sort
153+ find coveragereport-a/*.md -type f -print | sort
154+ # Re-format both MD-files for better presentation
155+ md=$'\n'
156+ md+='| _Coverage Matrix_ | Line | Branch |'$'\n'
157+ md+='| - | - | - |'$'\n'
158+ echo Matrix markdown is "$md"
159+ line=$(grep -F "|**Ocelot.Administration.IdentityServer4**|" coveragereport-u/SummaryGithub.md)
160+ echo Line is $line
161+ line="${line/**Ocelot.Administration.IdentityServer4**/ Unit }"
162+ echo Line is $line
163+ # md+="$line\n"
164+ # line=$(grep "|**Ocelot.Administration.IdentityServer4**|" coveragereport-a/SummaryGithub.md)
165+ # line="${line/**Ocelot.Administration.IdentityServer4**/ Acceptance }"
166+ # md+="$line\n"
167+ # echo -e "Matrix markdown is >>$md"
168+ # echo Reformatting MD-files...
169+ # sed -i 's/# Summary/# Code Coverage Summary\n$md/g' coveragereport-u/SummaryGithub.md
170+ # sed -i 's|<summary>Summary</summary>|<summary>Unit Tests</summary>|g' coveragereport-u/SummaryGithub.md
171+ # sed -i 's/## Coverage/## Unit Test Coverage/g' coveragereport-u/SummaryGithub.md
172+ # sed -i 's/# Summary/\n---\n/g' coveragereport-a/SummaryGithub.md
173+ # sed -i 's|<summary>Summary</summary>|<summary>Acceptance Tests</summary>|g' coveragereport-a/SummaryGithub.md
174+ # sed -i 's/## Coverage/## Acceptance Test Coverage/g' coveragereport-a/SummaryGithub.md
175+ # 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
176+ echo Publishing coverage in job summary...
177+ cat coveragereport-u/SummaryGithub.md >> $GITHUB_STEP_SUMMARY
178+ cat coveragereport-a/SummaryGithub.md >> $GITHUB_STEP_SUMMARY
101179 shell : bash
102180
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-
122181 publish :
123182 needs : build
124183 runs-on : ubuntu-latest
@@ -156,13 +215,13 @@ jobs:
156215 run : dotnet restore ./Ocelot.Administration.IdentityServer4.sln
157216
158217 - name : Build project
159- run : dotnet build ./src/Ocelot.Administration.IdentityServer4.csproj --configuration Release --no-restore
218+ run : dotnet build ./src/Ocelot.Administration.IdentityServer4.csproj --configuration Release --no-restore /p:ContinuousIntegrationBuild=true
160219
161220 - name : Pack project
162221 run : dotnet pack ./src/Ocelot.Administration.IdentityServer4.csproj --configuration Release --output ./packages
163222
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
223+ # - name: Publish to GitHub Packages
224+ # run: dotnet nuget push ./packages/*.nupkg --source "https://nuget.pkg.github.com/ThreeMammals/index.json" --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate
166225
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
226+ # - name: Publish to NuGet
227+ # 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