Skip to content

Commit 1c7ebba

Browse files
committed
Initial commit
0 parents  commit 1c7ebba

104 files changed

Lines changed: 27516 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/settings.local.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(cmake:*)",
5+
"Bash(ctest:*)",
6+
"Bash(./WinDevicesTests.exe:*)",
7+
"Bash(./build/bin/Release/WinDevicesTests.exe:*)",
8+
"Bash(cmd //c \"install.cmd --help\")",
9+
"Bash(cmd //c \".\\\\install.cmd --help\")",
10+
"Bash(cmd //c \".\\\\install.cmd --build-only\")",
11+
"Bash(cmd //c \"build-and-test.cmd --help\")",
12+
"Bash(cmd //c \".\\\\build-and-test.cmd --help\")",
13+
"Bash(cmd //c \"build-and-test.cmd debug\")",
14+
"Bash(cmd //c \".\\\\build-and-test.cmd debug\")",
15+
"Bash(cmd //c \".\\\\build-and-test.cmd debug --no-test --install\")",
16+
"Bash(dir:*)",
17+
"Bash(gh run view:*)",
18+
"Bash(git checkout:*)"
19+
]
20+
}
21+
}
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
name: 'Build and Test'
2+
description: 'Builds WinDevices library (Debug + Release) and runs tests'
3+
4+
inputs:
5+
build-type:
6+
description: 'Build configuration (Debug or Release) - both are always built'
7+
required: false
8+
default: 'Debug'
9+
enable-testing:
10+
description: 'Enable running unit tests'
11+
required: false
12+
default: 'true'
13+
enable-e2e-tests:
14+
description: 'Enable building E2E tests (requires hardware)'
15+
required: false
16+
default: 'false'
17+
upload-artifacts:
18+
description: 'Whether to upload build artifacts'
19+
required: false
20+
default: 'false'
21+
artifact-name:
22+
description: 'Name for uploaded artifacts'
23+
required: false
24+
default: 'build-artifacts'
25+
upload-test-results:
26+
description: 'Whether to upload test results'
27+
required: false
28+
default: 'false'
29+
test-results-name:
30+
description: 'Name for uploaded test results'
31+
required: false
32+
default: 'test-results'
33+
publish-test-results:
34+
description: 'Whether to publish test results to PR'
35+
required: false
36+
default: 'false'
37+
38+
outputs:
39+
build-path:
40+
description: 'Path to the build directory'
41+
value: ${{ steps.build-info.outputs.build-path }}
42+
binary-path:
43+
description: 'Path to the binary directory'
44+
value: ${{ steps.build-info.outputs.binary-path }}
45+
test-executable:
46+
description: 'Path to the test executable'
47+
value: ${{ steps.build-info.outputs.test-executable }}
48+
tests-passed:
49+
description: 'Whether all tests passed'
50+
value: ${{ steps.run-tests.outputs.tests-passed }}
51+
52+
runs:
53+
using: 'composite'
54+
steps:
55+
- name: Setup CMake
56+
uses: jwlawson/actions-setup-cmake@v1.14
57+
with:
58+
cmake-version: '3.29'
59+
60+
- name: Configure CMake
61+
shell: cmd
62+
run: |
63+
echo Configuring CMake with tests enabled...
64+
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DBUILD_E2E_TESTS=OFF -DENABLE_COVERAGE=OFF
65+
if errorlevel 1 (
66+
echo CMake configuration failed
67+
exit /b 1
68+
)
69+
echo CMake configuration completed
70+
71+
- name: Build Debug
72+
shell: cmd
73+
run: |
74+
echo Building Debug configuration...
75+
cmake --build build --config Debug --parallel
76+
if errorlevel 1 (
77+
echo Debug build failed
78+
exit /b 1
79+
)
80+
echo Debug build completed successfully
81+
82+
- name: Build Release
83+
shell: cmd
84+
run: |
85+
echo Building Release configuration...
86+
cmake --build build --config Release --parallel
87+
if errorlevel 1 (
88+
echo Release build failed
89+
exit /b 1
90+
)
91+
echo Release build completed successfully
92+
93+
- name: Run Tests
94+
id: run-tests
95+
if: ${{ inputs.enable-testing == 'true' }}
96+
shell: cmd
97+
run: |
98+
echo Running tests...
99+
echo.
100+
echo Looking for test executable...
101+
102+
if exist "build\bin\Debug\WinDevicesTests.exe" (
103+
echo Found: build\bin\Debug\WinDevicesTests.exe
104+
build\bin\Debug\WinDevicesTests.exe --gtest_output=xml:test-results.xml
105+
) else if exist "build\bin\WinDevicesTests.exe" (
106+
echo Found: build\bin\WinDevicesTests.exe
107+
build\bin\WinDevicesTests.exe --gtest_output=xml:test-results.xml
108+
) else (
109+
echo ERROR: WinDevicesTests.exe not found
110+
echo.
111+
echo Contents of build\bin:
112+
dir /s build\bin
113+
exit /b 1
114+
)
115+
116+
if errorlevel 1 (
117+
echo Tests failed
118+
echo tests-passed=false>> %GITHUB_OUTPUT%
119+
exit /b 1
120+
)
121+
122+
echo All tests passed
123+
echo tests-passed=true>> %GITHUB_OUTPUT%
124+
125+
- name: Set build information outputs
126+
id: build-info
127+
shell: powershell
128+
run: |
129+
$buildPath = "build"
130+
$binaryPath = "build\bin"
131+
132+
Write-Host "Build directory: $buildPath"
133+
134+
if (Test-Path "build\bin\Debug") {
135+
Write-Host "Debug build contents:"
136+
Get-ChildItem "build\bin\Debug" | ForEach-Object { Write-Host " $($_.Name)" }
137+
$testExe = "build\bin\Debug\WinDevicesTests.exe"
138+
} elseif (Test-Path "build\bin") {
139+
Write-Host "Build bin contents:"
140+
Get-ChildItem "build\bin" | ForEach-Object { Write-Host " $($_.Name)" }
141+
$testExe = "build\bin\WinDevicesTests.exe"
142+
} else {
143+
$testExe = ""
144+
}
145+
146+
if (Test-Path "build\bin\Release") {
147+
Write-Host "Release build contents:"
148+
Get-ChildItem "build\bin\Release" | ForEach-Object { Write-Host " $($_.Name)" }
149+
}
150+
151+
"build-path=$buildPath" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
152+
"binary-path=$binaryPath" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
153+
"test-executable=$testExe" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
154+
155+
- name: Upload Build Artifacts
156+
if: ${{ inputs.upload-artifacts == 'true' }}
157+
uses: actions/upload-artifact@v4
158+
with:
159+
name: ${{ inputs.artifact-name }}
160+
path: |
161+
build/bin/
162+
build/lib/
163+
include/
164+
build/include/
165+
retention-days: 30
166+
if-no-files-found: warn
167+
168+
- name: Upload Test Results Artifacts
169+
if: ${{ inputs.upload-test-results == 'true' && inputs.enable-testing == 'true' && always() }}
170+
uses: actions/upload-artifact@v4
171+
with:
172+
name: ${{ inputs.test-results-name }}
173+
path: |
174+
test-results.xml
175+
build/Testing/
176+
retention-days: 30
177+
if-no-files-found: warn

