Skip to content

Commit c833bc6

Browse files
authored
Add ADO Pipeline (#116)
1 parent d486cc4 commit c833bc6

4 files changed

+271
-0
lines changed

CSharpJobTemplate.yml

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# JOB LEVEL TEMPLATE:
2+
# Used to build CSharp
3+
# Reusable
4+
# Meant to be run from the single CSharpTemplate pipeline (default), or
5+
# from a multi-pipeline such as publishing (should specify alternate params)
6+
7+
parameters:
8+
- name: ApiSpecSource
9+
displayName: ApiSpecSource
10+
type: string
11+
default: -apiSpecGitUrl https://raw.githubusercontent.com/PlayFab/API_Specs/master/
12+
- name: CommitMessage
13+
displayName: CommitMessage
14+
type: string
15+
default: Automated build from ADO Pipeline
16+
- name: GitDestBranch
17+
displayName: GitDestBranch
18+
type: string
19+
default: doNotCommit
20+
- name: GitJSetupBranch
21+
displayName: GitJSetupBranch
22+
type: string
23+
default: master
24+
- name: GitSdkGenBranch
25+
displayName: GitSdkGenBranch
26+
type: string
27+
default: master
28+
- name: isVersioned
29+
displayName: isVersioned
30+
type: boolean
31+
default: false
32+
- name: TestCompile
33+
displayName: TestCompile
34+
type: boolean
35+
default: true
36+
- name: TestWin32NetCore
37+
displayName: TestWin32NetCore
38+
type: boolean
39+
default: true
40+
- name: TestWin32Basic
41+
displayName: TestWin32Basic
42+
type: boolean
43+
default: true
44+
- name: SelfTemplateResource
45+
displayName: SelfTemplateResource
46+
type: string
47+
default: self
48+
49+
jobs:
50+
- job: CSharpJobTemplate
51+
steps:
52+
- bash: echo CSharpJobTemplate
53+
- job: CSharpTemplate
54+
pool:
55+
vmImage: 'windows-latest'
56+
steps:
57+
- template: CSharpStepTemplate.yml
58+
parameters:
59+
ApiSpecSource: ${{ parameters.ApiSpecSource }}
60+
CommitMessage: ${{ parameters.CommitMessage }}
61+
GitDestBranch: ${{ parameters.GitDestBranch }}
62+
GitJSetupBranch: ${{ parameters.GitJSetupBranch }}
63+
GitSdkGenBranch: ${{ parameters.GitSdkGenBranch }}
64+
isVersioned: ${{ parameters.isVersioned }}
65+
TestCompile: ${{ parameters.TestCompile }}
66+
TestWin32NetCore: ${{ parameters.TestWin32NetCore }}
67+
TestWin32Basic: ${{ parameters.TestWin32Basic }}
68+
SelfTemplateResource: ${{ parameters.SelfTemplateResource }}

CSharpResourceTemplate.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# TOP LEVEL TEMPLATE:
2+
# Can only be used to run the single CSharpTemplate pipeline.
3+
# Why: Resources can only be defined once.
4+
# This determines the resources available to all "jobs" and "steps" no matter which templates are loaded after this
5+
# If resources is ever defined again, it'll break so badly that the pipeline won't even parse
6+
7+
resources:
8+
repositories:
9+
- repository: JenkinsSdkSetupScripts
10+
type: github
11+
endpoint: GitHub_PlayFab
12+
name: PlayFab/JenkinsSdkSetupScripts
13+
- repository: API_Specs
14+
type: github
15+
endpoint: GitHub_PlayFab
16+
name: PlayFab/API_Specs
17+
- repository: SdkGenerator
18+
type: github
19+
endpoint: GitHub_PlayFab
20+
name: PlayFab/SdkGenerator
21+
- repository: CSharpSDK
22+
endpoint: GitHub_PlayFab
23+
type: github
24+
name: PlayFab/CSharpSDK
25+
26+
jobs:
27+
- job: CSharpResourceTemplate
28+
steps:
29+
- bash: echo CSharpResourceTemplate
30+
- template: CSharpJobTemplate.yml

CSharpStepTemplate.yml

+165
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
# STEPS LEVEL TEMPLATE:
2+
# Used to build CSharp
3+
# Reusable
4+
# Used to "hide" the additional variables specific to this SDK which shouldn't be set from a higher level, or
5+
# shared from a multi-build pipeline like a publish
6+
7+
parameters:
8+
- name: ApiSpecSource
9+
displayName: ApiSpecSource
10+
type: string
11+
default: -apiSpecGitUrl https://raw.githubusercontent.com/PlayFab/API_Specs/master/
12+
- name: CommitMessage
13+
displayName: CommitMessage
14+
type: string
15+
default: Automated build from ADO Pipeline
16+
- name: GitDestBranch
17+
displayName: GitDestBranch
18+
type: string
19+
default: doNotCommit
20+
- name: SdkName
21+
displayName: SdkName
22+
type: string
23+
default: CSharpSDK
24+
- name: GitJSetupBranch
25+
displayName: GitJSetupBranch
26+
type: string
27+
default: master
28+
- name: GitSdkGenBranch
29+
displayName: GitSdkGenBranch
30+
type: string
31+
default: master
32+
- name: isVersioned
33+
displayName: isVersioned
34+
type: boolean
35+
default: false
36+
- name: TestCompile
37+
displayName: TestCompile
38+
type: boolean
39+
default: true
40+
- name: TestWin32NetCore
41+
displayName: TestWin32NetCore
42+
type: boolean
43+
default: true
44+
- name: TestWin32Basic
45+
displayName: TestWin32Basic
46+
type: boolean
47+
default: true
48+
- name: SelfTemplateResource
49+
displayName: SelfTemplateResource
50+
type: string
51+
default: self
52+
53+
steps:
54+
- checkout: JenkinsSdkSetupScripts
55+
clean: true
56+
path: s
57+
- checkout: API_Specs
58+
clean: true
59+
path: s/API_Specs
60+
- checkout: SdkGenerator
61+
clean: true
62+
path: s/SdkGenerator
63+
- checkout: ${{ parameters.SelfTemplateResource }}
64+
clean: true
65+
submodules: true
66+
path: s/sdks/CSharpSDK
67+
persistCredentials: true
68+
- bash: |
69+
set -e
70+
71+
echo alias the ADO variables into local variables
72+
ApiSpecSource="${{ parameters.ApiSpecSource }}"
73+
CommitMessage="${{ parameters.CommitMessage }}"
74+
GitDestBranch="${{ parameters.GitDestBranch }}"
75+
SdkName="${{ parameters.SdkName }}"
76+
TestCompile="${{ parameters.TestCompile }}"
77+
TestWin32Basic="${{ parameters.TestWin32Basic }}"
78+
TestWin32NetCore="${{ parameters.TestWin32NetCore }}"
79+
WORKSPACE=$(pwd -W)
80+
# Hack attempt to get WORKSPACE into a sub-environment
81+
export WORKSPACE="$WORKSPACE"
82+
83+
echo === load util.sh to find msbuild ===
84+
if [ -f "util.sh" ]; then
85+
. "./util.sh" 2> /dev/null
86+
elif [ ! -z "$WORKSPACE" ]; then
87+
. "$WORKSPACE/JenkinsSdkSetupScripts/JenkinsScripts/Pipeline/util.sh" 2> /dev/null
88+
fi
89+
90+
Find2019MsBuild || Find2017MsBuild
91+
92+
cd "$WORKSPACE/sdks/$SdkName"
93+
94+
. "$WORKSPACE/JenkinsSdkSetupScripts/JenkinsScripts/Pipeline/testInit.sh"
95+
96+
cd "$WORKSPACE/SDKGenerator/SDKBuildScripts"
97+
targetSrc="csharp"
98+
export PF_TEST_TITLE_DATA_JSON="$WORKSPACE\JenkinsSdkSetupScripts\Creds\testTitleData.json"
99+
. ./shared_build.sh
100+
101+
if [ $TestCompile = true ] ;
102+
then
103+
echo === Build the CSharp Project ===
104+
"$MSBUILD_EXE" "$WORKSPACE//sdks//$SdkName//PlayFabSDK//PlayFabSDK.sln" //restore //p:configuration="Debug" //t:Rebuild
105+
fi
106+
107+
cd "$WORKSPACE/sdks/$SdkName/PlayFabSDK"
108+
109+
if [ $TestWin32NetCore = true ] ;
110+
then
111+
echo === Build the CSharp UnitTestRunner ===
112+
"$MSBUILD_EXE" "$WORKSPACE//sdks//$SdkName//PlayFabSDK//UnittestRunner//UnittestRunner.csproj" //restore //p:configuration="Release" //t:Rebuild
113+
echo === Run the CSharpSdk UnitTestRunner net core app 2.0 ===
114+
cd "$WORKSPACE/sdks/$SdkName/PlayFabSDK/UnittestRunner/bin/Release/netcoreapp2.0"
115+
cmd <<< dotnet .\\UnittestRunner.dll -testInputsFile "$WORKSPACE\\JenkinsSdkSetupScripts\\Creds\\testTitleData.json"
116+
fi
117+
118+
if [ $TestWin32Basic = true ] ;
119+
then
120+
echo === Build PlayFabSDK+Unit.sln ===
121+
"$MSBUILD_EXE" "$WORKSPACE//sdks//$SdkName//PlayFabSDK//PlayFabSDK+Unit.sln" //restore //p:configuration="Release" //t:Rebuild
122+
echo === Run PlayFabSDK+Unit.sln ===
123+
cd "$WORKSPACE//sdks//$SdkName//PlayFabSDK//UnittestRunner//bin//Release//net45"
124+
cmd <<< UnittestRunner.exe -testInputsFile "$WORKSPACE//JenkinsSdkSetupScripts//Creds//testTitleData.json"
125+
fi
126+
127+
if [ $TestWin32Basic = true ] || [ $TestWin32NetCore = true ] || [ $TestCompile = true ] ;
128+
then
129+
"$MSBUILD_EXE" "$WORKSPACE//SDKGenerator//JenkinsConsoleUtility//JenkinsConsoleUtility.sln" //restore //p:configuration="Debug" //p:platform="Any CPU" //t:Rebuild
130+
cd "$WORKSPACE//SDKGenerator//JenkinsConsoleUtility"
131+
ListenCsJCU
132+
fi
133+
134+
if [ $isVersioned = true ] ;
135+
then
136+
cd "$WORKSPACE\SDKGenerator\JenkinsConsoleUtility\bin\Debug"
137+
cmd <<< "JenkinsConsoleUtility.exe --version -SdkName $SdkName -workspacepath "$WORKSPACE" -destFile version_$EXECUTOR_NUMBER.txt $apiSpecSource"
138+
echo TODO inject environment variable - $WORKSPACE/version_$EXECUTOR_NUMBER.txt ?
139+
touch $WORKSPACE/version_$EXECUTOR_NUMBER
140+
141+
echo === publish .NetCore nuget package ===
142+
echo This step is disabled for now, because we are still publishing the 4.5 package.
143+
echo We should decide at some point what and how to deal with the additional .netcore package
144+
echo cd "$WORKSPACE\sdks\$SdkName\PlayFabSDK\source"
145+
echo dotnet pack --configuration Release --output bin\out .\PlayFabSDK.csproj
146+
echo nuget push .\bin\out\PlayFabAllSDK.$sdkVersion.nupkg -Source nuget.org -A $NUGET_API_KEY
147+
148+
echo === publish .Net45 nuget package ===
149+
cd "$WORKSPACE\sdks\$SdkName\PlayFabSDK\source"
150+
dotnet pack --configuration Release --output bin\out .\PlayFabSDK.csproj
151+
nuget push bin\out\PlayFabAllSDK.$sdkVersion.nupkg -Source nuget.org -A $NUGET_API_KEY
152+
153+
echo === publish CloudScript plugin ===
154+
echo this step is disabled until we can discover why this is trying to access XPlat
155+
echo cd "$WORKSPACE\sdks\$SdkName\Plugins\CloudScript\source"
156+
echo dotnet pack --configuration Release --output bin\out .\PlayFabCloudScriptPlugin.csproj
157+
echo nuget push bin\out\PlayFabCloudScriptPlugin.$sdkVersion-alpha.nupkg -Source nuget.org -A $NUGET_API_KEY
158+
fi
159+
160+
displayName: 'Build/Test/Report'
161+
- task: PublishTestResults@2
162+
inputs:
163+
testResultsFormat: 'JUnit'
164+
testResultsFiles: '*.xml'
165+
testRunTitle: CSharpTemplate

azure-pipelines.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
pool:
2+
vmImage: 'ubuntu-latest'
3+
4+
trigger:
5+
- master
6+
7+
extends:
8+
template: CSharpResourceTemplate.yml

0 commit comments

Comments
 (0)