Skip to content

Commit 7321dab

Browse files
authored
Refactor workflows into reusable templates (#244)
This PR is to refactor our CI/PR and publish pipelines to: * Separate our CI and PR pipelines. That way failing PR results don't set our CI as failed * Build reusable, parameterized template pipelines to avoid all the copy/paste * Add a "Setup Check" to PR where it checks for change files so we can start using beachball properly * Set CI to run a larger matrix than PR and on a regular schedule This PR also fixes `example`, which wasn't being build in the pipelines before and was actually broken during the upgrade to 0.71. ###### Microsoft Reviewers: [Open in CodeFlow](https://portal.fabricbot.ms/api/codeflow?pullrequest=https://github.com/microsoft/react-native-xaml/pull/244)
1 parent cbc318a commit 7321dab

File tree

11 files changed

+343
-244
lines changed

11 files changed

+343
-244
lines changed

.github/workflows/main.yml

Lines changed: 58 additions & 187 deletions
Original file line numberDiff line numberDiff line change
@@ -1,200 +1,71 @@
1-
# This is a basic workflow to help you get started with Actions
2-
31
name: CI
42

5-
# Controls when the action will run. Triggers the workflow on push or pull request
6-
# events but only for the master branch
73
on:
4+
schedule:
5+
- cron: '0 15 * * 2' # Tuesday 3PM UTC (8AM PST)
86
push:
97
branches: [ main ]
10-
pull_request:
11-
branches: [ main ]
8+
workflow_dispatch:
129

13-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1410
jobs:
15-
codegen:
16-
runs-on: windows-2022
17-
steps:
18-
- name: setup git
19-
run: |
20-
git config --global core.autocrlf false
21-
git config --global core.filemode false
22-
23-
- uses: actions/checkout@v2
24-
25-
- name: yarn install
26-
run: yarn install
27-
28-
- uses: nuget/setup-nuget@v1
29-
30-
- name: NuGet restore
31-
run: nuget restore example\windows\example.sln
32-
33-
- name: run CodeGen
34-
run: dotnet run -verbose -winmd $env:USERPROFILE\.nuget\packages\microsoft.ui.xaml\2.7.0\lib\uap10.0\Microsoft.UI.Xaml.winmd
35-
working-directory: package\Codegen
36-
37-
- name: build TS
38-
run: yarn build
39-
40-
- name: verify no changes from CodeGen
41-
shell: powershell
42-
run: |
43-
$changed = git status --porcelain=v1
44-
$changed
45-
if ($changed -ne $null) { throw "CodeGen detected changes" }
46-
47-
examplenuget:
48-
runs-on: windows-2022
49-
steps:
50-
- uses: actions/checkout@v2
51-
52-
- name: yarn install
53-
run: yarn install
54-
55-
- name: build TS
56-
run: yarn build
57-
58-
- name: build ExampleNuget
59-
run: yarn windows --no-launch --no-deploy --no-packager --logging
60-
working-directory: examplenuget
61-
62-
- name: Upload appx
63-
uses: actions/upload-artifact@v2
64-
with:
65-
name: ExampleNuget appx
66-
path: examplenuget\windows\AppPackages\examplenuget\examplenuget_1.0.0.0_x64_Debug_Test
67-
if-no-files-found: error
68-
69-
70-
testcli-old:
71-
runs-on: windows-2019
11+
call-runcodegen:
12+
name: Run CodeGen
13+
uses: ./.github/workflows/template-runcodegen.yml
14+
with:
15+
vmImage: windows-2022
16+
17+
call-buildexample:
18+
name: Build Example
7219
strategy:
7320
fail-fast: false
7421
matrix:
75-
rnwSource: ['Source', 'NuGet'] # test building with both RNW source and RNW NuGet
76-
rnwVersion: ['^0.67', '^0.69'] # test key versions (min, partners)
77-
steps:
78-
- uses: actions/checkout@v2
79-
80-
- name: yarn install
81-
run: yarn install
82-
83-
- name: build TS
84-
run: yarn build
85-
86-
- name: yarn link
87-
run: yarn link
88-
working-directory: package
89-
90-
- name: create ${{ matrix.rnwVersion }} app
91-
run: npx react-native init testrnx --template react-native@${{ matrix.rnwVersion }}
92-
93-
- name: add Windows (RNW via ${{ matrix.rnwSource }})
94-
run: npx react-native-windows-init --overwrite ${{ matrix.rnwSource == 'NuGet' && '--experimentalNuGetDependency true' || '' }}
95-
working-directory: testrnx
96-
97-
- name: link react-native-xaml
98-
run: yarn link react-native-xaml
99-
working-directory: testrnx
100-
101-
- name: add react-native-xaml
102-
run: yarn add react-native-xaml
103-
working-directory: testrnx
104-
105-
- name: autolink
106-
run: npx react-native autolink-windows --logging
107-
working-directory: testrnx
108-
109-
- name: update WinUI package version
110-
run: ..\.github\workflows\SetUpAppForNuget.ps1 ${{ matrix.rnwSource == 'NuGet' && '-UseNuGet' || '' }}
111-
working-directory: testrnx
112-
113-
- name: build app
114-
run: npx react-native run-windows --no-launch --no-deploy --no-packager --logging
115-
working-directory: testrnx
116-
117-
testcli:
118-
runs-on: windows-2022
22+
exampleName: ['example', 'examplenuget'] # build both examples
23+
uses: ./.github/workflows/template-buildexample.yml
24+
with:
25+
vmImage: windows-2022
26+
exampleName: ${{ matrix.exampleName }}
27+
28+
call-testcli:
29+
name: Test CLI
11930
strategy:
12031
fail-fast: false
12132
matrix:
122-
rnwSource: ['Source', 'NuGet'] # test building with both RNW source and RNW NuGet
123-
rnwVersion: ['^0.71'] # test key versions (latest)
124-
steps:
125-
- uses: actions/checkout@v2
126-
127-
- name: yarn install
128-
run: yarn install
129-
130-
- name: build TS
131-
run: yarn build
132-
133-
- name: yarn link
134-
run: yarn link
135-
working-directory: package
136-
137-
- name: create ${{ matrix.rnwVersion }} app
138-
run: npx react-native init testrnx --template react-native@${{ matrix.rnwVersion }}
139-
140-
- name: add Windows (RNW via ${{ matrix.rnwSource }})
141-
run: npx react-native-windows-init --overwrite ${{ matrix.rnwSource == 'NuGet' && '--experimentalNuGetDependency true' || '' }}
142-
working-directory: testrnx
143-
144-
- name: link react-native-xaml
145-
run: yarn link react-native-xaml
146-
working-directory: testrnx
147-
148-
- name: add react-native-xaml
149-
run: yarn add react-native-xaml
150-
working-directory: testrnx
151-
152-
- name: autolink
153-
run: npx react-native autolink-windows --logging
154-
working-directory: testrnx
155-
156-
- name: update WinUI package version
157-
run: ..\.github\workflows\SetUpAppForNuget.ps1 ${{ matrix.rnwSource == 'NuGet' && '-UseNuGet' || '' }}
158-
working-directory: testrnx
159-
160-
- name: build app
161-
run: npx react-native run-windows --no-launch --no-deploy --no-packager --logging
162-
working-directory: testrnx
163-
164-
package:
165-
runs-on: windows-2022
166-
steps:
167-
- uses: actions/checkout@v2
168-
169-
- name: setup-msbuild
170-
uses: microsoft/setup-msbuild@v1
171-
172-
- name: yarn install
173-
run: yarn install
174-
175-
- name: build TS
176-
run: yarn build
177-
178-
- name: npm pack
179-
run: npm pack
180-
working-directory: package
181-
182-
- name: Upload npm package
183-
uses: actions/upload-artifact@v2
184-
with:
185-
name: npm package
186-
path: package\*.tgz
187-
if-no-files-found: error
188-
189-
- name: build Release x64
190-
run: msbuild /restore /p:RestorePackagesConfig=true package\windows\ReactNativeXaml.sln /p:configuration=Release /p:platform=x64
191-
192-
- name: Validate size
193-
shell: powershell
194-
run: |
195-
$size = (gci package\windows\x64\Release\ReactNativeXaml\ReactNativeXaml.dll).Length
196-
$size
197-
if ($size -gt 1.5MB) {
198-
throw "DLL is bigger than 1.5MB"
199-
}
200-
33+
rnwVersion: ['^0.71'] # test supported versions
34+
useRnwNuGet: [false, true] # test building with both RNW source and RNW NuGet
35+
uses: ./.github/workflows/template-testcli.yml
36+
with:
37+
vmImage: windows-2022
38+
rnwVersion: ${{ matrix.rnwVersion }}
39+
useRnwNuGet: ${{ matrix.useRnwNuGet }}
40+
41+
call-testcli-old:
42+
name: Test CLI (Old)
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
rnwVersion: ['^0.67', '^0.68', '^0.69', '^0.70'] # test supported versions
47+
useRnwNuGet: [false, true] # test building with both RNW source and RNW NuGet
48+
uses: ./.github/workflows/template-testcli.yml
49+
with:
50+
vmImage: windows-2019
51+
rnwVersion: ${{ matrix.rnwVersion }}
52+
useRnwNuGet: ${{ matrix.useRnwNuGet }}
53+
54+
call-buildnpmpackage:
55+
name: Build NPM Package
56+
uses: ./.github/workflows/template-buildnpmpackage.yml
57+
with:
58+
vmImage: windows-2022
59+
60+
call-buildrnx:
61+
name: Build RNX
62+
strategy:
63+
fail-fast: false
64+
matrix:
65+
configuration: ['Debug', 'Release']
66+
platform: ['x64']
67+
uses: ./.github/workflows/template-buildrnx.yml
68+
with:
69+
vmImage: windows-2022
70+
configuration: ${{ matrix.configuration }}
71+
platform: ${{ matrix.platform }}

.github/workflows/pr.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: PR
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
7+
jobs:
8+
setupcheck:
9+
name: Setup Check
10+
runs-on: windows-2022
11+
steps:
12+
- uses: actions/checkout@v3
13+
14+
- name: yarn install
15+
run: yarn install
16+
17+
- name: beachball check
18+
run: npx beachball check --verbose --changehint "::error::Run `yarn change` from root of repo to generate a change file."
19+
20+
call-runcodegen:
21+
name: Run CodeGen
22+
needs: setupcheck
23+
uses: ./.github/workflows/template-runcodegen.yml
24+
with:
25+
vmImage: windows-2022
26+
27+
call-buildexample:
28+
name: Build Example
29+
needs: setupcheck
30+
strategy:
31+
fail-fast: true
32+
matrix:
33+
exampleName: ['example', 'examplenuget'] # build both examples
34+
uses: ./.github/workflows/template-buildexample.yml
35+
with:
36+
vmImage: windows-2022
37+
exampleName: ${{ matrix.exampleName }}
38+
39+
call-testcli:
40+
name: Test CLI
41+
needs: setupcheck
42+
strategy:
43+
fail-fast: true
44+
matrix:
45+
rnwVersion: ['^0.71'] # test key versions
46+
useRnwNuGet: [false, true] # test building with both RNW source and RNW NuGet
47+
uses: ./.github/workflows/template-testcli.yml
48+
with:
49+
vmImage: windows-2022
50+
rnwVersion: ${{ matrix.rnwVersion }}
51+
useRnwNuGet: ${{ matrix.useRnwNuGet }}
52+
53+
call-testcli-old:
54+
name: Test CLI (Old)
55+
needs: setupcheck
56+
strategy:
57+
fail-fast: true
58+
matrix:
59+
rnwVersion: ['^0.67', '^0.69'] # test key versions (min, partners)
60+
useRnwNuGet: [false, true] # test building with both RNW source and RNW NuGet
61+
uses: ./.github/workflows/template-testcli.yml
62+
with:
63+
vmImage: windows-2019
64+
rnwVersion: ${{ matrix.rnwVersion }}
65+
useRnwNuGet: ${{ matrix.useRnwNuGet }}
66+
67+
call-buildnpmpackage:
68+
name: Build NPM Package
69+
needs: setupcheck
70+
uses: ./.github/workflows/template-buildnpmpackage.yml
71+
with:
72+
vmImage: windows-2022
73+
74+
call-buildrnx:
75+
name: Build RNX
76+
needs: setupcheck
77+
strategy:
78+
fail-fast: true
79+
matrix:
80+
configuration: ['Release']
81+
platform: ['x64']
82+
uses: ./.github/workflows/template-buildrnx.yml
83+
with:
84+
vmImage: windows-2022
85+
configuration: ${{ matrix.configuration }}
86+
platform: ${{ matrix.platform }}

0 commit comments

Comments
 (0)