Skip to content

Commit f490977

Browse files
committed
How about some GitHub Actions
1 parent 2756625 commit f490977

File tree

6 files changed

+559
-39
lines changed

6 files changed

+559
-39
lines changed
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: CI - Build and Test
2+
3+
on:
4+
push:
5+
branches: [ main, net10.0, release/*, staged-pipelines ]
6+
pull_request:
7+
branches: [ main, net10.0, release/* ]
8+
workflow_dispatch:
9+
10+
env:
11+
DOTNET_NOLOGO: true
12+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
13+
DOTNET_CLI_TELEMETRY_OPTOUT: true
14+
15+
jobs:
16+
build-and-test:
17+
name: Build and Unit Tests
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
os: [ubuntu-latest, windows-latest, macos-latest]
23+
include:
24+
- os: ubuntu-latest
25+
name: Linux
26+
- os: windows-latest
27+
name: Windows
28+
- os: macos-latest
29+
name: macOS
30+
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
with:
35+
fetch-depth: 0
36+
37+
- name: Setup .NET
38+
uses: actions/setup-dotnet@v4
39+
with:
40+
global-json-file: global.json
41+
42+
- name: Setup Java (for Android builds)
43+
if: matrix.os != 'macos-latest' # Skip Java on macOS for now to keep it simple
44+
uses: actions/setup-java@v4
45+
with:
46+
distribution: 'microsoft'
47+
java-version: '17'
48+
49+
- name: Install dotnet tools
50+
run: dotnet tool restore
51+
52+
- name: Restore dependencies
53+
run: dotnet restore Microsoft.Maui.sln
54+
55+
- name: Build solution
56+
run: dotnet build Microsoft.Maui.sln --no-restore --configuration Release
57+
58+
- name: Run Core Unit Tests
59+
run: dotnet test src/Core/tests/UnitTests/Core.UnitTests.csproj --no-build --configuration Release --logger trx --collect:"XPlat Code Coverage"
60+
61+
- name: Run Essentials Unit Tests
62+
run: dotnet test src/Essentials/test/UnitTests/Essentials.UnitTests.csproj --no-build --configuration Release --logger trx --collect:"XPlat Code Coverage"
63+
64+
- name: Run Controls Core Unit Tests
65+
run: dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --no-build --configuration Release --logger trx --collect:"XPlat Code Coverage"
66+
67+
- name: Run Controls XAML Unit Tests
68+
run: dotnet test src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj --no-build --configuration Release --logger trx --collect:"XPlat Code Coverage"
69+
70+
- name: Run Compatibility Unit Tests
71+
run: dotnet test src/Compatibility/Core/tests/Compatibility.UnitTests/Compatibility.Core.UnitTests.csproj --no-build --configuration Release --logger trx --collect:"XPlat Code Coverage"
72+
73+
- name: Upload test results
74+
uses: actions/upload-artifact@v4
75+
if: always()
76+
with:
77+
name: test-results-${{ matrix.name }}
78+
path: |
79+
**/*.trx
80+
**/coverage.cobertura.xml
81+
retention-days: 30
82+
83+
format-check:
84+
name: Code Format Check
85+
runs-on: ubuntu-latest
86+
steps:
87+
- name: Checkout
88+
uses: actions/checkout@v4
89+
90+
- name: Setup .NET
91+
uses: actions/setup-dotnet@v4
92+
with:
93+
global-json-file: global.json
94+
95+
- name: Restore dependencies
96+
run: dotnet restore Microsoft.Maui.sln
97+
98+
- name: Check code formatting
99+
run: dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --verify-no-changes --verbosity diagnostic
100+
101+
summary:
102+
name: Build Summary
103+
runs-on: ubuntu-latest
104+
needs: [build-and-test, format-check]
105+
if: always()
106+
steps:
107+
- name: Build Summary
108+
run: |
109+
echo "## Build and Test Summary" >> $GITHUB_STEP_SUMMARY
110+
echo "" >> $GITHUB_STEP_SUMMARY
111+
echo "| Job | Status |" >> $GITHUB_STEP_SUMMARY
112+
echo "|-----|--------|" >> $GITHUB_STEP_SUMMARY
113+
echo "| Linux Build & Test | ${{ needs.build-and-test.result == 'success' && '✅' || '❌' }} |" >> $GITHUB_STEP_SUMMARY
114+
echo "| Windows Build & Test | ${{ needs.build-and-test.result == 'success' && '✅' || '❌' }} |" >> $GITHUB_STEP_SUMMARY
115+
echo "| macOS Build & Test | ${{ needs.build-and-test.result == 'success' && '✅' || '❌' }} |" >> $GITHUB_STEP_SUMMARY
116+
echo "| Code Format Check | ${{ needs.format-check.result == 'success' && '✅' || '❌' }} |" >> $GITHUB_STEP_SUMMARY
117+
echo "" >> $GITHUB_STEP_SUMMARY
118+
119+
if [[ "${{ needs.build-and-test.result }}" == "success" && "${{ needs.format-check.result }}" == "success" ]]; then
120+
echo "🎉 All checks passed! The codebase builds successfully and unit tests are passing." >> $GITHUB_STEP_SUMMARY
121+
else
122+
echo "❌ Some checks failed. Please review the job details above." >> $GITHUB_STEP_SUMMARY
123+
fi
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
name: CI - Extended Build
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
run_device_tests:
7+
description: 'Run device tests after build'
8+
required: false
9+
default: false
10+
type: boolean
11+
run_android_build:
12+
description: 'Include Android platform build'
13+
required: false
14+
default: true
15+
type: boolean
16+
schedule:
17+
# Run nightly at 2 AM UTC
18+
- cron: '0 2 * * *'
19+
20+
env:
21+
DOTNET_NOLOGO: true
22+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
23+
DOTNET_CLI_TELEMETRY_OPTOUT: true
24+
25+
jobs:
26+
build-core:
27+
name: Core Build and Unit Tests
28+
runs-on: ubuntu-latest
29+
outputs:
30+
success: ${{ steps.build.outcome == 'success' }}
31+
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 0
37+
38+
- name: Setup .NET
39+
uses: actions/setup-dotnet@v4
40+
with:
41+
global-json-file: global.json
42+
43+
- name: Install dotnet tools
44+
run: dotnet tool restore
45+
46+
- name: Build build tasks
47+
run: dotnet build ./Microsoft.Maui.BuildTasks.slnf
48+
49+
- name: Build and test core
50+
id: build
51+
run: |
52+
echo "Building core solution..."
53+
dotnet build Microsoft.Maui.sln --configuration Release
54+
55+
echo "Running unit tests..."
56+
dotnet test src/Core/tests/UnitTests/Core.UnitTests.csproj --configuration Release --logger trx
57+
dotnet test src/Essentials/test/UnitTests/Essentials.UnitTests.csproj --configuration Release --logger trx
58+
dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --configuration Release --logger trx
59+
dotnet test src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj --configuration Release --logger trx
60+
61+
- name: Upload artifacts
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: build-artifacts
65+
path: |
66+
artifacts/
67+
**/*.trx
68+
retention-days: 30
69+
70+
build-android:
71+
name: Android Build
72+
runs-on: ubuntu-latest
73+
needs: build-core
74+
if: needs.build-core.outputs.success == 'true' && (github.event.inputs.run_android_build == 'true' || github.event_name == 'schedule')
75+
76+
steps:
77+
- name: Checkout
78+
uses: actions/checkout@v4
79+
80+
- name: Setup .NET
81+
uses: actions/setup-dotnet@v4
82+
with:
83+
global-json-file: global.json
84+
85+
- name: Setup Java
86+
uses: actions/setup-java@v4
87+
with:
88+
distribution: 'microsoft'
89+
java-version: '17'
90+
91+
- name: Install dotnet tools
92+
run: dotnet tool restore
93+
94+
- name: Build build tasks
95+
run: dotnet build ./Microsoft.Maui.BuildTasks.slnf
96+
97+
- name: Download build artifacts
98+
uses: actions/download-artifact@v4
99+
with:
100+
name: build-artifacts
101+
102+
- name: Build Android sample
103+
run: |
104+
echo "Building Android sample to verify platform integration..."
105+
dotnet build src/Controls/samples/Maui.Controls.Sample/Maui.Controls.Sample.csproj -f net9.0-android --configuration Release
106+
107+
build-ios:
108+
name: iOS Build (macOS)
109+
runs-on: macos-latest
110+
needs: build-core
111+
if: needs.build-core.outputs.success == 'true' && github.event_name == 'schedule'
112+
113+
steps:
114+
- name: Checkout
115+
uses: actions/checkout@v4
116+
117+
- name: Setup .NET
118+
uses: actions/setup-dotnet@v4
119+
with:
120+
global-json-file: global.json
121+
122+
- name: Install dotnet tools
123+
run: dotnet tool restore
124+
125+
- name: Build build tasks
126+
run: dotnet build ./Microsoft.Maui.BuildTasks.slnf
127+
128+
- name: Build iOS sample
129+
run: |
130+
echo "Building iOS sample to verify platform integration..."
131+
dotnet build src/Controls/samples/Maui.Controls.Sample/Maui.Controls.Sample.csproj -f net9.0-ios --configuration Release
132+
133+
device-tests:
134+
name: Device Tests (if requested)
135+
runs-on: ubuntu-latest
136+
needs: [build-core, build-android]
137+
if: needs.build-core.outputs.success == 'true' && github.event.inputs.run_device_tests == 'true'
138+
139+
steps:
140+
- name: Checkout
141+
uses: actions/checkout@v4
142+
143+
- name: Setup .NET
144+
uses: actions/setup-dotnet@v4
145+
with:
146+
global-json-file: global.json
147+
148+
- name: Setup Java
149+
uses: actions/setup-java@v4
150+
with:
151+
distribution: 'microsoft'
152+
java-version: '17'
153+
154+
- name: Install dotnet tools
155+
run: dotnet tool restore
156+
157+
- name: Build device tests
158+
run: |
159+
echo "Building device tests (Android only in public runners)..."
160+
dotnet build src/Essentials/test/DeviceTests/Essentials.DeviceTests.csproj -f net9.0-android --configuration Release
161+
dotnet build src/Core/tests/DeviceTests/Core.DeviceTests.csproj -f net9.0-android --configuration Release
162+
163+
- name: Note about device tests
164+
run: |
165+
echo "Device tests built successfully!"
166+
echo "Note: Actual device testing requires physical devices or emulators with additional setup."
167+
echo "This workflow validates that device test projects compile correctly."
168+
169+
summary:
170+
name: Summary
171+
runs-on: ubuntu-latest
172+
needs: [build-core, build-android, build-ios, device-tests]
173+
if: always()
174+
175+
steps:
176+
- name: Build Summary
177+
run: |
178+
echo "## Extended Build Summary" >> $GITHUB_STEP_SUMMARY
179+
echo "" >> $GITHUB_STEP_SUMMARY
180+
echo "| Stage | Status | Notes |" >> $GITHUB_STEP_SUMMARY
181+
echo "|-------|--------|-------|" >> $GITHUB_STEP_SUMMARY
182+
echo "| Core Build & Unit Tests | ${{ needs.build-core.result == 'success' && '✅ Passed' || '❌ Failed' }} | Basic .NET MAUI build and unit tests |" >> $GITHUB_STEP_SUMMARY
183+
echo "| Android Build | ${{ needs.build-android.result == 'success' && '✅ Passed' || needs.build-android.result == 'skipped' && '⏭️ Skipped' || '❌ Failed' }} | Android platform validation |" >> $GITHUB_STEP_SUMMARY
184+
echo "| iOS Build | ${{ needs.build-ios.result == 'success' && '✅ Passed' || needs.build-ios.result == 'skipped' && '⏭️ Skipped' || '❌ Failed' }} | iOS platform validation (macOS only) |" >> $GITHUB_STEP_SUMMARY
185+
echo "| Device Tests | ${{ needs.device-tests.result == 'success' && '✅ Passed' || needs.device-tests.result == 'skipped' && '⏭️ Skipped' || '❌ Failed' }} | Device test compilation check |" >> $GITHUB_STEP_SUMMARY
186+
echo "" >> $GITHUB_STEP_SUMMARY
187+
188+
if [[ "${{ needs.build-core.result }}" == "success" ]]; then
189+
echo "🎉 **Core build successful!** The .NET MAUI codebase compiles and unit tests pass." >> $GITHUB_STEP_SUMMARY
190+
echo "" >> $GITHUB_STEP_SUMMARY
191+
echo "### Next Steps" >> $GITHUB_STEP_SUMMARY
192+
echo "- ✅ Core functionality validated" >> $GITHUB_STEP_SUMMARY
193+
if [[ "${{ needs.build-android.result }}" == "success" ]]; then
194+
echo "- ✅ Android platform integration confirmed" >> $GITHUB_STEP_SUMMARY
195+
fi
196+
if [[ "${{ needs.build-ios.result }}" == "success" ]]; then
197+
echo "- ✅ iOS platform integration confirmed" >> $GITHUB_STEP_SUMMARY
198+
fi
199+
echo "- 🔄 Ready for more comprehensive testing in Azure DevOps pipelines" >> $GITHUB_STEP_SUMMARY
200+
else
201+
echo "❌ **Core build failed.** Please fix compilation issues before proceeding." >> $GITHUB_STEP_SUMMARY
202+
fi

0 commit comments

Comments
 (0)