forked from microsoft/fluentui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypescript-compatibility-build.yml
194 lines (174 loc) · 6.53 KB
/
typescript-compatibility-build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
trigger:
branches:
include:
- tsc-compat-debug
- refs/tags/office-ui-fabric-react_v*
variables:
- name: PackageName
value: office-ui-fabric-react
- name: CompatRepoUrl
value: https://github.com/Microsoft/ui-fabric-ts-validation.git
- name: NodeVersion
value: '10.x'
- name: VmImage
value: 'Ubuntu 16.04'
jobs:
- job: Build
pool:
vmImage: $(VmImage)
timeoutInMinutes: 60
steps:
- checkout: self
clean: true
- task: NodeTool@0
displayName: 'Use Node $(NodeVersion)'
inputs:
versionSpec: '$(NodeVersion)'
checkLatest: true
# Install Rush repo dependencies
- script: |
node common/scripts/install-run-rush.js install --bypass-policy
displayName: Run Rush install in office-ui-fabric-react repository
# Build package in Rush repo
- script: |
node common/scripts/install-run-rush.js build --to $(PackageName)
displayName: Run Rush build --to $(PackageName)
# Run npm pack to simulate installation from feed
- script: |
npm pack ./packages/$(PackageName)
displayName: Run npm pack $(PackageName)
# Save ReleaseId into a txt artifact file
- script: |
echo *.tgz | grep -oP '(?<=office-ui-fabric-react-).*(?=.tgz)' >> $(Build.StagingDirectory)/compatMap.txt
name: setReleaseIdStep
displayName: Save ReleaseId into a txt artifact file
# Rename built package tarball to reference later
- script: |
mv *.tgz $(Build.StagingDirectory)/$(PackageName).tgz
displayName: Move $(PackageName).tgz to Build.StagingDirectory
# Publish built library for validation job
- task: PublishBuildArtifacts@1
displayName: Publish Build Artifacts
inputs:
pathtoPublish: $(Build.StagingDirectory)
artifactName: compatMapDrop
- job: Compatibility
dependsOn: Build
condition: succeeded()
timeoutInMinutes: 60
pool:
vmImage: $(VmImage)
strategy:
maxParallel: 1
matrix:
'TypeScript 2.4':
TypeScriptVersion: 2.4
'TypeScript 2.7':
TypeScriptVersion: 2.7
'TypeScript 2.8':
TypeScriptVersion: 2.8
'TypeScript 2.9':
TypeScriptVersion: 2.9
'TypeScript 3.0':
TypeScriptVersion: 3.0
'TypeScript 3.1':
TypeScriptVersion: 3.1
'TypeScript 3.2':
TypeScriptVersion: 3.2
'TypeScript 3.3':
TypeScriptVersion: 3.3
'TypeScript 3.4':
TypeScriptVersion: 3.4
steps:
- checkout: none
- task: NodeTool@0
displayName: 'Use Node $(NodeVersion)'
inputs:
versionSpec: '$(NodeVersion)'
checkLatest: true
# Download build library
- task: DownloadBuildArtifacts@0
displayName: 'Download Build Artifacts'
inputs:
artifactName: compatMapDrop
downloadPath: $(Build.StagingDirectory)
# Clone repository containing versioned TypeScript sample apps
- script: |
git clone $(CompatRepoUrl) $(Build.StagingDirectory)/__tests__
displayName: Clone compatibility repository
# Install repository's dependencies
- script: |
node common/scripts/install-run-rush.js install
displayName: Run Rush install in compatibility repository
workingDirectory: $(Build.StagingDirectory)/__tests__
# Install built package tarball in sample app
- script: |
npm install $(Build.StagingDirectory)/compatMapDrop/$(PackageName).tgz
displayName: Install $(PackageName) in TypeScript $(TypeScriptVersion) test app
workingDirectory: $(Build.StagingDirectory)/__tests__/tests/$(TypeScriptVersion)
# Build sample app consuming Fluent UI React to test TypeScript version compatibility
- script: |
node common/scripts/install-run-rush.js test --to $(TypeScriptVersion)-office-ui-fabric-react-test
displayName: Build TypeScript $(TypeScriptVersion) test app
workingDirectory: $(Build.StagingDirectory)/__tests__
# Write successful ts versions to compatMap.txt
- script: |
echo $(TypeScriptVersion) >> $(Build.StagingDirectory)/compatMapDrop/compatMap.txt
displayName: Write successful ts versions to compatMap.txt
# Publish built library for validation job
- task: PublishBuildArtifacts@1
displayName: Publish Build Artifacts
inputs:
pathtoPublish: $(Build.StagingDirectory)/compatMapDrop
artifactName: compatMapDrop
- job: InvokePOSTAPI
dependsOn: Compatibility
condition: always()
timeoutInMinutes: 60
pool:
vmImage: $(VmImage)
steps:
# Download build library
- task: DownloadBuildArtifacts@0
displayName: 'Download Build Artifacts'
inputs:
artifactName: compatMapDrop
downloadPath: $(Build.StagingDirectory)
# Invoke POST API with json body
# The artifact file compatMap.txt which has the TS compatibility folows the below format,
# where the first line is the OUFR release and the subsequent lines are the TS versions supported
# 6.182.1
# 2.8
# 2.9
# 3.0
# 3.1
# 3.2
# 3.3
# 3.4
# It is then concatenated into a format like 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4
# and the fabricweb backend API is invoked which writes these entrie to an Azure table
- powershell: $i = 0;
$releaseVersion = "";
$compatibleTsVersions = "";
$compatMapArray = Get-Content $env:BUILD_STAGINGDIRECTORY/compatMapDrop/compatMap.txt;
foreach($line in $compatMapArray) {
if($i -match 0) {
$releaseVersion = $line;
} else {
if($i -match 1) {
$compatibleTsVersions += $line;
} else {
$compatibleTsVersions += ", ";
$compatibleTsVersions += $line;
}
}
$i++;
}
Write-Host $releaseVersion;
Write-Host $compatibleTsVersions;
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]";
$headers.Add("AuthToken", "$(releaseVersionVariable)");
$APIUrl = "https://fabricweb.azurewebsites.net/oufr/registerNewWithTsCompat?version=$releaseVersion&compatibleTsVersions=$compatibleTsVersions";
$response = Invoke-RestMethod -Uri $APIUrl -Method Get -Headers $headers;
Write-Host $response;
displayName: Invoke POST API with json body