Skip to content

Commit

Permalink
Merge branch 'master' into v-rusraut/InfobloxCloudDataConnector-MMAto…
Browse files Browse the repository at this point in the history
…AMAMigration
  • Loading branch information
v-rusraut committed Sep 29, 2023
2 parents 347a758 + fd66f23 commit 8c9301d
Show file tree
Hide file tree
Showing 1,511 changed files with 177,147 additions and 22,519 deletions.
44 changes: 39 additions & 5 deletions .azure-pipelines/callGithubWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ jobs:
- job: "CallGithubWorkflow"
pool:
vmImage: 'ubuntu-latest'
variables:
- group: autopackaging

# NAME OF THE JOB THAT DEPENDS
dependsOn:
Expand Down Expand Up @@ -54,17 +56,49 @@ jobs:
$branchName = "$(System.PullRequest.SourceBranch)"
$targetBranch = "$(System.PullRequest.TargetBranch)"
$pullRequestNumber = "$(System.PullRequest.PullRequestNumber)"
$isAutoGeneratedPR = [bool]($branchName -match "-automated-pr")
Write-Host "BranchName is $branchName, pullRequestNumber $pullRequestNumber, isAutoGeneratedPR $isAutoGeneratedPR"
$isAutoGeneratedOrDependabotPR = [bool]($branchName -match "dependabot/|-automated-pr")
Write-Host "BranchName is $branchName, pullRequestNumber $pullRequestNumber, isAutoGeneratedOrDependabotPR $isAutoGeneratedOrDependabotPR"
# NOT MAIN/MASTER OR AUTOMATED BRANCH
if ($branchName -ne 'master' -and $isAutoGeneratedPR -eq $false -and $targetBranch -eq 'master')
if ($branchName -ne 'master' -and $isAutoGeneratedOrDependabotPR -eq $false -and $targetBranch -eq 'master')
{
.script/package-automation/invokeGithubWorklow.ps1 $branchName $pullRequestNumber
# INVOKE GITHUB WORKFLOW
$header = @{
"Accept" = "application/vnd.github+json"
}
$githubToken = "$($env:GITHUB_TOKEN_VALUE)"
$token = $githubToken | ConvertTo-SecureString -AsPlainText -Force
$pullRequestNumberInt = [int]$pullRequestNumber
$client_payload = @{
"pullRequestBranchName" = "$branchName"
"pullRequestNumber" = $pullRequestNumberInt
}
$BodyJson = @{
"event_type" = "package-command"
"client_payload" = $client_payload
}
$jsonBody = $BodyJson | ConvertTo-Json
Write-Host "jsonBody $jsonBody"
$Parameters = @{
Method = "POST"
Uri = "https://api.github.com/repos/Azure/Azure-Sentinel/dispatches"
Headers = $header
ContentType = "application/json"
Body = $jsonBody
Authentication = "Bearer"
Token = $token
}
$result = Invoke-RestMethod @Parameters
Write-Host $result
}
else
{
Write-Host "Skipping Github Workflow from execution as current branch is a Master branch or is a automated PR or target branch is not master."
Write-Host "Skipping Github Workflow from execution as current branch is a Master branch/Automated PR/Dependabot or target branch is not master."
}
}
catch
Expand Down
51 changes: 3 additions & 48 deletions .github/workflows/arm-ttk-validations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,54 +17,9 @@ jobs:
id: step1
name: Identify Changes in PR
run: |
$diff = git diff --diff-filter=d --name-only HEAD^ HEAD
Write-Host "List of files in PR: $diff"
$hasmainTemplateChanged = $false
$hasCreateUiDefinitionTemplateChanged = $false
$isChangeInSolutionsFolder = [bool]($diff | Where-Object {$_ -like 'Solutions/*'})
if (!$isChangeInSolutionsFolder)
{
Write-Host "Skipping as change is not in Solutions folder!"
exit 0
}
$requiredFiles = @("mainTemplate.json", "createUiDefinition.json")
$filteredFiles = $diff | Where-Object {$_ -match ($requiredFiles -Join "|")}
Write-Host "Filtered Files $filteredFiles"
if ($filteredFiles.Count -gt 0)
{
$mainTemplateValue = $filteredFiles -match "mainTemplate.json"
$createUiValue = $filteredFiles -match "createUiDefinition.json"
if ($mainTemplateValue)
{
$hasmainTemplateChanged = $true
}
if ($createUiValue)
{
$hasCreateUiDefinitionTemplateChanged = $true
}
if ($filteredFiles.Count -eq 1)
{
$packageIndex = $filteredFiles.IndexOf("/Package")
$sName = $filteredFiles.SubString(10, $packageIndex - 10)
}
else
{
$packageIndex = $filteredFiles[0].IndexOf("/Package")
$sName = $filteredFiles[0].SubString(10, $packageIndex - 10)
}
Write-Host "SolutionName: $sName"
}
Write-Output "::set-output name=solutionName::$sName"
Write-Output "::set-output name=mainTemplateChanged::$hasmainTemplateChanged"
Write-Output "::set-output name=createUiChanged::$hasCreateUiDefinitionTemplateChanged"
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module powershell-yaml
./.script/package-automation/arm-ttk-tests.ps1
- uses: docker/build-push-action@v2
id: publishGithubPackage
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/checkAutomatedPR.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions:
pull-requests: read

env:
BRANCH_NAME: ${{ github.event.client_payload.pull_request.head.ref && github.event.client_payload.pull_request.head.ref || github.event.client_payload.pullRequestBranchName }}
BRANCH_NAME: ${{ github.event.client_payload.pull_request.head.ref || github.event.client_payload.pullRequestBranchName }}
BODY: ${{ github.event.issue.body }}

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/checkPRContentChange.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- "Solutions/**"

env:
BRANCH_NAME: ${{ github.event.client_payload.pull_request.head.ref && github.event.client_payload.pull_request.head.ref || github.event.client_payload.pullRequestBranchName }}
BRANCH_NAME: ${{ github.event.client_payload.pull_request.head.ref || github.event.client_payload.pullRequestBranchName }}

jobs:
solutionNameDetails:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/checkSkipPackagingInfo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
value: ${{ jobs.checkPackagingInfoStatus.outputs.isPackagingRequired }}

env:
BRANCH_NAME: ${{ github.event.client_payload.pull_request.head.ref && github.event.client_payload.pull_request.head.ref || github.event.client_payload.pullRequestBranchName }}
BRANCH_NAME: ${{ github.event.client_payload.pull_request.head.ref || github.event.client_payload.pullRequestBranchName }}

jobs:
checkPackagingInfoStatus:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/getSolutionName.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
value: ${{ jobs.currentPRSolutionName.outputs.sName }}

env:
BRANCH_NAME: ${{ github.event.client_payload.pull_request.head.ref && github.event.client_payload.pull_request.head.ref || github.event.client_payload.pullRequestBranchName }}
BRANCH_NAME: ${{ github.event.client_payload.pull_request.head.ref || github.event.client_payload.pullRequestBranchName }}

jobs:
currentPRSolutionName:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/neworexistingsolution.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
value: ${{ jobs.masterDetails.outputs.solutionPublisherId }}

env:
BRANCH_NAME: ${{ github.event.client_payload.pull_request.head.ref && github.event.client_payload.pull_request.head.ref || github.event.client_payload.pullRequestBranchName }}
BRANCH_NAME: ${{ github.event.client_payload.pull_request.head.ref || github.event.client_payload.pullRequestBranchName }}

jobs:
masterDetails:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/package-command.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ env:
DEFAULTPACKAGEVERSION: "${{ vars.DEFAULTPACKAGEVERSION }}"
BLOB_CONN_STRING: "${{ secrets.BLOB_CONN_STRING }}"
BASE_FOLDER_PATH: "${{ vars.BASEFOLDERPATH }}"
BRANCH_NAME: "${{ github.event.client_payload.pull_request.head.ref && github.event.client_payload.pull_request.head.ref || github.event.client_payload.pullRequestBranchName }}"
BRANCH_NAME: "${{ github.event.client_payload.pull_request.head.ref || github.event.client_payload.pullRequestBranchName }}"
ADO_TOKEN: "${{ secrets.ADO_TOKEN }}"
ADO_BASE_URL: "${{ vars.ADO_BASE_URL }}"
ADO_AREAPATH: "${{ vars.ADO_AREAPATH }}"
Expand All @@ -18,7 +18,7 @@ on:
types: [package-command, Package-command, PACKAGE-command]
jobs:
solutionNameDetails:
if: ${{ !github.event.pull_request.head.repo.fork }}
if: ${{ !github.event.pull_request.head.repo.fork && !contains(github.event.client_payload.pull_request.head.ref , 'dependabot/') && !contains(github.event.client_payload.pullRequestBranchName , 'dependabot/') }}
uses: ./.github/workflows/getSolutionName.yaml
secrets: inherit

