Skip to content

Commit 94ecb1c

Browse files
authored
Merge pull request #681 from CommunityToolkit/ci/build-and-package/incremental-components/filter-buildable
Filter incrementally changed component in CI by MultiTarget/WinUI support
2 parents a425dfc + 742173b commit 94ecb1c

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

.github/workflows/build.yml

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ jobs:
7272

7373
env:
7474
MULTI_TARGET_DIRECTORY: tooling/MultiTarget
75-
# faux-ternary expression to select which platforms to build for each platform vs. duplicating step below.
76-
TARGET_PLATFORMS: ${{ matrix.platform != 'WinUI3' && 'all-wasdk' || 'all-uwp' }}
77-
TEST_PLATFORM: ${{ matrix.platform != 'WinUI3' && 'UWP' || 'WinAppSdk' }}
7875
VERSION_PROPERTY: ${{ github.ref == 'refs/heads/main' && format('build.{0}', github.run_number) || format('pull-{0}.{1}', github.event.number, github.run_number) }}
7976

8077
# Steps represent a sequence of tasks that will be executed as part of the job
@@ -132,19 +129,23 @@ jobs:
132129
uses: microsoft/setup-msbuild@v2
133130
with:
134131
vs-version: '[17.9,)'
135-
132+
# Get changed components
136133
- name: Get changed components
137134
run: |
138-
echo "CHANGED_COMPONENTS_LIST=$(./tooling/Get-Changed-Components.ps1)" >> $env:GITHUB_ENV
135+
$changedComponents = $(./tooling/Get-Changed-Components.ps1)
136+
$buildableChangedComponents = $(./tooling/MultiTarget/Filter-Supported-Components.ps1 -Components $changedComponents -MultiTargets ${{ matrix.multitarget }} -WinUIMajorVersion ${{ matrix.winui }})
137+
echo "CHANGED_COMPONENTS_LIST=$(($buildableChangedComponents | ForEach-Object { "'$_'" }) -join ',')" >> $env:GITHUB_ENV
138+
echo "HAS_BUILDABLE_COMPONENTS=$($buildableChangedComponents.Count -gt 0)" >> $env:GITHUB_ENV
139139
140140
# Generate full solution with all projects (sample gallery heads, components, tests)
141141
- name: Generate solution with ${{ matrix.multitarget }} gallery, components and tests
142142
working-directory: ./
143+
if: ${{ env.HAS_BUILDABLE_COMPONENTS == 'true' }}
143144
run: powershell -version 5.1 -command "./tooling/GenerateAllSolution.ps1 -MultiTargets ${{ matrix.multitarget }} ${{ env.ENABLE_DIAGNOSTICS == 'true' && ' -UseDiagnostics' || '' }} -Components ${{ env.CHANGED_COMPONENTS_LIST }} -WinUIMajorVersion ${{ matrix.winui }}" -ErrorAction Stop
144145

145146
# Build solution
146147
- name: MSBuild (With diagnostics)
147-
if: ${{ env.ENABLE_DIAGNOSTICS == 'true' }}
148+
if: ${{ env.ENABLE_DIAGNOSTICS == 'true' && env.HAS_BUILDABLE_COMPONENTS == 'true' }}
148149
run: >
149150
msbuild.exe /restore /nowarn:MSB4011
150151
/p:Configuration=Release
@@ -154,20 +155,21 @@ jobs:
154155
CommunityToolkit.AllComponents.sln
155156
156157
- name: MSBuild
157-
if: ${{ env.ENABLE_DIAGNOSTICS == 'false' }}
158+
if: ${{ env.ENABLE_DIAGNOSTICS == 'false' && env.HAS_BUILDABLE_COMPONENTS == 'true' }}
158159
run: msbuild.exe CommunityToolkit.AllComponents.sln /restore /nowarn:MSB4011 -p:Configuration=Release
159160

160161
# Run tests
161162
- name: Setup VSTest Path
162163
uses: darenm/setup-vstest@3a16d909a1f3bbc65b52f8270d475d905e7d3e44
163164

164165
- name: Install Testspace Module
166+
if: ${{ env.HAS_BUILDABLE_COMPONENTS == 'true' }}
165167
uses: testspace-com/setup-testspace@v1
166168
with:
167169
domain: ${{ github.repository_owner }}
168170

169171
- name: Run component tests against ${{ matrix.multitarget }}
170-
if: ${{ matrix.multitarget == 'uwp' || matrix.multitarget == 'wasdk' }}
172+
if: ${{ (matrix.multitarget == 'uwp' || matrix.multitarget == 'wasdk') && env.HAS_BUILDABLE_COMPONENTS == 'true' }}
171173
id: test-platform
172174
run: vstest.console.exe ./tooling/**/CommunityToolkit.Tests.${{ matrix.multitarget }}.build.appxrecipe /Framework:FrameworkUap10 /logger:"trx;LogFileName=${{ matrix.multitarget }}.trx" /Blame
173175

