Skip to content

Commit

Permalink
Update trigger_beta_build and daily Slack status jobs to handle jdk(h…
Browse files Browse the repository at this point in the history
…ead) version branching (#1046)

* Ensure correct version tags are triggered for EA builds

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Ensure correct version tags are triggered for EA builds

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Ensure correct version tags are triggered for EA builds

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Ensure correct version tags are triggered for EA builds

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Ensure correct version tags are triggered for EA builds

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Ensure correct version tags are triggered for EA builds

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Ensure correct version tags are triggered for EA builds

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Ensure correct version tags are triggered for EA builds

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Ensure correct version tags are triggered for EA builds

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Try super-linter 6.6.0

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Try super-linter 6.6.0

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Try super-linter 6.6.0

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Ensure correct version tags are triggered for EA builds

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

---------

Signed-off-by: Andrew Leonard <anleonar@redhat.com>
  • Loading branch information
andrew-m-leonard authored Jun 20, 2024
1 parent 03479cd commit f0af2f2
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 33 deletions.
6 changes: 6 additions & 0 deletions .github/linters/.jscpd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"threshold": 0,
"ignore": [
"**/*.groovy"
]
}
4 changes: 3 additions & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
# Run Linter against code base #
################################
- name: Lint Code Base
uses: github/super-linter@45fc0d88288beee4701c62761281edfee85655d7 # v5.0.0
uses: github/super-linter@88ea3923a7e1f89dd485d079f6eb5f5e8f937589 # v6.6.0
env:
VALIDATE_ALL_CODEBASE: false
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -62,3 +62,5 @@ jobs:
# Someone should investigate adding these at some point
VALIDATE_DOCKERFILE: false
VALIDATE_DOCKERFILE_HADOLINT: false
# checkov fails
VALIDATE_CHECKOV: false
13 changes: 10 additions & 3 deletions pipelines/build/common/trigger_beta_build.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,16 @@ def loadTargetConfigurations(String javaVersion, String variant, String configSe
}