.github/workflows/build-test.yaml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Build and Test
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
paths-ignore:
8+
- 'docs/**'
9+
- '**.md'
10+
push:
11+
branches:
12+
- main
13+
paths-ignore:
14+
- 'docs/**'
15+
- '**.md'
16+
workflow_dispatch:
17+
18+
jobs:
19+
build:
20+
runs-on: windows-latest
21+
strategy:
22+
matrix:
23+
config: [Debug, Release]
24+
fail-fast: false
25+
26+
permissions:
27+
contents: read
28+
actions: read
29+
checks: write
30+
pull-requests: write
31+
32+
steps:
33+
- name: Checkout source code
34+
uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 0
37+
38+
- name: Setup CMake
39+
uses: jwlawson/actions-setup-cmake@v1.14
40+
with:
41+
cmake-version: '3.29'
42+
43+
- name: Configure CMake
44+
shell: cmd
45+
run: |
46+
echo Configuring CMake for ${{ matrix.config }}...
47+
cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DBUILD_TESTS=ON -DBUILD_E2E_TESTS=OFF -DENABLE_COVERAGE=OFF
48+
if errorlevel 1 exit /b 1
49+
50+
- name: Build
51+
shell: cmd
52+
run: |
53+
echo Building ${{ matrix.config }} configuration...
54+
cmake --build build --config ${{ matrix.config }} --parallel
55+
if errorlevel 1 exit /b 1
56+
57+
- name: Run Tests
58+
shell: cmd
59+
run: |
60+
echo Running tests for ${{ matrix.config }}...
61+
if exist "build\bin\${{ matrix.config }}\WinDevicesTests.exe" (
62+
build\bin\${{ matrix.config }}\WinDevicesTests.exe --gtest_output=xml:test-results-${{ matrix.config }}.xml
63+
) else if exist "build\bin\WinDevicesTests.exe" (
64+
build\bin\WinDevicesTests.exe --gtest_output=xml:test-results-${{ matrix.config }}.xml
65+
) else (
66+
echo ERROR: WinDevicesTests.exe not found
67+
dir /s build\bin
68+
exit /b 1
69+
)
70+
71+
- name: Upload Test Results
72+
if: always()
73+
uses: actions/upload-artifact@v4
74+
with:
75+
name: test-results-${{ matrix.config }}
76+
path: test-results-${{ matrix.config }}.xml
77+
retention-days: 30
78+
if-no-files-found: warn
79+
80+
- name: Upload Build Artifacts
81+
uses: actions/upload-artifact@v4
82+
with:
83+
name: build-${{ matrix.config }}
84+
path: |
85+
build/bin/${{ matrix.config }}/
86+
build/lib/${{ matrix.config }}/
87+
retention-days: 30
88+
if-no-files-found: warn
89+
90+
summary:
91+
needs: build
92+
runs-on: windows-latest
93+
if: always()
94+
steps:
95+
- name: Build Summary
96+
shell: powershell
97+
run: |
98+
Write-Host "=== Build Summary ==="
99+
Write-Host "Debug build: ${{ needs.build.result }}"
100+
Write-Host "Release build: ${{ needs.build.result }}"
101+
102+
if ("${{ needs.build.result }}" -eq "success") {
103+
Write-Host ""
104+
Write-Host "All builds completed successfully!"
105+
} else {
106+
Write-Host ""
107+
Write-Host "Some builds failed. Check the logs above."
108+
exit 1
109+
}

0 commit comments

Comments
 (0)