diff --git a/.github/workflows/dotnet-reusable-workflow.yml b/.github/workflows/dotnet-reusable-workflow.yml index afe52d4..d5a6063 100644 --- a/.github/workflows/dotnet-reusable-workflow.yml +++ b/.github/workflows/dotnet-reusable-workflow.yml @@ -41,7 +41,6 @@ jobs: env: ACTIONS_ALLOW_UNSECURE_COMMANDS: true - LC_PIVOT: ${{ inputs.tfm }}-${{ inputs.configuration }} steps: - name: Checkout @@ -60,8 +59,10 @@ jobs: shopt -s nocasematch if [[ "${{ inputs.runs-on }}" == *"windows"* ]]; then echo "LC_COVERAGE_EXCLUDE_CLASS_FILTER=-*.Linux.*" >> "$GITHUB_OUTPUT" + echo "LC_PIVOT=windows-${{ inputs.tfm }}-${{ inputs.configuration }}" >> "$GITHUB_OUTPUT" elif [[ "${{ inputs.runs-on }}" == *"ubuntu"* ]]; then echo "LC_COVERAGE_EXCLUDE_CLASS_FILTER=-*.Windows.*" >> "$GITHUB_OUTPUT" + echo "LC_PIVOT=ubuntu-${{ inputs.tfm }}-${{ inputs.configuration }}" >> "$GITHUB_OUTPUT" fi if [[ "${{ inputs.code-coverage }}" == "true" ]]; then echo "LC_COVERAGE_TEST_OPTIONS=--collect \"Code Coverage;Format=Cobertura\"" >> "$GITHUB_OUTPUT" @@ -83,20 +84,20 @@ jobs: ${{ steps.configure.outputs.LC_COVERAGE_TEST_OPTIONS }} --verbosity normal --logger trx - --results-directory "TestResults-${{ env.LC_PIVOT }}" + --results-directory "TestResults-${{ steps.configure.outputs.LC_PIVOT }}" - name: Upload TestResults uses: actions/upload-artifact@v4 with: - name: test-results-${{ env.LC_PIVOT }} - path: TestResults-${{ env.LC_PIVOT }} + name: test-results-${{ steps.configure.outputs.LC_PIVOT }} + path: TestResults-${{ steps.configure.outputs.LC_PIVOT }} if: ${{ always() }} - name: Generage coverage report uses: danielpalme/ReportGenerator-GitHub-Action@5.3.11 with: - reports: '${{ github.workspace }}/TestResults-${{ env.LC_PIVOT }}/**/*.cobertura.xml' - targetdir: '${{ github.workspace }}/CoverageReport-${{ env.LC_PIVOT }}' + reports: '${{ github.workspace }}/TestResults-${{ steps.configure.outputs.LC_PIVOT }}/**/*.cobertura.xml' + targetdir: '${{ github.workspace }}/CoverageReport-${{ steps.configure.outputs.LC_PIVOT }}' reporttypes: 'Html;Html_Dark;Cobertura;MarkdownSummaryGithub;Badges;JsonSummary' assemblyfilters: '-*.Tests;-LCTestTarget*' classfilters: '${{ steps.configure.outputs.LC_COVERAGE_EXCLUDE_CLASS_FILTER }}' @@ -105,7 +106,7 @@ jobs: if: ${{ inputs.code-coverage && inputs.configuration == inputs.code-coverage-configuration }} - name: Add coverage report to summary - run: cat $GITHUB_WORKSPACE/CoverageReport-${{ env.LC_PIVOT }}/SummaryGithub.md >> $GITHUB_STEP_SUMMARY + run: cat $GITHUB_WORKSPACE/CoverageReport-${{ steps.configure.outputs.LC_PIVOT }}/SummaryGithub.md >> $GITHUB_STEP_SUMMARY shell: bash if: ${{ inputs.code-coverage && inputs.configuration == inputs.code-coverage-configuration }} @@ -113,8 +114,8 @@ jobs: run: | chmod +rx .github/workflows/update_gist.sh .github/workflows/update_gist.sh 9bd61dea93406219c4985641039c4e2f \ - code-coverage-windows-${{ env.LC_PIVOT }}.svg \ - $GITHUB_WORKSPACE/CoverageReport-${{ env.LC_PIVOT }}/badge_combined.svg + code-coverage-windows-${{ steps.configure.outputs.LC_PIVOT }}.svg \ + $GITHUB_WORKSPACE/CoverageReport-${{ steps.configure.outputs.LC_PIVOT }}/badge_combined.svg shell: bash env: GH_TOKEN: ${{ secrets.BADGE_GIST_TOKEN }} @@ -123,6 +124,6 @@ jobs: - name: Upload CoverageReport uses: actions/upload-artifact@v4 with: - name: coverage-report-${{ env.LC_PIVOT }} - path: CoverageReport-${{ env.LC_PIVOT }} + name: coverage-report-${{ steps.configure.outputs.LC_PIVOT }} + path: CoverageReport-${{ steps.configure.outputs.LC_PIVOT }} if: ${{ always() && inputs.code-coverage && inputs.configuration == inputs.code-coverage-configuration }} \ No newline at end of file diff --git a/.github/workflows/dotnet-ubuntu.yml b/.github/workflows/dotnet-ubuntu.yml index 05b90fb..5bf37e0 100644 --- a/.github/workflows/dotnet-ubuntu.yml +++ b/.github/workflows/dotnet-ubuntu.yml @@ -21,4 +21,4 @@ jobs: dotnet-version: ${{ matrix.dotnet-version }} configuration: ${{ matrix.configuration }} tfm: ${{ matrix.tfm }} - code-coverage: true \ No newline at end of file + code-coverage: true diff --git a/.github/workflows/dotnet-windows.yml b/.github/workflows/dotnet-windows.yml index 9ca57b8..8d8b385 100644 --- a/.github/workflows/dotnet-windows.yml +++ b/.github/workflows/dotnet-windows.yml @@ -21,4 +21,4 @@ jobs: dotnet-version: ${{ matrix.dotnet-version }} configuration: ${{ matrix.configuration }} tfm: ${{ matrix.tfm }} - code-coverage: true \ No newline at end of file + code-coverage: true diff --git a/.github/workflows/upload-coverage-report.yml b/.github/workflows/upload-coverage-report.yml new file mode 100644 index 0000000..5f490de --- /dev/null +++ b/.github/workflows/upload-coverage-report.yml @@ -0,0 +1,56 @@ +name: Upload Coverage Report + +on: + workflow_dispatch: + +jobs: + update-coverage-report: + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages + permissions: + contents: read + pages: write + id-token: write + # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. + # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. + concurrency: + group: "pages" + cancel-in-progress: false + strategy: + matrix: + spec: + - .github/workflows/dotnet-windows.yml codecoverage-report-windows-net8.0-Release, codecoverage-report-windows-net481-Release + - .github/workflows/dotnet-ubuntu.yml codecoverage-report-ubuntu-net8.0-Release + steps: + - name: 'Download latest successful build artifact' + run: | + IFS=' ' read -ra spec <<< "${{ matrix.spec }}" + workflow_id=$(echo ${spec[0]} | xargs) + run_id=$(gh run list -w $workflow_id --json conclusion,headBranch,databaseId --jq 'first(.[] | select(.conclusion | contains("success"))) | .databaseId') + [ -z "$run_id" ] && echo "::error:::No successful run found for workflow '$workflow_id'" && exit 1 || true + echo "::notice::Last successful run for workflow '$workflow_id' is '$run_id'" + IFS=',' read -ra artifacts <<< "${spec[@]:1}" + for i in "${artifacts[@]}"; do + artifact_id=$(echo $i | xargs) + artifact_subdir=$(echo $artifact_id | sed 's/codecoverage-report-//g') + echo "::notice::Downloading '$artifact_id'" + gh run download $run_id -n $artifact_id -D $ARTIFACTS_TMP_DIR + unzip $ARTIFACTS_TMP_DIR/${artifact_id}.zip -d $OUTPUT_DIR/$artifact_subdir + done + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + WF_SPEC: ${{ matrix.spec }} + ARTIFACTS_TMP_DIR: artifacts + OUTPUT_DIR: coverage-results + - name: Setup Pages + uses: actions/configure-pages@v5 + - name: Upload Pages + uses: actions/upload-pages-artifact@v3 + with: + path: coverage-results + - name: Deploy Pages + id: deployment + uses: actions/deploy-pages@v4