node('worker') {
def adopt_tag_search = 'grep "_adopt"'
if (mirrorRepo.contains("aarch32-jdk8u")) {
adopt_tag_search = adopt_tag_search + ' | grep "\\-aarch32\\-"'
def adopt_tag_search
if (version == 8) {
// eg. jdk8u422-b03_adopt
adopt_tag_search = 'grep "jdk8u.*_adopt"'
if (mirrorRepo.contains("aarch32-jdk8u")) {
adopt_tag_search = adopt_tag_search + ' | grep "\\-aarch32\\-"'
}
} else {
// eg. jdk-11.0.24+6_adopt or jdk-23+26_adopt
adopt_tag_search = 'grep "jdk-'+version+'[\\.\\+].*_adopt"'
}

// Find latest _adopt tag for this version?
Expand Down
68 changes: 39 additions & 29 deletions tools/nightly_build_and_test_stats.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,7 @@ def isGaTag(String version, String tag) {
return false
}

def openjdkRepo = "https://github.com/openjdk/${version}.git"
if (version == "aarch32-jdk8u") {
openjdkRepo = "https://github.com/openjdk/aarch32-port-jdk8u.git"
} else if (version == "alpine-jdk8u") {
openjdkRepo = "https://github.com/openjdk/jdk8u.git"
}
def openjdkRepo = getUpstreamRepo(version)

def tagCommitSHA = sh(returnStdout: true, script:"git ls-remote --tags ${openjdkRepo} | grep '\\^{}' | grep \"${tag}\" | tr -s '\\t ' ' ' | cut -d' ' -f1 | tr -d '\\n'")

Expand All @@ -56,35 +51,50 @@ def isGaTag(String version, String tag) {
}
}

// Get the latest upstream openjdk build tag
def getLatestOpenjdkBuildTag(String version) {
def openjdkRepo = "https://github.com/openjdk/${version}.git"
if (version == "aarch32-jdk8u") {
// Determine the upstream OpenJDK reporistory
def getUpstreamRepo(String version) {
def openjdkRepo

def versionInt = (version == "aarch32-jdk8u" || version == "alpine-jdk8u") ? 8 : version.replaceAll("[a-z]","").toInteger()
def isUpdateVersion = version.endsWith("u")

if (versionInt >= 23 && !isUpdateVersion) {
// jdk-23+ stabalisation versions are now branches in jdk(head) repo
openjdkRepo = "https://github.com/openjdk/jdk.git"
} else if (version == "aarch32-jdk8u") {
openjdkRepo = "https://github.com/openjdk/aarch32-port-jdk8u.git"
} else if (version == "alpine-jdk8u") {
} else if (version.contains("jdk8u")) {
openjdkRepo = "https://github.com/openjdk/jdk8u.git"
} else {
openjdkRepo = "https://github.com/openjdk/${version}.git"
}

// Need to include jdk8u to avoid picking up old tag format
def jdk8Filter = (version.contains("jdk8u")) ? "| grep 'jdk8u'" : ""
return openjdkRepo
}

// Get the latest upstream openjdk build tag
def getLatestOpenjdkBuildTag(String version) {
def openjdkRepo = getUpstreamRepo(version)
def versionInt = (version == "aarch32-jdk8u" || version == "alpine-jdk8u") ? 8 : version.replaceAll("[a-z]","").toInteger()

def tagFilter
if (version == "aarch32-jdk8u") {
jdk8Filter += " | grep '\\-aarch32\\-'"
tagFilter = "| grep 'jdk8u.*-aarch32-'"
} else if (version.contains("jdk8u")) {
tagFilter = "| grep 'jdk8u'"
} else {
tagFilter = "| grep 'jdk-"+versionInt+"[\\.\\+]'"
}

def latestTag = sh(returnStdout: true, script:"git ls-remote --sort=-v:refname --tags ${openjdkRepo} | grep -v '\\^{}' | tr -s '\\t ' ' ' | cut -d' ' -f2 | sed \"s,refs/tags/,,\" | grep -v '\\-ga' ${jdk8Filter} | sort -V -r | head -1 | tr -d '\\n'")
def latestTag = sh(returnStdout: true, script:"git ls-remote --sort=-v:refname --tags ${openjdkRepo} | grep -v '\\^{}' | tr -s '\\t ' ' ' | cut -d' ' -f2 | sed \"s,refs/tags/,,\" | grep -v '\\-ga' ${tagFilter} | sort -V -r | head -1 | tr -d '\\n'")
echo "latest upstream openjdk/${version} tag = ${latestTag}"

return latestTag
}

// Get how long ago the given upstream tag was published?
def getOpenjdkBuildTagAge(String version, String tag) {
def openjdkRepo = "https://github.com/openjdk/${version}.git"
if (version == "aarch32-jdk8u") {
openjdkRepo = "https://github.com/openjdk/aarch32-port-jdk8u.git"
} else if (version == "alpine-jdk8u") {
openjdkRepo = "https://github.com/openjdk/jdk8u.git"
}
def openjdkRepo = getUpstreamRepo(version)

def date = sh(returnStdout: true, script:"(rm -rf tmpRepo; git clone ${openjdkRepo} tmpRepo; cd tmpRepo; git for-each-ref --format=\"%(refname:short) %(creatordate:format:%Y-%m-%dT%H:%M:%S%z)\" \"refs/tags/*\"; cd ..; rm -rf tmpRepo) | grep \"${tag}\" | cut -d\" \" -f2 | sed -e 's/.\\{22\\}/&:/1' | tr -d '\\n'")

Expand All @@ -109,7 +119,7 @@ def getLatestBinariesTag(String version) {
def getInProgressBuildUrl(String trssUrl, String variant, String featureRelease, String publishName, String scmRef) {
def inProgressBuildUrl = ""

def featureReleaseInt = (featureRelease == "aarch32-jdk8u" || featureRelease == "alpine-jdk8u") ? 8 : featureRelease.replaceAll("u", "").replaceAll("jdk", "").toInteger()
def featureReleaseInt = (featureRelease == "aarch32-jdk8u" || featureRelease == "alpine-jdk8u") ? 8 : featureRelease.replaceAll("[a-z]","").toInteger()
def pipelineName = "openjdk${featureReleaseInt}-pipeline"

def pipeline = sh(returnStdout: true, script: "wget -q -O - ${trssUrl}/api/getBuildHistory?buildName=${pipelineName}")
Expand Down Expand Up @@ -153,6 +163,7 @@ def getInProgressBuildUrl(String trssUrl, String variant, String featureRelease,
def verifyReleaseContent(String version, String release, String variant, Map status) {
echo "Verifying ${version} assets in release: ${release}"
status['assets'] = "Error"
status['missingAssets'] = []

def configVersion = version
// aarch32-jdk8u and alpine-jdk8u use "jdk8u" config
Expand All @@ -161,7 +172,7 @@ def verifyReleaseContent(String version, String release, String variant, Map sta
}

def escRelease = release.replaceAll("\\+", "%2B")
def releaseAssetsUrl = "https://api.github.com/repos/${params.BINARIES_REPO}/releases/tags/${escRelease}".replaceAll("_NN_", configVersion.replaceAll("u","").replaceAll("jdk",""))
def releaseAssetsUrl = "https://api.github.com/repos/${params.BINARIES_REPO}/releases/tags/${escRelease}".replaceAll("_NN_", configVersion.replaceAll("[a-z]",""))

// Transform to browser URL for use in Slack message link
status['assetsUrl'] = releaseAssetsUrl.replaceAll("api.github.com","github.com").replaceAll("/repos/","/").replaceAll("/tags/","/")
Expand Down Expand Up @@ -346,7 +357,7 @@ node('worker') {
allNonTipReleases.addAll(nonTagBuildReleases)
}
allNonTipReleases.each { featureRelease ->
def featureReleaseInt = (featureRelease == "aarch32-jdk8u" || featureRelease == "alpine-jdk8u") ? 8 : featureRelease.replaceAll("u", "").replaceAll("jdk", "").toInteger()
def featureReleaseInt = (featureRelease == "aarch32-jdk8u" || featureRelease == "alpine-jdk8u") ? 8 : featureRelease.replaceAll("[a-z]","").toInteger()

// Extra filter to find latest jdk8u port assets
def extraFilter = ""
Expand Down Expand Up @@ -391,8 +402,8 @@ node('worker') {

// Check tip_release status, by querying binaries repo as API does not server the "tip" dev release
if (tipRelease != "") {
def latestOpenjdkBuild = getLatestOpenjdkBuildTag("jdk")
def tipVersion = tipRelease.replaceAll("u", "").replaceAll("jdk", "").toInteger()
def latestOpenjdkBuild = getLatestOpenjdkBuildTag(tipRelease)
def tipVersion = tipRelease.replaceAll("[a-z]","").toInteger()
def releaseName = getLatestBinariesTag("${tipVersion}")
status = [releaseName: releaseName, expectedReleaseName: "${latestOpenjdkBuild}-ea-beta", upstreamTag: latestOpenjdkBuild]
verifyReleaseContent(tipRelease, releaseName, variant, status)
Expand Down Expand Up @@ -426,7 +437,7 @@ node('worker') {
allReleases.addAll(nonTagBuildReleases)
}
allReleases.each { release ->
def featureReleaseStr = (release == "aarch32-jdk8u" || release == "alpine-jdk8u") ? "8" : release.replaceAll("u", "").replaceAll("jdk", "")
def featureReleaseStr = (release == "aarch32-jdk8u" || release == "alpine-jdk8u") ? "8" : release.replaceAll("[a-z]","")

// Only interested in triggered openjdkNN-pipeline's
if (!pipelinesOfInterest.contains(",openjdk${featureReleaseStr}-pipeline")) {
Expand Down Expand Up @@ -658,8 +669,7 @@ node('worker') {

// Check latest published binaries are for the latest openjdk build tag, unless upstream is a GA tag
if (status['releaseName'] != status['expectedReleaseName'] && !isGaTag(featureRelease, status['upstreamTag'])) {
def upstreamRepoVersion = (featureRelease == tipRelease) ? "jdk" : featureRelease
def upstreamTagAge = getOpenjdkBuildTagAge(upstreamRepoVersion, status['upstreamTag'])
def upstreamTagAge = getOpenjdkBuildTagAge(featureRelease, status['upstreamTag'])
if (upstreamTagAge > 3 && inProgressBuildUrl == "") {
slackColor = 'danger'
health = "Unhealthy"
Expand Down

0 comments on commit f0af2f2

Please sign in to comment.