Skip to content

.NET CI Build

.NET CI Build #239

name: ci-unit-test
run-name: .NET CI Build
on:
workflow_dispatch:
push:
branches: [ "main" ]
paths-ignore:
- '.github/**'
pull_request:
branches: [ "main" ]
paths-ignore:
- '.github/**'
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set status pending
run: |
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
${{ github.api_url }}/repos/${{ github.repository }}/statuses/${{ github.sha }} \
-d '{"state":"pending","target_url":"${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}","description":"CI Build is pending!","context":"continuous-integration/build"}'
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: |
dotnet nuget add source --username ${{ github.triggering_actor }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/bjornbouetsmith/index.json"
dotnet restore Source/ROOT.Zfs.sln
- name: Build
run: dotnet build Source/ROOT.Zfs.sln --no-restore
- name: Test
run: dotnet test Source/**/*.Tests.csproj --configuration Debug --verbosity normal --filter "TestCategory!=Integration" /p:AltCover=true /p:AltCoverReport="/home/runner/work/ROOT.Zfs/ROOT.Zfs/Source/ROOT.Zfs.Tests/coverage.opencover.xml" /p:AltCoverAttributeFilter=ExcludeFromCodeCoverage /p:AltCoverVisibleBranches=true
- name: Set failed status
if: failure()
run: |
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
${{ github.api_url }}/repos/${{ github.repository }}/statuses/${{ github.sha }} \
-d '{"state":"failure","target_url":"${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}","description":"CI Build failed!","context":"continuous-integration/build"}'
- name: Set success status
run: |
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
${{ github.api_url }}/repos/${{ github.repository }}/statuses/${{ github.sha }} \
-d '{"state":"success","target_url":"${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}","description":"CI Build succeeded!","context":"continuous-integration/build"}'