@@ -199,6 +201,7 @@ jobs:
199201
filters: |
200202
dump:
201203
- added: '${{ github.workspace }}/CrashDumps/*.dmp'
204+
202205
- name: Artifact - WER crash dumps
203206
uses: actions/upload-artifact@v4
204207
if: ${{ steps.filter.outputs.dump == 'true' && (env.ENABLE_DIAGNOSTICS == 'true' || env.COREHOST_TRACE != '') && always() }}
@@ -262,31 +265,34 @@ jobs:
262265
uses: microsoft/setup-msbuild@v2
263266
with:
264267
vs-version: '[17.9,)'
265-
266-
# Get changed components
268+
# Get changed components
267269
- name: Get changed components
268270
run: |
269-
echo "CHANGED_COMPONENTS_LIST=$(./tooling/Get-Changed-Components.ps1)" >> $env:GITHUB_ENV
271+
$changedComponents = $(./tooling/Get-Changed-Components.ps1)
272+
$buildableChangedComponents = $(./tooling/MultiTarget/Filter-Supported-Components.ps1 -Components $changedComponents -MultiTargets "all" -WinUIMajorVersion ${{ matrix.winui }})
273+
echo "CHANGED_COMPONENTS_LIST=$(($buildableChangedComponents | ForEach-Object { "'$_'" }) -join ',')" >> $env:GITHUB_ENV
274+
echo "HAS_BUILDABLE_COMPONENTS=$($buildableChangedComponents.Count -gt 0)" >> $env:GITHUB_ENV
270275
271276
# Build and pack component nupkg
272277
- name: Build and pack component packages
278+
if: ${{ env.HAS_BUILDABLE_COMPONENTS == 'true' }}
273279
run: ./tooling/Build-Toolkit-Components.ps1 -MultiTargets all -Components ${{ env.CHANGED_COMPONENTS_LIST }} -WinUIMajorVersion ${{ matrix.winui }} -DateForVersion ${{ env.VERSION_DATE }} ${{ env.VERSION_PROPERTY != '' && format('-PreviewVersion "{0}"', env.VERSION_PROPERTY) || '' }} ${{ env.ENABLE_DIAGNOSTICS == 'true' && '-EnableBinlogs' || '' }} ${{ env.ENABLE_DIAGNOSTICS == 'true' && '-Verbose' || '' }} -BinlogOutput ./ -NupkgOutput ./ -Release
274280

275281
- name: Validate package names
276-
if: ${{ env.VERSION_PROPERTY != '' }}
282+
if: ${{ env.VERSION_PROPERTY != '' && env.HAS_BUILDABLE_COMPONENTS == 'true' }}
277283
run: powershell -version 5.1 -command "Get-ChildItem -Path '*.nupkg' | ForEach-Object { if (`$_.Name -notmatch '${{ env.VERSION_PROPERTY }}') { throw 'Nupkg name is missing trailing VERSION_PROPERTY' + `$_.Name } }" -ErrorAction Stop
278284

279285
# Push Pull Request Packages to our DevOps Artifacts Feed (see nuget.config)
280286
- name: Push Pull Request Packages (if not fork)
281-
if: ${{ env.IS_PR == 'true' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' }}
287+
if: ${{ env.IS_PR == 'true' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' && env.HAS_BUILDABLE_COMPONENTS == 'true' }}
282288
run: |
283289
dotnet nuget add source https://pkgs.dev.azure.com/dotnet/CommunityToolkit/_packaging/CommunityToolkit-PullRequests/nuget/v3/index.json `
284290
--name PullRequests `
285291
--username dummy --password ${{ secrets.DEVOPS_PACKAGE_PUSH_TOKEN }}
286292
dotnet nuget push "*.nupkg" --api-key dummy --source PullRequests --skip-duplicate
287293
288294
- name: Push packages (main)
289-
if: ${{ github.ref == 'refs/heads/main' }}
295+
if: ${{ github.ref == 'refs/heads/main' && env.HAS_BUILDABLE_COMPONENTS == 'true' }}
290296
run: |
291297
dotnet nuget add source https://pkgs.dev.azure.com/dotnet/CommunityToolkit/_packaging/CommunityToolkit-Labs/nuget/v3/index.json `
292298
--name LabsFeed `
@@ -296,7 +302,7 @@ jobs:
296302
# if we're not doing a PR build (or it's a PR from a fork) then we upload our packages so we can sign as a separate job or have available to test.
297303
- name: Upload Packages as Artifacts
298304
uses: actions/upload-artifact@v4
299-
if: ${{ env.IS_PR == 'false' || github.event.pull_request.head.repo.full_name != github.repository }}
305+
if: ${{ (env.IS_PR == 'false' || github.event.pull_request.head.repo.full_name != github.repository) && env.HAS_BUILDABLE_COMPONENTS == 'true' }}
300306
with:
301307
name: nuget-packages-winui${{ matrix.winui }}
302308
if-no-files-found: error

0 commit comments

Comments
 (0)