Skip to content

Commit ae265e1

Browse files
authored
Merge pull request #12 from Calvindd2f/review
Calvindd2f/issue1
2 parents 9ab419e + 23fe362 commit ae265e1

22 files changed

Lines changed: 1067 additions & 255 deletions

‎.github/workflows/build.yml‎

Lines changed: 36 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,55 @@
1-
name: CI
1+
name: Build & Test
22

3-
on:
4-
workflow_dispatch:
5-
inputs:
6-
configuration:
7-
description: 'Build configuration'
8-
required: true
9-
default: 'Release'
10-
type: choice
11-
options:
12-
- Debug
13-
- Release
14-
- All
15-
targetFramework:
16-
description: 'Target framework'
17-
required: true
18-
default: 'net8.0-windows'
19-
noRestore:
20-
description: 'Skip dotnet restore'
21-
required: false
22-
default: 'false'
23-
type: boolean
24-
verbose:
25-
description: 'Verbose dotnet output'
26-
required: false
27-
default: 'false'
28-
type: boolean
3+
on: [push, pull_request]
294

305
jobs:
316
build:
32-
name: Build (${{ matrix.configuration }})
337
runs-on: windows-latest
34-
# Run this matrix row only if user asked for All or it matches the chosen configuration
35-
if: ${{ github.event.inputs.configuration == 'All' || matrix.configuration == github.event.inputs.configuration }}
36-
strategy:
37-
fail-fast: false
38-
matrix:
39-
configuration: [Debug, Release]
40-
41-
env:
42-
PROJECT_PATH: src/IoTPowerShellAgent/IoTPowerShellAgent.csproj
43-
TARGET_FRAMEWORK: ${{ github.event.inputs.targetFramework }}
44-
VERBOSE_FLAG: ${{ github.event.inputs.verbose == 'true' ? '--verbosity detailed' : '--verbosity minimal' }}
45-
NO_RESTORE_FLAG: ${{ github.event.inputs.noRestore == 'true' ? '--no-restore' : '' }}
46-
478
steps:
48-
- name: Checkout
49-
uses: actions/checkout@v4
50-
51-
- name: Setup .NET SDK
52-
uses: actions/setup-dotnet@v3
9+
- uses: actions/checkout@v4
5310
with:
54-
dotnet-version: '8.0.x'
55-
56-
- name: Show .NET SDK version
57-
run: dotnet --version
11+
fetch-depth: 0 # Fetch all history for semantic versioning
5812

59-
- name: Cache NuGet packages
60-
uses: actions/cache@v4
13+
- uses: actions/setup-dotnet@v4
6114
with:
62-
path: ~/.nuget/packages
63-
# fallback to OS-based key if no lock file is present
64-
key: nuget-${{ runner.os }}-${{ hashFiles('**/packages.lock.json') }}
65-
restore-keys: |
66-
nuget-${{ runner.os }}-
15+
dotnet-version: "8.0.x"
16+
17+
- name: Determine version from Git tag
18+
id: version
19+
run: |
20+
$tag = git describe --tags --abbrev=0 2>$null
21+
if ($tag) {
22+
$version = $tag -replace '^v', ''
23+
Write-Host "Version from tag: $version"
24+
echo "version=$version" >> $env:GITHUB_OUTPUT
25+
} else {
26+
Write-Host "No tag found, using default version"
27+
echo "version=1.0.0" >> $env:GITHUB_OUTPUT
28+
}
29+
shell: pwsh
6730

68-
- name: Restore (conditional)
69-
if: ${{ github.event.inputs.noRestore != 'true' }}
70-
run: dotnet restore ${{ env.PROJECT_PATH }}
31+
- name: Restore dependencies
32+
run: dotnet restore
7133

7234
- name: Build
73-
shell: pwsh
74-
run: |
75-
Write-Host "Building project: $env:PROJECT_PATH"
76-
Write-Host "Configuration: ${{ matrix.configuration }}"
77-
Write-Host "Framework: $env:TARGET_FRAMEWORK"
78-
dotnet build "$env:PROJECT_PATH" `
79-
--configuration "${{ matrix.configuration }}" `
80-
--framework "$env:TARGET_FRAMEWORK" `
81-
--no-incremental `
82-
$env:NO_RESTORE_FLAG `
83-
$env:VERBOSE_FLAG `
84-
/p:BuildInParallel=true `
85-
/p:Deterministic=true `
86-
/p:EnableSourceLink=true `
87-
/p:GenerateAssemblyInfo=true
35+
run: dotnet build --no-restore /p:Version=${{ steps.version.outputs.version }}
8836

89-
- name: Show output file info (if present)
90-
if: always()
37+
- name: Test
38+
run: dotnet test --no-build --logger trx
39+
40+
- name: Run Pester Tests
9141
shell: pwsh
9242
run: |
93-
$out = Join-Path $PWD "src/IoTPowerShellAgent/bin/${{ matrix.configuration }}/$($env:TARGET_FRAMEWORK)"
94-
Write-Host "Looking for output in: $out"
95-
if (Test-Path $out) {
96-
Get-ChildItem -Path $out -File -Recurse | ForEach-Object {
97-
$sizeMB = [math]::Round($_.Length / 1MB, 2)
98-
Write-Host "$($_.FullName) - $sizeMB MB"
99-
}
43+
if (Test-Path "src\IoTPowerShellAgent.Tests.Pester\run-pester.ps1") {
44+
Set-Location src\IoTPowerShellAgent.Tests.Pester
45+
.\run-pester.ps1 -OutputFormat NUnitXml -OutputFile PesterResults.xml
46+
Set-Location ..\..
10047
} else {
101-
Write-Host "Output directory not found."
48+
Write-Host "Pester tests not found, skipping..."
10249
}
10350
104-
- name: Upload build artifacts
105-
uses: actions/upload-artifact@v4
51+
- name: Publish test results
52+
if: always()
53+
uses: EnricoMi/publish-unit-test-result-action@v2
10654
with:
107-
name: IoTPowerShellAgent-${{ matrix.configuration }}
108-
path: src/IoTPowerShellAgent/bin/${{ matrix.configuration }}/$${{ github.event.inputs.targetFramework }}
55+
files: "**/*.trx,**/PesterResults.xml"

‎.github/workflows/dotnet-desktop.yml‎

Lines changed: 0 additions & 115 deletions
This file was deleted.

‎.gitignore‎

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,6 @@ bld/
2424
*.userosscache
2525
*.sln.docstates
2626

27-
# Build results
28-
[Dd]ebug/
29-
[Dd]ebugPublic/
30-
[Rr]elease/
31-
[Rr]eleases/
32-
x64/
33-
x86/
34-
[Aa][Rr][Mm]/
35-
[Aa][Rr][Mm]64/
36-
bld/
37-
[Bb]in/
38-
[Oo]bj/
39-
[Ll]og/
40-
[Ll]ogs/
41-
42-
# Visual Studio cache/options directory
43-
.vs/
44-
4527
# NuGet Packages
4628
*.nupkg
4729
*.snupkg
@@ -53,3 +35,12 @@ config/appsettings.Development.json
5335
config/appsettings.Local.json
5436
AGENTS.md
5537
.claude/agents/repo_expert.md
38+
39+
# Test results
40+
*.trx
41+
*.coverage
42+
*.coveragexml
43+
TestResults/
44+
45+
# Pester test results
46+
PesterResults.xml

0 commit comments

Comments
 (0)