Skip to content

Add Caching to CI, Build for tests #33

Add Caching to CI, Build for tests

Add Caching to CI, Build for tests #33

Workflow file for this run

# .github/workflows/dotnet.yml
name: .NET Build and Test
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
# 1. Checkout the repository with a shallow clone
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1 # Shallow clone for faster checkouts
# 2. Setup .NET SDK with exact version
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x # Specify the exact SDK version
# 3. Cache NuGet packages
- name: Cache NuGet packages
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.sln') }}
restore-keys: |
${{ runner.os }}-nuget-
# 4. Restore dependencies
- name: Restore dependencies
run: dotnet restore
# 5. Build the solution in Release configuration
- name: Build
run: dotnet build --no-restore --configuration Release
# 6. Run tests with parallel execution
- name: Test
run: dotnet test --verbosity normal