-
Notifications
You must be signed in to change notification settings - Fork 518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CI] Create the initial stage to start running APIScan. #19828
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b54d082
[CI] Create the inital stage to start running APIScan.
mandel-macaque b77f489
Move platforms to a parameter.
mandel-macaque c55ed92
Use parameter for the vars in the upload.
mandel-macaque b69e67a
Merge branch 'main' into download-workloads-apiscan
mandel-macaque bcaa9d6
Start moving to the use of a config + matrix approach.
mandel-macaque 6b9cc52
Merge branch 'main' into download-workloads-apiscan
mandel-macaque f372bb6
Clean left behind code.
mandel-macaque File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the secret be displayed like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Devops is super smart (for once), and knows not to display them: