Skip to content

Commit

Permalink
[ci] JDK matrix Buildkite pipelines (pt 2/Windows)
Browse files Browse the repository at this point in the history
This commit adds JDK matrix Buildkite pipelines for Windows 2022, 2019
and 2016.

Relates:

- elastic#15539
- elastic/ingest-dev#1725 (comment)
  • Loading branch information
dliappis committed Nov 8, 2023
1 parent d775ea6 commit cd1c7c0
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 10 deletions.
18 changes: 10 additions & 8 deletions .buildkite/scripts/jdk-matrix-tests/generate-steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def init_annotation(self) -> JobRetValues:
Command for creating the header of a new annotation for a group step
"""

body = f"### Group: `{self.os} / {self.jdk}`\n| **Status** | **Test** |\n| --- | ----|"
body = f"### Group: {self.os} / {self.jdk}\n| **Status** | **Test** |\n| --- | ----|"

return JobRetValues(
step_label="Initialize annotation",
Expand All @@ -81,21 +81,23 @@ def __init__(self, os: str, jdk: str, group_key: str):

def all_jobs(self):# -> list[Callable[[], JobRetValues]]:
return [
self.init_annotation,
self.unit_tests,
]

def unit_tests(self) -> JobRetValues:
step_name_human = "Java Unit Test"
test_command = "# TODO"
step_name_human = "Unit Test"
step_key = f"{self.group_key}-unit-test"
test_command = f'''.\\\\.buildkite\\\\scripts\\\\jdk-matrix-tests\\\\launch-command.ps1 -JDK "{self.jdk}" -StepNameHuman "{step_name_human}" -Context "{self.group_key}" -CIScript ".\\\\ci\\\\unit_tests.bat"
'''

return JobRetValues(
step_label=step_name_human,
command=test_command,
step_key="java-unit-test",
depends="",
command=LiteralScalarString(test_command),
step_key=step_key,
depends=self.init_annotation_key,
)
return step_name_human, test_command



class LinuxJobs(Jobs):
def __init__(self, os: str, jdk: str, group_key: str):
Expand Down
34 changes: 34 additions & 0 deletions .buildkite/scripts/jdk-matrix-tests/launch-command.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# ********************************************************
# This file contains prerequisite bootstrap invocations
# required for Logstash CI JDK matrix tests
# ********************************************************

$ErrorActionPreference = "Stop"

param (
[string]$JDK,
[string]$CIScript,
[switch]$StepNameHuman,
[switch]$AnnotateContext
)

# unset generic JAVA_HOME
if (Test-Path env:JAVA_HOME) {
Remove-Item -Path env:JAVA_HOME
Write-Host "--- Environment variable 'JAVA_HOME' has been unset."
} else {
Write-Host "--- Environment variable 'JAVA_HOME' doesn't exist. Continuing."
}

# LS env vars for JDK matrix tests
$JAVA_CUSTOM_DIR = "C:\.java\$JDK"
$env:BUILD_JAVA_HOME = $JAVA_CUSTOM_DIR
$env:RUNTIME_JAVA_HOME = $JAVA_CUSTOM_DIR
$env:LS_JAVA_HOME = $JAVA_CUSTOM_DIR

& $CIScript
if ($LASTEXITCODE -ne 0) {
buildkite-agent annotate --context=$AnnotateContext --append "| :bk-status-failed: | $StepNameHuman |\n"
exit 1
}
buildkite-agent annotate --context=$AnnotateContext --append "| :bk-status-passed: | $StepNameHuman |\n"
66 changes: 64 additions & 2 deletions .buildkite/windows_jdk_matrix_pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,65 @@
steps:
- label: "Test Windows JDK matrix pipeline"
command: "echo 'Hello world'"
- input: "Test Parameters"
if: build.source != "schedule"
fields:
- select: "Operating System"
key: "matrix-os"
hint: "The operating system variant(s) to run on:"
required: true
multiple: true
default: "windows-2022"
options:
- label: "Windows 2022"
value: "windows-2022"
- label: "Windows 2019"
value: "windows-2019"
- label: "Windows 2016"
value: "windows-2016"

- select: "Java"
key: "matrix-jdk"
hint: "The JDK to test with:"
required: true
multiple: true
default: "adoptiumjdk_17"
options:
- label: "Adoptium JDK 17 (Eclipse Temurin)"
value: "adoptiumjdk_17"
- label: "Adopt OpenJDK 11"
value: "adoptopenjdk_11"
- label: "OpenJDK 17"
value: "openjdk_17"
- label: "OpenJDK 11"
value: "openjdk_11"
- label: "Zulu 17"
value: "zulu_17"
- label: "Zulu 11"
value: "zulu_11"

- wait: ~
if: build.source != "schedule"

- command: |
set -euo pipefail
echo "--- Downloading prerequisites"
python3 -m pip install ruamel.yaml
echo "--- Printing generated dynamic steps"
export MATRIX_OSES="$(buildkite-agent meta-data get matrix-os)"
export MATRIX_JDKS="$(buildkite-agent meta-data get matrix-jdk)"
set +eo pipefail
python3 .buildkite/scripts/jdk-matrix-tests/generate-steps.py >pipeline_steps.yml
if [[ $$? -ne 0 ]]; then
echo "^^^ +++"
echo "There was a problem rendering the pipeline steps."
cat pipeline_steps.yml
echo "Exiting now."
exit 1
else
set -eo pipefail
cat pipeline_steps.yml
fi
echo "--- Uploading steps to buildkite"
cat pipeline_steps.yml | buildkite-agent pipeline upload

0 comments on commit cd1c7c0

Please sign in to comment.