Expand All @@ -34,7 +34,7 @@ jobs:
neworexistingsolution:
needs: [solutionNameDetails, checkSkipPackagingDetails]
uses: ./.github/workflows/neworexistingsolution.yaml
if: ${{ needs.solutionNameDetails.outputs.solutionName != '' && needs.checkSkipPackagingDetails.outputs.isPackagingRequired == 'True' }}
if: ${{ needs.solutionNameDetails.outputs.solutionName != '' && needs.checkSkipPackagingDetails.outputs.isPackagingRequired == 'True' }}
with:
solutionName: "${{ needs.solutionNameDetails.outputs.solutionName }}"
secrets: inherit
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/package-on-merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ on:
- closed
jobs:
checkAutomatedPR:
if: ${{ github.event.pull_request.merged && !github.event.pull_request.head.repo.fork }}
if: ${{ github.actor != 'dependabot[bot]' && github.event.pull_request.merged && !github.event.pull_request.head.repo.fork }}
uses: ./.github/workflows/checkAutomatedPR.yaml

solutionNameDetails:
if: ${{ github.event.pull_request.merged && !github.event.pull_request.head.repo.fork }}
if: ${{ github.actor != 'dependabot[bot]' && github.event.pull_request.merged && !github.event.pull_request.head.repo.fork }}
needs: checkAutomatedPR
uses: ./.github/workflows/getSolutionName.yaml
secrets: inherit

checkSkipPackagingDetails:
if: ${{ github.event.pull_request.merged && !github.event.pull_request.head.repo.fork && needs.solutionNameDetails.outputs.solutionName != '' }}
if: ${{ github.actor != 'dependabot[bot]' && github.event.pull_request.merged && !github.event.pull_request.head.repo.fork && needs.solutionNameDetails.outputs.solutionName != '' }}
uses: ./.github/workflows/checkSkipPackagingInfo.yaml
secrets: inherit
needs: solutionNameDetails
Expand All @@ -41,7 +41,7 @@ jobs:
neworexistingsolution:
needs: [solutionNameDetails, checkSkipPackagingDetails]
uses: ./.github/workflows/neworexistingsolution.yaml
if: ${{ needs.solutionNameDetails.outputs.solutionName != '' && needs.checkSkipPackagingDetails.outputs.isPackagingRequired == 'True' }}
if: ${{ github.actor != 'dependabot[bot]' && needs.solutionNameDetails.outputs.solutionName != '' && needs.checkSkipPackagingDetails.outputs.isPackagingRequired == 'True' }}
with:
solutionName: "${{ needs.solutionNameDetails.outputs.solutionName }}"
secrets: inherit
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/slash-command-armttk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# THIS WORKFLOW WILL RUN WHEN WE ADD SLASH COMMAND LIKE '/arm-ttk', '/ARM-TTK', '/Arm-Ttk', 'armttk' or 'ARMTTK'
name: Slash Command ARM-TTK Tests

on:
issue_comment:
types: [created, edited]

jobs:
run-arm-ttk:
runs-on: ubuntu-latest
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork && github.event.issue.pull_request && contains(fromJson('["/armttk", "/Armttk", "/ARM-TTK", "/ARMTTK", "/arm-ttk", "/ArmTtk"]'), github.event.comment.body) }}
outputs:
solutionName: ${{ steps.step1.outputs.solutionName }}
mainTemplateChanged: ${{ steps.step1.outputs.mainTemplateChanged }}
createUiChanged: ${{ steps.step1.outputs.createUiChanged }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 5
ref: refs/pull/${{ github.event.issue.number }}/head
- shell: pwsh
id: step1
name: Identify Changes in PR
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module powershell-yaml
./.script/package-automation/arm-ttk-tests.ps1
- uses: docker/build-push-action@v2
id: publishGithubPackage
name: Run ARM-TTK
if: ${{ success() && steps.step1.outcome == 'success' && steps.step1.outputs.solutionName != '' && (steps.step1.outputs.mainTemplateChanged == 'true' || steps.step1.outputs.createUiChanged == 'true') }}
env:
SolutionName: ${{ steps.step1.outputs.solutionName }}
mainTemplateChanged: ${{ steps.step1.outputs.mainTemplateChanged }}
createUiChanged: ${{ steps.step1.outputs.createUiChanged }}
with:
context: .
file: ./.github/actions/Dockerfile
push: false
build-args: |
SolutionName
mainTemplateChanged
createUiChanged
8 changes: 8 additions & 0 deletions .script/dataConnectorValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ function getConnectorCategory(dataTypes : any, instructionSteps:[])
{
return ConnectorCategory.BloodHoundEnterprise;
}
else if (dataTypes[0].name.includes("AwsS3"))
{
return ConnectorCategory.AwsS3;
}
else if (dataTypes[0].name.includes("AWS"))
{
return ConnectorCategory.AWS;
}
return "";
}
let fileTypeSuffixes = ["json"];
Expand Down
57 changes: 57 additions & 0 deletions .script/package-automation/arm-ttk-tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

try {
$diff = git diff --diff-filter=d --name-only HEAD^ HEAD
Write-Host "List of files in PR: $diff"

$hasmainTemplateChanged = $false
$hasCreateUiDefinitionTemplateChanged = $false

$isChangeInSolutionsFolder = [bool]($diff | Where-Object {$_ -like 'Solutions/*'})
if (!$isChangeInSolutionsFolder)
{
Write-Host "Skipping as change is not in Solutions folder!"
exit 0
}

$requiredFiles = @("mainTemplate.json", "createUiDefinition.json")
$filteredFiles = $diff | Where-Object {$_ -match ($requiredFiles -Join "|")}
Write-Host "Filtered Files $filteredFiles"

$sName = ''
$hasmainTemplateChanged = $false
$hasCreateUiDefinitionTemplateChanged = $false

if ($filteredFiles.Count -gt 0)
{
$mainTemplateValue = $filteredFiles -match "mainTemplate.json"
$createUiValue = $filteredFiles -match "createUiDefinition.json"

if ($mainTemplateValue -or $createUiValue)
{
$hasmainTemplateChanged = $true
$hasCreateUiDefinitionTemplateChanged = $true
}

if ($filteredFiles.Count -eq 1)
{
$packageIndex = $filteredFiles.IndexOf("/Package")
$sName = $filteredFiles.SubString(10, $packageIndex - 10)
}
else
{
$packageIndex = $filteredFiles[0].IndexOf("/Package")
$sName = $filteredFiles[0].SubString(10, $packageIndex - 10)
}
}

Write-Host "solutionName $sName, mainTemplateChanged $hasmainTemplateChanged, createUiChanged $hasCreateUiDefinitionTemplateChanged"
Write-Output "solutionName=$sName" >> $env:GITHUB_OUTPUT
Write-Output "mainTemplateChanged=$hasmainTemplateChanged" >> $env:GITHUB_OUTPUT
Write-Output "createUiChanged=$hasCreateUiDefinitionTemplateChanged" >> $env:GITHUB_OUTPUT
}
catch {
Write-Host "Skipping as exception has occured Error Details: $_"
Write-Output "solutionName=''" >> $env:GITHUB_OUTPUT
Write-Output "mainTemplateChanged=$false" >> $env:GITHUB_OUTPUT
Write-Output "createUiChanged=$false" >> $env:GITHUB_OUTPUT
}
12 changes: 12 additions & 0 deletions .script/package-automation/getSolutionName.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ try
$filteredFiles = $diff | Where-Object {$_ -match "Solutions/"} | Where-Object {$_ -notlike "Solutions/Images/*"} | Where-Object {$_ -notlike "Solutions/*.md"} | Where-Object { $_ -notlike '*system_generated_metadata.json' }
Write-Host "Filtered Files $filteredFiles"

# IDENTIFY EXCLUSIONS AND IF THERE ARE NO FILES AFTER EXCLUSION THEN SKIP WORKFLOW RUN
$exclusionList = @(".py$",".png$",".jpg$",".jpeg$",".conf$", ".svg$", ".html$", ".ps1$", ".psd1$", "requirements.txt$", "host.json$", "proxies.json$", "/function.json$", ".xml$", ".zip$", ".md$")

$filterOutExclusionList = $filteredFiles | Where-Object { $_ -notmatch ($exclusionList -join '|') }

if ($filterOutExclusionList.Count -le 0)
{
Write-Host "Skipping GitHub Action as changes in PR are not valid and contains only excluded files!"
Write-Output "solutionName=" >> $env:GITHUB_OUTPUT
exit 0
}

if ($filteredFiles.Count -gt 0)
{
if ($instrumentationKey -ne '')
Expand Down
34 changes: 0 additions & 34 deletions .script/package-automation/invokeGithubWorklow.ps1

This file was deleted.

Loading

0 comments on commit 8c9301d

Please sign in to comment.