From 9de43c85c2278dd6851a5d0ab4234ba06203d439 Mon Sep 17 00:00:00 2001 From: Maytham Fahmi <9260645+maythamfahmi@users.noreply.github.com> Date: Sun, 3 Nov 2024 14:58:46 +0100 Subject: [PATCH] #100 update pipelines --- .github/workflows/1-ci.yml | 29 +++---- .github/workflows/3-code-coverage.yml | 113 +++++++++++++------------- 2 files changed, 67 insertions(+), 75 deletions(-) diff --git a/.github/workflows/1-ci.yml b/.github/workflows/1-ci.yml index c4c7c38..41cdbbf 100644 --- a/.github/workflows/1-ci.yml +++ b/.github/workflows/1-ci.yml @@ -26,25 +26,20 @@ jobs: runs-on: ${{ matrix.os }} timeout-minutes: 15 - env: - NAME: "Continuous Integration" steps: - - name: bash-version - run: echo "::add-mask::$NAME" + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 - # - name: Checkout - # uses: actions/checkout@v4 - # with: - # fetch-depth: 0 + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x - # - name: Setup .NET - # uses: actions/setup-dotnet@v4 - # with: - # dotnet-version: 8.0.x + - name: Build + run: dotnet build --configuration Release - # - name: Build - # run: dotnet build --configuration Release - - # - name: Test - # run: dotnet test --configuration Release --no-build + - name: Test + run: dotnet test --configuration Release --no-build diff --git a/.github/workflows/3-code-coverage.yml b/.github/workflows/3-code-coverage.yml index 39aa005..57758d3 100644 --- a/.github/workflows/3-code-coverage.yml +++ b/.github/workflows/3-code-coverage.yml @@ -21,62 +21,59 @@ jobs: build: runs-on: ubuntu-latest - env: - NAME: "Code Coverage" - steps: - - name: bash-version - run: echo "::add-mask::$NAME" - - # - name: Checkout repository - # uses: actions/checkout@v4 - - # - name: Setup .NET - # uses: actions/setup-dotnet@v4 - # with: - # dotnet-version: 8.0.x - - # - name: Install ReportGenerator tool - # run: dotnet tool install --global dotnet-reportgenerator-globaltool - - # - name: Restore dependencies - # run: dotnet restore - - # - name: Build the solution - # run: dotnet build --no-restore - - # - name: Run tests and collect code coverage - # run: dotnet test --no-build --collect:"XPlat Code Coverage" - - # - name: Generate code coverage report - # run: reportgenerator -reports:"**/coverage.cobertura.xml" -targetdir:"coverage" -reporttypes:"HtmlInline_AzurePipelines;Badges" - - # - name: Upload coverage report - # uses: actions/upload-artifact@v4 - # with: - # name: code-coverage-report - # path: coverage - - # - name: Upload coverage badge - # uses: actions/upload-artifact@v4 - # with: - # name: code-coverage-badge - # path: coverage/badge_linecoverage.svg - - # - name: Create coverage badge - # run: cp coverage/badge_linecoverage.svg ./coverage-badge.svg - - # - name: Print Directory Structure - # uses: FiorelaCiroku/XDTesting-Print-Directory-Structure@v1.0.2 - - # - name: Commit coverage badge - # run: | - # git config --global user.name 'github-actions[bot]' - # git config --global user.email 'github-actions[bot]@users.noreply.github.com' - # git add coverage-badge.svg - # if git diff-index --cached --name-only HEAD | grep -vsxF coverage-badge.svg; then - # git commit -m 'Update coverage badge' - # git push - # fi - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} + fetch-depth: 0 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + + - name: Install ReportGenerator tool + run: dotnet tool install --global dotnet-reportgenerator-globaltool + + - name: Restore dependencies + run: dotnet restore + + - name: Build the solution + run: dotnet build --no-restore + + - name: Run tests and collect code coverage + run: dotnet test --no-build --collect:"XPlat Code Coverage" + + - name: Generate code coverage report + run: reportgenerator -reports:"**/coverage.cobertura.xml" -targetdir:"coverage" -reporttypes:"HtmlInline_AzurePipelines;Badges" + + - name: Upload coverage report + uses: actions/upload-artifact@v4 + with: + name: code-coverage-report + path: coverage + + - name: Upload coverage badge + uses: actions/upload-artifact@v4 + with: + name: code-coverage-badge + path: coverage/badge_linecoverage.svg + + - name: Create coverage badge + run: cp coverage/badge_linecoverage.svg ./coverage-badge.svg + + - name: Print Directory Structure + uses: FiorelaCiroku/XDTesting-Print-Directory-Structure@v1.0.2 + + - name: Commit coverage badge + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git add coverage-badge.svg + if git diff-index --cached --name-only HEAD | grep -vsxF coverage-badge.svg; then + git commit -m 'Update coverage badge' + git push + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}