forked from xamarin/xamarin-macios
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CI] Create the initial stage to start running APIScan. (xamarin#19828)
APIScan is slow (as per their own documentation). To ensure that the extra check does not slow our CI we create a matrix that will run APIScan in each of the platforms to later be uploaded to TSA via a funnel job.
- Loading branch information
1 parent
4dffdce
commit b7f4bef
Showing
8 changed files
with
189 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
class APIScanConfiguration { | ||
[string[]] $enabledPlatforms | ||
|
||
APIScanConfiguration ( | ||
[string[]] $enabledPlatforms) { | ||
$this.enabledPlatforms = $enabledPlatforms | ||
} | ||
|
||
[string] Create() { | ||
$vars = [ordered]@{} | ||
Write-Host "enabledPlatforms: $($this.enabledPlatforms)" | ||
|
||
foreach ($platform in $this.enabledPlatforms) { | ||
# dictionary with the secrets needed by each matrix | ||
$platformVars = [ordered]@{ | ||
CLIENT_ID = $Env:API_SCAN_CLIENT_ID; | ||
TENANT = $Env:API_SCAN_TENANT; | ||
SECRET = "`$(API_SCAN_SECRET_$($platform.ToUpper()))"; | ||
PLATFORM = $platform.ToUpper(); | ||
} | ||
$vars[$platform] = $platformVars | ||
} | ||
|
||
return $vars | ConvertTo-Json | ||
} | ||
|
||
} | ||
|
||
function Get-APIScanConfiguration { | ||
param | ||
( | ||
[Parameter(Mandatory)] | ||
[string] | ||
[AllowEmptyString()] | ||
$EnabledPlatforms | ||
) | ||
|
||
$arrEnabledPlatforms = -split $EnabledPlatforms | ||
$config = [APIScanConfiguration]::new($arrEnabledPlatforms) | ||
return $config.Create() | ||
} | ||
|
||
# export public functions, other functions are private and should not be used outside the module. | ||
Export-ModuleMember -Function Get-APIScanConfiguration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
parameters: | ||
|
||
- name: isPR | ||
type: boolean | ||
|
||
- name: repositoryAlias | ||
type: string | ||
default: self | ||
|
||
- name: commit | ||
type: string | ||
default: HEAD | ||
|
||
- name: uploadPrefix | ||
type: string | ||
default: '$(MaciosUploadPrefix)' | ||
|
||
steps: | ||
|
||
- template: ../common/checkout.yml | ||
parameters: | ||
isPR: ${{ parameters.isPR }} | ||
repositoryAlias: ${{ parameters.repositoryAlias }} | ||
commit: ${{ parameters.commit }} | ||
|
||
- pwsh: | | ||
Write-Output "Performing APISCan for $(PLATFORM) using tenant $(TENANT) client id $(CLIENT_ID) and secret $(SECRET)." | ||
displayName: "APISCan" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# contains the stage used to run all governance related jobs | ||
|
||
parameters: | ||
- name: isPR | ||
type: boolean | ||
|
||
- name: repositoryAlias | ||
type: string | ||
default: self | ||
|
||
- name: commit | ||
type: string | ||
default: HEAD | ||
|
||
- name: stageDisplayNamePrefix | ||
type: string | ||
default: '' | ||
|
||
|
||
stages: | ||
- stage: governance_checks | ||
displayName: '${{ parameters.stageDisplayNamePrefix }}Governance Checks' | ||
dependsOn: [ configure_build ] | ||
|
||
jobs: | ||
- job: apiscan | ||
displayName: 'APIScan:' | ||
pool: | ||
vmImage: windows-latest | ||
|
||
|
||
strategy: | ||
matrix: $[ stageDependencies.configure_build.configure.outputs['apiscan_matrix.APISCAN_MATRIX'] ] | ||
|
||
steps: | ||
- template: ./apiscan.yml | ||
parameters: | ||
isPR: ${{ parameters.isPR }} | ||
repositoryAlias: ${{ parameters.repositoryAlias }} | ||
commit: ${{ parameters.commit }} | ||
|
||
- job: general_governance | ||
displayName: 'Governance Checks' | ||
pool: | ||
vmImage: windows-latest | ||
|
||
steps: | ||
- template: ./general.yml | ||
parameters: | ||
isPR: ${{ parameters.isPR }} | ||
repositoryAlias: ${{ parameters.repositoryAlias }} | ||
commit: ${{ parameters.commit }} | ||
|
||
- job: tsa_upload | ||
displayName: 'TSA Upload' | ||
dependsOn: [ general_governance, apiscan ] | ||
pool: | ||
vmImage: windows-latest | ||
|
||
variables: | ||
${{ each p in parameters.platforms }}: | ||
INCLUDE_DOTNET_${{ upper(p.key) }}: $[ stageDependencies.configure_build.configure.outputs['configure_platforms.INCLUDE_DOTNET_${{ upper(p.key)}}'] ] | ||
|
||
steps: | ||
- template: ./tsa-upload.yml | ||
parameters: | ||
isPR: ${{ parameters.isPR }} | ||
repositoryAlias: ${{ parameters.repositoryAlias }} | ||
commit: ${{ parameters.commit }} |
28 changes: 28 additions & 0 deletions
28
tools/devops/automation/templates/governance/tsa-upload.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
parameters: | ||
|
||
- name: isPR | ||
type: boolean | ||
|
||
- name: repositoryAlias | ||
type: string | ||
default: self | ||
|
||
- name: commit | ||
type: string | ||
default: HEAD | ||
|
||
- name: uploadPrefix | ||
type: string | ||
default: '$(MaciosUploadPrefix)' | ||
|
||
steps: | ||
|
||
- template: ../common/checkout.yml | ||
parameters: | ||
isPR: ${{ parameters.isPR }} | ||
repositoryAlias: ${{ parameters.repositoryAlias }} | ||
commit: ${{ parameters.commit }} | ||
|
||
- pwsh: | | ||
Write-Output "Upload to tsa." | ||
displayName: "Debug" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters