Workflow try 4 🥺 #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Test | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
branches: | |
- main | |
- feature/source-generator | |
jobs: | |
build: | |
name: 🧪 Test sample module | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
issues: read | |
checks: write | |
pull-requests: write | |
steps: | |
- name: 👨💻 Check-out code | |
uses: actions/checkout@v4 | |
- name: 👨🔧 Setup .NET Core SDK | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.x | |
- name: 🔍 Enable problem matchers | |
run: echo "::add-matcher::.github/matchers/dotnet.json" | |
- name: 🦸♂️ Restore steriods # this is the caching step, remove if you don't think you need it | |
uses: actions/cache@v4 | |
with: | |
path: ~/.nuget/packages | |
# Look to see if there is a cache hit for the corresponding requirements file | |
key: ${{ runner.os }}-nuget-${{ hashFiles('src/**/packages.lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-nuget | |
- name: 🎒 Load packages | |
run: dotnet restore ./src/Svrooij.PowerShell.DI/Svrooij.PowerShell.DI.csproj | |
- name: 🛠️ Build library | |
run: dotnet build ./src/Svrooij.PowerShell.DI/Svrooij.PowerShell.DI.csproj --configuration Release --no-restore | |
- name: 🛠️ Build sample project | |
run: dotnet build ./sample/net8-sample/Svrooij.PowerShell.DependencyInjection.Sample.csproj --configuration Release | |
- name: 🧪 Install pester | |
run: Install-Module -Name Pester -Force -SkipPublisherCheck -Scope CurrentUser | |
shell: pwsh | |
- name: 🧪 Run test | |
shell: pwsh | |
run: | | |
Import-Module ./sample/net8-sample/bin/Release/net8.0/Svrooij.PowerShell.DependencyInjection.Sample.dll -Force | |
Import-Module Pester | |
$pesterConfig = [PesterConfiguration]@{ | |
Output = @{ | |
Verbosity = "Normal" | |
CIFormat = "Auto" | |
StackTraceVerbosity = "FirstLine" | |
} | |
TestResult = @{ | |
Enabled = $true | |
OutputPath = "${{ github.workspace }}/testresults/TestResults.xml" | |
OutputFormat = "JUnitXml" | |
} | |
Run = @{ | |
Path = "./tests/Pester-SampleModule" | |
Exit = $true | |
} | |
Should = @{ | |
ErrorAction = "Continue" | |
} | |
} | |
Invoke-Pester -Configuration $pesterConfig | |
- name: 📃 Publish Test Results | |
uses: EnricoMi/publish-unit-test-result-action@v2 | |
if: always() | |
with: | |
files: ${{ github.workspace }}/testresults/*.xml |