Skip to content

Bump the tests group in /src/Factory.Tests with 3 updates #147

Bump the tests group in /src/Factory.Tests with 3 updates

Bump the tests group in /src/Factory.Tests with 3 updates #147

Workflow file for this run

name: CI/CD
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
name: Build job
runs-on: ubuntu-latest
outputs:
Version: ${{ steps.gitversion.outputs.SemVer }}
CommitsSinceVersionSource: ${{ steps.gitversion.outputs.CommitsSinceVersionSource }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup GitVersion
uses: gittools/actions/gitversion/setup@v1.1.1
with:
versionSpec: 5.x
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v1.1.1
- name: Display GitVersion outputs
run: |
echo "Version: ${{ steps.gitversion.outputs.SemVer }}"
echo "CommitsSinceVersionSource: ${{ steps.gitversion.outputs.CommitsSinceVersionSource }}"
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.0.x
- name: .NET publish
run: dotnet publish src/Factory/Factory.csproj -c Release -p:Version='${{ steps.gitversion.outputs.SemVer }}'
- name: Upload package back to GitHub
uses: actions/upload-artifact@v4
with:
name: drop
path: src/Factory/bin/Release
test:
name: test job
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.0.x
- name: .NET test
run: dotnet test src/Factory.Tests/Factory.Tests.csproj -c Debug -e:CollectCoverage=true -e:CoverletOutput=TestResults/ -e:CoverletOutputFormat=lcov
- run: dir src/Factory.Tests/TestResults
- name: Publish coverage report to coveralls.io
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: src/Factory.Tests/TestResults/coverage.info
sonarCloud:
name: Run SonarCloud analysis
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Run Sonarcloud test
uses: samsmithnz/SamsDotNetSonarCloudAction@v2
with:
projects: 'src/Factory/Factory.csproj,src/Factory.Tests/Factory.Tests.csproj'
dotnet-version: '7.0.x'
sonarcloud-organization: samsmithnz-github
sonarcloud-project: samsmithnz_Factory
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Release:
runs-on: ubuntu-latest
needs:
- build
- test
- sonarCloud
if: github.ref == 'refs/heads/main'
steps:
- name: Display GitVersion outputs
run: |
echo "Version: ${{ needs.build.outputs.Version }}"
echo "CommitsSinceVersionSource: ${{ needs.build.outputs.CommitsSinceVersionSource }}"
- name: Download package artifacts
uses: actions/download-artifact@v4
- name: Create Release
uses: ncipollo/release-action@v1
if: needs.build.outputs.CommitsSinceVersionSource > 0 #Only create a release if there has been a commit/version change
with:
tag: "v${{ needs.build.outputs.Version }}"
name: "v${{ needs.build.outputs.Version }}"
token: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
#- name: Publish nuget package to nuget.org
#if: needs.build.outputs.CommitsSinceVersionSource > 0 #Only publish a NuGet package if there has been a commit/version change
#run: dotnet nuget push nugetPackage\*.nupkg --api-key "${{ secrets.GHPackagesToken }}" --source "https://api.nuget.org/v3/index.json"
#shell: pwsh