-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathazure-pipelines.yml
116 lines (97 loc) · 6.65 KB
/
azure-pipelines.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
# to future maintainers considering that this is an open-source project please be mindful of the fact that this file is PUBLIC
# to future maintainers so any sensitive pieces of info (tokens, passwords, etc) should be stored in ENCRYPTED Azure DevOps pipeline variables
# to future maintainers
# to future maintainers in the same vein of thought its important to always keep an eye on the pipelines trigger-settings for PR validation
# to future maintainers to ensure that PR builds coming from people outside Laerdal fire if and only a Laerdal dev has explicitly comments
# to future maintainers on the PR with the following string [build] if this string is not present the PR build should NOT fire
trigger:
branches:
include:
- '*'
pool:
name: 'Azure Pipelines'
vmImage: 'macOS-13' # to future maintainers if you ever want to switch back to azure be warned that you will need to first make sure that macos14 is available on azure if macos14
# to future maintainers is not available on azure you will run into trouble making the build work for the latest versions of ios sdks (17+) and maccatalyst sdks
variables:
- group: shared-variables # needed for the github access token which is used to create new releases in github
- name: Laerdal_Test_Results_Folderpath
value: '$(Build.Repository.LocalPath)/TestResults'
- name: is_from_fork # its vital to use the notation variables['x'] for the environment variables below if we use variables.x the value will be evaluated as empty!
value: ${{ eq(variables['System.PullRequest.IsFork'], 'True') }}
- name: has_green_build_reason
value: ${{ in(variables['Build.Reason'], 'PullRequest', 'Manual', 'Schedule', 'BuildCompletion', 'ResourceTrigger') }}
- name: is_triggered_from_central_branches
value: ${{ in(variables['Build.SourceBranch'], 'refs/heads/main', 'refs/heads/master', 'refs/heads/develop') }}
- name: contains_build_keyword_in_commit_message
value: ${{ contains(variables['Build.SourceVersionMessage'], '[build]') }}
- name: should_build
${{ if eq(variables.is_from_fork, True) }}: # order must be checked first
value: 'No [is from fork]' # we want to explicitly disable any and all activity related to 3rd party forks in github
${{ elseif eq(variables.has_green_build_reason, True) }}:
value: 'Yes [has green build reason]'
${{ elseif eq(variables.is_triggered_from_central_branches, True) }}:
value: 'Yes [is triggered from central branches]'
${{ elseif eq(variables.contains_build_keyword_in_commit_message, True) }}:
value: 'Yes [contains build keyword in commit message]'
${{ else }}:
value: 'No [humdrum feature branch commit]'
resources:
repositories:
- repository: self
type: git
ref: refs/heads/develop
jobs:
- job: 'Skip_Build'
condition: ${{ startsWith(variables.should_build, 'No ') }}
displayName: "Should we auto-build? ... ${{ variables.should_build }} (is_from_fork=__${{ variables.is_from_fork }}__ ** has_green_build_reason=__${{ variables.has_green_build_reason }}__ ** is_triggered_from_central_branches=__${{ variables.is_triggered_from_central_branches }}__ ** contains_build_keyword_in_commit_message=__${{ variables.contains_build_keyword_in_commit_message }}__ ** IsFork=__${{ variables['System.PullRequest.IsFork'] }}__ ** Build.Reason=__${{ variables['Build.Reason'] }}__ ** SourceBranch=__${{ variables['Build.SourceBranch'] }}__ ** SourceVersionMessage=__${{ variables['Build.SourceVersionMessage'] }}__)"
steps:
- checkout: none # keep this otherwise it will make a full checkout of the repo unnecessarily
displayName: '(Skipping checkout completely ...)'
- script: 'echo "##vso[task.complete result=SucceededWithIssues;]Build skipped because this is a PR coming from a fork or because this is from a feature branch in which the latest commit message doesnt contain the keyword [build]"'
displayName: '(Set Warning-Icon ... )'
- job: 'Build'
condition: ${{ startsWith(variables.should_build, 'Yes ') }}
displayName: 'Build Agent'
steps:
- checkout: self
displayName: '🔽 Checkout'
clean: true
fetchTags: false
fetchDepth: 0
persistCredentials: True
- task: Bash@3
displayName: '🛠 Setup Build Environment'
inputs:
targetType: filePath
filePath: 'Laerdal.Scripts/Laerdal.SetupBuildEnvironment.sh'
arguments: ' "https://pkgs.dev.azure.com/LaerdalMedical/_packaging/LaerdalNuGet/nuget/v3/index.json" "$(Laerdal.NugetFeed.Username)" "$(Laerdal.NugetFeed.AccessToken)" "$(Build.ArtifactStagingDirectory)/Artifacts/" '
# notice that explicitly disabling parallelization via m:1 below is vital because if parallelization is enabled the ios and android
# builds will fail with cryptic errors due to multiple target-frameworks are involved coupled with the custom build logic for native libs
#
# also noticed that we intentionally skip the maccatalyst build on azure because under net8 we need macos14 to be available on azure but
# it is not available just yet in 2024 Q1 :(
- task: DotNetCoreCLI@2
displayName: '🏗 📦 Build, Pack & Announce New Release (if appropriate)'
inputs:
command: 'custom'
custom: 'msbuild'
arguments: 'Laerdal.Scripts/Laerdal.Builder.targets -m:1 -p:Should_Skip_MacCatalyst="true" -p:Laerdal_Gradle_Path="/usr/local/opt/gradle@7/bin/gradle" -p:Laerdal_Test_Results_Folderpath="$(Laerdal_Test_Results_Folderpath)" -p:Laerdal_Github_Access_Token="$(Github.ComponentsTeam.AccessToken)" -p:Laerdal_Repository_Path="$(Repository.Path)" -p:Laerdal_Source_Branch="$(Build.SourceBranch)" -p:PackageOutputPath="$(Build.ArtifactStagingDirectory)/Artifacts/" '
- task: PublishTestResults@2
displayName: '📡 Publish Test Results'
inputs:
testRunTitle: 'McuMgr Test Suite (Platform-Agnostic)'
mergeTestResults: true
testResultsFiles: |
$(Laerdal_Test_Results_Folderpath)/**/TEST-*.xml
$(Laerdal_Test_Results_Folderpath)/**/TEST-*.trx
testResultsFormat: 'XUnit'
publishRunAttachments: true
failTaskOnFailedTests: true
failTaskOnMissingResultsFile: true
# bare in mind that this task doesnt support wildcards
- task: PublishBuildArtifacts@1
displayName: '📡 Publish Artifacts'
inputs:
ArtifactName: 'drop'
PathtoPublish: '$(Build.ArtifactStagingDirectory)/Artifacts/'
publishLocation: 'Container'