Skip to content

Workflow file for this run

name: Build Test Coverage
on:
workflow_dispatch:
push:
paths:
- 'ChocolateStoreCore/**'
- 'ChocolateStoreCoreTests/**'
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout code
if: ${{ github.actor != 'dependabot[bot]' }}
uses: actions/checkout@v3
with:
token: ${{ secrets.GIT_PAT }}
- name: Checkout code for dependabot
if: ${{ github.actor == 'dependabot[bot]' }}
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
- name: Update Version
run: |
pwsh -File ${{ github.workspace }}\version.ps1 -dir ${{ github.workspace }}\ChocolateStoreCore
- name: Restore dependencies ChocolateStoreCore
run: |
cd ${{ github.workspace }}\ChocolateStoreCore
dotnet restore ${{ github.workspace }}\ChocolateStoreCore\ChocolateStoreCore.csproj -r win-x86
- name: Build ChocolateStoreCore
run: |
dotnet build ${{ github.workspace }}\ChocolateStoreCore\ChocolateStoreCore.csproj --configuration Release --no-restore
- name: Restore dependencies Tests
run: |
cd ${{ github.workspace }}\ChocolateStoreCoreTests\
dotnet restore -r win-x86
- name: Build Tests
run: |
dotnet build "${{ github.workspace }}\ChocolateStoreCoreTests\ChocolateStoreCoreTests.csproj" --configuration Release --no-restore
- name: Test
run: |
dotnet test "${{ github.workspace }}\ChocolateStoreCoreTests\ChocolateStoreCoreTests.csproj" --configuration Release --no-restore --collect:"XPlat Code Coverage"
- name: ReportGenerator New
if: ${{ github.actor != 'dependabot[bot]' }}
run: |
dotnet tool install -g dotnet-reportgenerator-globaltool
$reports = "${{ github.workspace }}\ChocolateStoreCoreTests\**\coverage.cobertura.xml"
$targetdir = "${{ github.workspace }}\.coverage"
$reporttypes = 'MarkdownSummaryGithub;Badges;HtmlSummary'
$historydir = "${{ github.workspace }}\.coverage\History"
$title = 'ChocolateStoreCore Coverage Report'
$license = "${{ secrets.REPORTGENERATOR_LICENSE }}"
reportgenerator -reports:"$reports" -targetdir:"$targetdir" -reporttypes:"$reporttypes" -historydir:"$historydir" -license:"$license"
- name: Publish
if: ${{ github.actor != 'dependabot[bot]' }}
run: |
pwsh -File ${{ github.workspace }}\publish.ps1 -dir ${{ github.workspace }}\ChocolateStoreCore
- name: Create chocolatey package
if: ${{ github.actor != 'dependabot[bot]' }}
run: |
pwsh -File ${{ github.workspace }}\package.ps1 -dir ${{ github.workspace }}\ChocolateStoreCore
- name: Add artefacts
if: ${{ github.actor != 'dependabot[bot]' }}
uses: actions/upload-artifact@v3
with:
name: Assets
path: "${{ github.workspace }}/release/*"
- name: Test coverage report generation preparation
if: ${{ github.actor != 'dependabot[bot]' }}
run: |
if (!(Test-Path -path ${{ github.workspace }}\.coverage\History)) {
New-Item -ItemType directory -Force -Path ${{ github.workspace }}\.coverage\History
}
#- name: ReportGenerator
# if: ${{ github.actor != 'dependabot[bot]' }}
# uses: danielpalme/[email protected]
# with:
# reports: ${{ github.workspace }}\ChocolateStoreCoreTests\**\coverage.cobertura.xml
# targetdir: ${{ github.workspace }}\.coverage
# reporttypes: MarkdownSummaryGithub;Badges;HtmlSummary
# historydir: ${{ github.workspace }}\.coverage\History
# title: 'ChocolateStoreCore Coverage Report'
# license: ${{ secrets.REPORTGENERATOR_LICENSE }}
- name: Commit and push changes
if: ${{ github.actor != 'dependabot[bot]' }}
run: |
cd ${{ github.workspace }}
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git remote add origin_https https://${{ secrets.GIT_PAT }}@github.com/robertZaufall/ChocolateStoreCore.git
git remote update
$Local = $(git rev-parse '@') ; echo "Local: $Local"
$Remote = $(git rev-parse '@{u}') ; echo "Remote: $Remote"
if ($Local -ne $Remote) {
echo "Check-in cancelled due to changes in the meantime."
exit 0
}
git add ChocolateStoreCore/ChocolateStoreCore.csproj
git add version.txt
git add ChocolateyPackages\chocolatestore\chocolatestore.nuspec
git add .coverage/SummaryGithub.md
git add .coverage/summary.html
git add .coverage/badge_branchcoverage.svg
git add .coverage/badge_combined.svg
git add .coverage/badge_linecoverage.svg
git add .coverage/badge_methodcoverage.svg
git add .coverage/badge_shieldsio_branchcoverage_blue.svg
git add .coverage/badge_shieldsio_linecoverage_blue.svg
git add .coverage/badge_shieldsio_methodcoverage_blue.svg
git add .coverage/History
git commit -m "automated ci/cd task [skip actions]"
git push origin_https
env:
GIT_PAT: ${{ secrets.GIT_PAT }}