-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added changeset ps1 script and updated xpack-winlogbeat pipeline
- Loading branch information
Showing
3 changed files
with
99 additions
and
29 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,71 @@ | ||
function ArePathsChanged($patterns) { | ||
$changedlist = @() | ||
foreach ($pattern in $patterns) { | ||
$changedFiles = & git diff --name-only "HEAD@{1}" HEAD | Select-String -Pattern $pattern | ||
if ($changedFiles) { | ||
$changedlist += $changedFiles | ||
} | ||
} | ||
if ($changedlist) { | ||
Write-Output "--- Files changed:" | ||
Write-Output $changedlist | ||
return $true | ||
} | ||
else { | ||
Write-Output "--- No files changed within specified changeset:" | ||
Write-Output $patterns | ||
return $false | ||
} | ||
} | ||
|
||
function AreChangedOnlyPaths($patterns) { | ||
$changedFiles = & git diff --name-only "HEAD@{1}" HEAD | ||
$matchedFiles = @() | ||
foreach ($pattern in $patterns) { | ||
$matched = $changedFiles | Select-String -Pattern $pattern | ||
if ($matched) { | ||
$matchedFiles += $matched | ||
} | ||
} | ||
if (($matchedFiles.Count -eq $changedFiles.Count) -or ($changedFiles.Count -eq 0)) { | ||
return $true | ||
} | ||
return $false | ||
} | ||
|
||
# This function sets a `MODULE` env var, required by IT tests, containing a comma separated list of modules for a given beats project (specified via the first argument). | ||
# The list is built depending on directories that have changed under `modules/` excluding anything else such as asciidoc and png files. | ||
# `MODULE` will empty if no changes apply. | ||
function DefineModuleFromTheChangeSet($projectPath) { | ||
$projectPathTransformed = $projectPath -replace '/', '\\' | ||
$projectPathExclusion = "((?!^$projectPathTransformed\\\/).)*\$" | ||
$exclude = @("^($projectPathExclusion|((?!\\/module\\/).)*\$|.*\\.asciidoc|.*\\.png)") | ||
|
||
$changedModules = '' | ||
|
||
$moduleDirs = Get-ChildItem -Directory "$projectPath\module" | ||
foreach($moduleDir in $moduleDirs) { | ||
if((ArePathsChanged($moduleDir)) -and !(AreChangedOnlyPaths($exclude))) { | ||
if(!$changedModules) { | ||
$changedModules = $moduleDir.Name | ||
} | ||
else { | ||
$changedModules += ',' + $moduleDir.Name | ||
} | ||
} | ||
} | ||
|
||
# TODO: remove this conditional when issue https://github.com/elastic/ingest-dev/issues/2993 gets resolved | ||
if(!$changedModules) { | ||
if($Env:BUILDKITE_PIPELINE_SLUG -eq 'beats-xpack-metricbeat') { | ||
$Env:MODULE = "aws" | ||
} | ||
else { | ||
$Env:MODULE = "kubernetes" | ||
} | ||
} | ||
else { | ||
# TODO: once https://github.com/elastic/ingest-dev/issues/2993 gets resolved, this should be the only thing we export | ||
$Env:MODULE = $changedModules | ||
} | ||
} |
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