diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 217f7cb..f3ec053 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -1,7 +1,6 @@ -# This workflow will build a .NET project -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net +# .github/workflows/dotnet.yml -name: .NET +name: .NET Build and Test on: push: @@ -10,19 +9,31 @@ on: branches: [ "main" ] jobs: - build: - + build-and-test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Setup .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 8.0.x - - name: Restore dependencies - run: dotnet restore - - name: Build - run: dotnet build --no-restore - - name: Test - run: dotnet test --no-build --verbosity normal + # 1. Checkout the repository with a shallow clone + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + # 2. Setup .NET SDK with exact version and enable NuGet caching + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.x # Specify the exact SDK version + cache: 'nuget' + + # 3. Restore dependencies + - name: Restore dependencies + run: dotnet restore + + # 4. Build the solution in Release configuration + - name: Build + run: dotnet build --no-restore --configuration Release + + # 5. Run tests with parallel execution + - name: Test + run: dotnet test --no-build --verbosity normal --parallel