-
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.
Browse files
Browse the repository at this point in the history
…9101) * Buildkite Xpack/Winlogbeat pipeline fixes (#39007) * updated common.sh * fixed typo * updated common.sh * added changeset ps1 script and updated xpack-winlogbeat pipeline * pr fixes * handle backslashes in changeset directories (cherry picked from commit 243f9c3) * resolved conflicts * moved win-2016 step to extended --------- Co-authored-by: Olga Naydyonock <olga.naidjonoka@elastic.co> Co-authored-by: Olga Naidjonoka <olga_naidjonoka@epam.com>
- Loading branch information
1 parent
7b5bfe4
commit 1614b93
Showing
3 changed files
with
102 additions
and
34 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,72 @@ | ||
function ArePathsChanged($patterns) { | ||
$changedlist = @() | ||
foreach ($pattern in $patterns) { | ||
$changedFiles = & git diff --name-only "HEAD@{1}" HEAD | Select-String -Pattern $pattern -SimpleMatch | ||
if ($changedFiles) { | ||
$changedlist += $changedFiles | ||
} | ||
} | ||
if ($changedlist) { | ||
Write-Host "--- Files changed: $changedlist" | ||
return $true | ||
} | ||
else { | ||
Write-Host "--- No files changed within specified changeset: $patterns" | ||
return $false | ||
} | ||
} | ||
|
||
function AreChangedOnlyPaths($patterns) { | ||
$changedFiles = & git diff --name-only "HEAD@{1}" HEAD | ||
Write-Host "--- Git Diff result:" | ||
Write-Host "$changedFiles" | ||
|
||
$matchedFiles = @() | ||
foreach ($pattern in $patterns) { | ||
$matched = $changedFiles | Select-String -Pattern $pattern -SimpleMatch | ||
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