Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add generic Jenkins files pipelines #2093

Merged
merged 1 commit into from
Jun 14, 2018

Conversation

vsebe
Copy link
Contributor

@vsebe vsebe commented Jun 6, 2018

  • add Jenkins file for build and test any platform
  • add pipeline wrapper for any platform
    These Jenkins files allow the OpenJ9 extensions build and test for any
    supported version and platform. New platforms can be added easily
    without creating new Jenkins files only parameterized Jenkins jobs.
    Pipeline-Build-Test-Any-Platform could also replace the all of the
    Pipeline-Build-Test-JDK<version>-<platform> wrappers.
    Build-Test-Any-Platform could replace all of the
    Build-JDK<version>-<platform>, Test-Sanity-JDK<version>-<platform>, Test-Extended-JDK<version>-<platform> and PullRequest-*-JDK<version>-<platform> scripts.

Fixes #1897

[ci skip]

Signed-off-by: Violeta Sebe vsebe@ca.ibm.com

@vsebe vsebe changed the title Add generic Jenkins file for Windows 32bits pipelines WIP: Add generic Jenkins file for Windows 32bits pipelines Jun 6, 2018
@vsebe vsebe changed the title WIP: Add generic Jenkins file for Windows 32bits pipelines WIP: Add generic Jenkins files pipelines Jun 6, 2018
@vsebe
Copy link
Contributor Author

vsebe commented Jun 6, 2018

@AdamBrousseau please review

@vsebe vsebe changed the title WIP: Add generic Jenkins files pipelines Add generic Jenkins files pipelines Jun 6, 2018
// check mandatory parameters if any
try {
validate_arguments(ARGS)
} catch(MissingPropertyException e){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this catch only when ARGS is not defined, or will it also catch the perror(s) we may throw inside the validate_arguments function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only when ARGS is not defined

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AdamBrousseau - ready for review, thx


def check_parameter(ARG_NAME) {
if (!params.get(ARG_NAME)) {
perror(ARG_NAME)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of moving the error out to a new function if we only use it in one place?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simplicity


def validate_arguments(ARGS) {
for (arg in ARGS) {
check_parameter(arg)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment, what is the purpose or value moving this out if we don't use it anywhere else?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simplicity

} else {
if (params.UPSTREAM_JOB_NAME && params.UPSTREAM_JOB_NUMBER) {
// fetch resources from upstream job, run tests, archive results, clean up
testFile.test_all_with_fetch()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not work because JAVA_BIN was set on master when the test file was loaded
https://github.com/eclipse/openj9/pull/2093/files#diff-b19f95b3c3121dd4c7d986c2633a9deaR41

Given #1450 is very close, I think we should not worry about covering both compile and test jobs with this change
We should however, probably still do the PRs in this file, since we haven't ironed out where that story is headed yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a 2nd checkout for the test script

* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/

ARGS = ['SDK_VERSION', 'PLATFORM', 'TESTS_TARGETS']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current pipeline jobs don't use an argument for TEST_TARGETS, they get the default from the variables-function file
https://github.com/eclipse/openj9/blob/master/buildenv/jenkins/common/variables-functions#L267

Is this an intended change in beaviour?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on second thought we can dispense of it

@pshipton
Copy link
Member

pshipton commented Jun 6, 2018

@smlambert fyi

@smlambert
Copy link
Contributor

It will be good to add more details in the commit message about this PR, what it intends to accomplish / what issue it fixes.

By the look of the title, it seems it may help eliminate duplication in Jenkinsfiles in the repo, is that true? If so, is the plan to remove duplicate files in a later PR?

How does this PR relate to the one linked to it #2097, does it replace the need for it?

@AdamBrousseau
Copy link
Contributor

related #2117

@vsebe
Copy link
Contributor Author

vsebe commented Jun 7, 2018

@smlambert - yes to both your question.
It is intended to eliminate the duplicated Jenkins files: Pipeline-Build-Test-JDK*, Build-JDK*, Test-Sanity-JDK*, PullRequest-*, etc.

  • Pipeline-Build-Test-Any-Platform replaces Pipeline-Build-JDK<version>-<spec> files
  • Build-Test-Any-Platform replaces Build-JDK<version>-<spec>, Test-Sanity-JDK<version>-<spec>, Test-Extended-JDK<version>-<spec>, PullRequest-*-JDK<version>-<spec> files.

We'll eliminate the duplicates in another PR.

PR #2097 adds windows 32 bits platform. There are no Jenkins file for win x86, e.g. Pipeline-Build-JDK9-win_x86, TestBuild-Test-JDK9-win_x86, etc.
To build and test OpenJ9 JDK8 on win x86 32bits we'll create parameterized Jenkins jobs that'll use Pipeline-Build-Test-Any-Platform and Build-Test-Any-Platform scripts.

*******************************************************************************/

ARGS = ['SDK_VERSION', 'PLATFORM']

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should also wrap all this in a timeout for protection?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a timeout already set in the upstream pipeline - Pipeline-Build-Test-All

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this will also be used for PR builds which are not triggered by Pipeline-Build-Test-All

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added 10h timeout


variableFile = load 'buildenv/jenkins/common/variables-functions'

if (!params.UPSTREAM_JOB_NAME && !params.UPSTREAM_JOB_NUMBER) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably add a comment here about what this if means.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment added

}

if (arg == 'PLATFORM') {
SPEC = params.get(arg)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably add a comment about why we use SPEC and PLATFORM and the difference between a groovy variable and a Jenkins Param and why SPEC conflicts with a compile.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment added

}

if (run_tests()) {
variableFile.set_job_variables('test')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For PR builds with testing, we will hit set_job_variables('build') then set_job_variables('test') but we should be hitting set_job_variables('pullRequest'). This will technically work as-is because our build/test labels (machines) are currently the same at OpenJ9. But we would essentially be setting up for a build node and then changing to a test node, which is incorrect because we need to compile on a build node. We may need another if here that looks for a param that is passed in a PR build.
https://ci.eclipse.org/openj9/view/Pull%20Requests/job/PullRequest-Sanity-JDK8-win_x86-64_cmprssptrs-OpenJ9/lastSuccessfulBuild/parameters/
ghprbPullId is usually a good one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added check for PR

}

node("${NODE}") {
if (!run_tests()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have a try/finally with cleanWs() here, presumably because both build_all() and test_all() have that functionality. Is it better to move that functionality here and not duplicate them in the build and test files? It might also allow us to remove build_pr() since that function is designed to not cleanup after a PR compile. That way we could have something more like, if compile; build_all; if test; test_all; done

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are 130 Jenkins files still relying on build and test scripts. timeout, timestamps, cleanWs() should be done here but at this point it only duplicates an existing functionality. The refactoring should take place after we replace all the platform specific Jenkins files with Pipeline-Buld-Test-Any-Platform, Buld-Test-Any-Platform scripts.

*******************************************************************************/

ARGS = ['SDK_VERSION', 'PLATFORM']

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timeout wrapper?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a timeout in Pipeline-Build-Test-All

ARGS = ['SDK_VERSION', 'PLATFORM']

node('master') {
timestamps {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should move timestamps outside of node to show queue time

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved

ARGS = ['SDK_VERSION', 'PLATFORM']

node('master') {
timestamps {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move timestamps outside of node

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AdamBrousseau ready for review, thx

@AdamBrousseau
Copy link
Contributor

Looks good now except for my one comment about a timeout in build-test-any

@AdamBrousseau
Copy link
Contributor

adam test sanity

@AdamBrousseau
Copy link
Contributor

adam test sanity depends eclipse/omr#master

1 similar comment
@AdamBrousseau
Copy link
Contributor

adam test sanity depends eclipse/omr#master

Copy link
Contributor

@AdamBrousseau AdamBrousseau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is good to go

@vsebe
Copy link
Contributor Author

vsebe commented Jun 13, 2018

@pshipton please review

@pshipton
Copy link
Member

@smlambert or delegate needs to sign off on this first.

@vsebe
Copy link
Contributor Author

vsebe commented Jun 13, 2018

@smlambert - this does not change the current implementation of the test pipelines.
The pipelines workflow, the way the test pipeline are hooked up, the input for the test pipeline, how tests run remain unchanged.

@AdamBrousseau AdamBrousseau mentioned this pull request Jun 13, 2018
4 tasks
@AdamBrousseau
Copy link
Contributor

One more comment, can you add Fixes #1897 to your commit comment please?

@vsebe
Copy link
Contributor Author

vsebe commented Jun 13, 2018

@AdamBrousseau - added Fixes #1897 to the commit message

// pull request pipeline: compile, run tests, archive results,
// clean up
buildFile.build_pr()
testFile.test_all()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build-Test-Any-Platform could replace all of the Build-Test-JDK<version>-<platform> and PullRequest-*-JDK<version>-<platform> scripts

What is Build-Test-JDK<version>-<platform>? I cannot find it in openj9 repo.
Just a note, once we switch to AdoptOpenJDK test pipeline for nightly, testFile.* will not be used. PullRequest-*-JDK<version>-<platform> will continue running until it is switched.

Copy link
Contributor Author

@vsebe vsebe Jun 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo, should be Build-JDK<version>-<platform> - fixed
The AdoptOpenJDK test pipeline would use other scripts. We'll clean up the if statement in a different PR when we're ready to switch to the new test pipeline.

SPEC = params.get(arg)
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Why we set ARGS array and get params based on the array? Could we just directly use parameters? i.e.,
       if( params.PLATFORM ) {
		SPEC = params.PLATFORM
	} else {
		// error
	}
  • Do we get SDK_VERSION value somewhere?

Copy link
Contributor Author

@vsebe vsebe Jun 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

params could contains mandatory and optional parameters. This checks only for mandatory parameters.
Yes, the SDK_VERSION is a mandatory parameter for the Jenkins job. An error is thrown if it isn't set.

- add Jenkins file for build and test any platform
- add pipeline wrapper for any platform
These Jenkins files allow the OpenJ9 extensions build and test for any
supported version and platform. New platforms can be added easily
without creating new Jenkins files only parameterized Jenkins jobs.
Pipeline-Build-Test-Any-Platform could also replace the all of the
Pipeline-Build-Test-JDK<version>-<platform> wrappers.
Build-Test-Any-Platform could replace all of the
Build-JDK<version>-<platform>, Test-Sanity-JDK<version>-<platform>,
Test-Extended-JDK<version>-<platform> and
PullRequest-*-JDK<version>-<platform> scripts.

Fixes eclipse-openj9#1897

[ci skip]

Signed-off-by: Violeta Sebe <vsebe@ca.ibm.com>
@vsebe
Copy link
Contributor Author

vsebe commented Jun 14, 2018

@pshipton please review

@smlambert smlambert merged commit 7e5a97b into eclipse-openj9:master Jun 14, 2018
@vsebe vsebe deleted the openj9.jenkins branch May 8, 2019 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants