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

Minimal node.js version upgrade #2558

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

timja
Copy link
Member

@timja timja commented Apr 12, 2024

Description

Replaces #2557

Previously it was not possible to build directly on MacOS, for three reasons:

  1. For arm64 Mac there was not arm64 versions of Node.JS for the version in use
  2. For arm64 Mac there is no arm64 version of node-sass
  3. If you got around that or used an amd64 mac then you hit an issue that you couldn't build native dependencies e.g. node-sass as each version of node-sass only works for specific versions of MacOS and specific Node.JS versions.

The first issue with the upgrade was "ReferenceError: primordials is not defined".
https://stackoverflow.com/questions/55921442/how-to-fix-referenceerror-primordials-is-not-defined-in-node-js shows that this is an issue with old versions of gulp.

I tried upgrading gulp in #2557, blueocean itself was fine but this project also uses the abandoned https://github.com/jenkinsci/js-builder/, I found the upgrade there non-trivial / non-obvious and I looked to see if there was another approach as a stepping stone.

The stackoverflow link gives a workaround using overrides to just upgrade graceful-fs, that gets past the gulp errors.

After that there's issues with jest not working on a new Node.JS version without a version conflict.

I initially tried upgrading jest to the latest but that requires a babel upgrade as well. I went down a long rabbit hole in #2557 trying to do the babel upgrade but that also required changes in js-builder and after making changes there I got weird errors that I didn't manage to figure out.

I found that jest 23 was the latest version that worked with all our dependencies (although other references do say 24 should be able to work I wasn't able to find a dependency set that would work together).

Future work needed

These dependencies all need upgrade work done on them to be able to update dependencies to latest

  • gulp
  • storybook
  • babel
  • jest

Submitter checklist

  • Link to JIRA ticket in description, if appropriate.
  • Change is code complete and matches issue description
  • Appropriate unit or acceptance tests or explanation to why this change has no tests
  • Reviewer's manual test instructions provided in PR description. See Reviewer's first task below.

Reviewer checklist

  • Run the changes and verified the change matches the issue description
  • Reviewed the code
  • Verified that the appropriate tests have been written or valid explanation given

@dwnusbaum
Copy link
Member

Nice work! I checked and with this PR everything builds for me fine as well on an M1 Mac.

@olamy
Copy link
Member

olamy commented Apr 13, 2024

Thanks for your work.
The build is failing for me on both linux and osx but it doesn't look to be an operating system issue.
It's passing on ci.jenkins.io because the build is using the parameter -Dmaven.test.failure.ignore without this parameter it would fail (not sure about the reason of the usage of this parameter for ci.jenkins,io but it would be nice to disable this for this build)

[INFO] --- frontend:1.15.0:npm (npm mvntest) @ blueocean-core-js ---
[INFO] Running 'npm run mvntest' in /home/olamy/dev/sources/jenkins/blueocean-plugin/blueocean-core-js
[INFO] 
[INFO] > @jenkins-cd/blueocean-core-js@1.10.4 mvntest
[INFO] > gulp test
[INFO] 
[INFO] [12:45:57] Test specs: src/test/js/**/*-spec.{js,jsx} (use --testFileSuffix switch to select different files)
[INFO] [12:45:57] Changing default language level to ECMA v6. Found "babel-preset-es2015" dependency in package.json.
[INFO] [12:45:57] Language level set to ECMA v6. Call builder.lang([number]) to change.
[INFO] [12:45:57] **********************************************************************
[INFO] [12:45:57] This build is using Jenkins JS Builder.
[INFO] [12:45:57]   For command line options and other help, go to
[INFO] [12:45:57]   https://www.npmjs.com/package/@jenkins-cd/js-builder
[INFO] [12:45:57] **********************************************************************
[INFO] [12:45:57] Maven project.
[INFO] [12:45:57] 	- Jenkins plugin (HPI): blueocean-core-js
[INFO] [12:45:57] Defining default tasks: lint,test,bundle
[INFO] [12:45:57] Not create Jenkins adjunct based external module bundle for package "@jenkins-cd/design-language@any". Is using a non-specific version name.
[INFO] [12:45:57] Not create Jenkins adjunct based external module bundle for package "moment@any". Is using a non-specific version name.
[INFO] [12:45:57] Not create Jenkins adjunct based external module bundle for package "moment-duration-format@any". Is using a non-specific version name.
[INFO] [12:45:57] Not create Jenkins adjunct based external module bundle for package "react@any". Is using a non-specific version name.
[INFO] [12:45:57] Not create Jenkins adjunct based external module bundle for package "react-dom@any". Is using a non-specific version name.
[INFO] [12:45:57] Not create Jenkins adjunct based external module bundle for package "react-router@any". Is using a non-specific version name.
[INFO] [12:45:57] Running Jenkins js-builder plugin: @jenkins-cd/js-builder-jest
[INFO] [12:45:57] Running Jenkins js-builder plugin: @jenkins-cd/js-extensions
[INFO] [12:45:57] Bundle of 'target/tstemp/js/index.js' will be generated in directory 'target/classes/io/jenkins/blueocean' as 'blueocean-core-js.js'.
[INFO] [12:45:57] Not create Jenkins adjunct based external module bundle for package "react@any". Is using a non-specific version name.
[INFO] [12:45:57] Not create Jenkins adjunct based external module bundle for package "react-dom@any". Is using a non-specific version name.
[INFO] [12:45:57] Not create Jenkins adjunct based external module bundle for package "react-router@any". Is using a non-specific version name.
[INFO] [12:45:57] Using gulpfile ~/dev/sources/jenkins/blueocean-plugin/blueocean-core-js/gulpfile.js
[INFO] (node:1774776) Warning: Accessing non-existent property 'cat' of module exports inside circular dependency
[INFO] (Use `node --trace-warnings ...` to show where the warning was created)
[INFO] (node:1774776) Warning: Accessing non-existent property 'cd' of module exports inside circular dependency
[INFO] (node:1774776) Warning: Accessing non-existent property 'chmod' of module exports inside circular dependency
[INFO] (node:1774776) Warning: Accessing non-existent property 'cp' of module exports inside circular dependency
[INFO] (node:1774776) Warning: Accessing non-existent property 'dirs' of module exports inside circular dependency
[INFO] (node:1774776) Warning: Accessing non-existent property 'pushd' of module exports inside circular dependency
[INFO] (node:1774776) Warning: Accessing non-existent property 'popd' of module exports inside circular dependency
[INFO] (node:1774776) Warning: Accessing non-existent property 'echo' of module exports inside circular dependency
[INFO] (node:1774776) Warning: Accessing non-existent property 'tempdir' of module exports inside circular dependency
[INFO] (node:1774776) Warning: Accessing non-existent property 'pwd' of module exports inside circular dependency
[INFO] (node:1774776) Warning: Accessing non-existent property 'exec' of module exports inside circular dependency
[INFO] (node:1774776) Warning: Accessing non-existent property 'ls' of module exports inside circular dependency
[INFO] (node:1774776) Warning: Accessing non-existent property 'find' of module exports inside circular dependency
[INFO] (node:1774776) Warning: Accessing non-existent property 'grep' of module exports inside circular dependency
[INFO] (node:1774776) Warning: Accessing non-existent property 'head' of module exports inside circular dependency
[INFO] (node:1774776) Warning: Accessing non-existent property 'ln' of module exports inside circular dependency
[INFO] (node:1774776) Warning: Accessing non-existent property 'mkdir' of module exports inside circular dependency
[INFO] (node:1774776) Warning: Accessing non-existent property 'rm' of module exports inside circular dependency
[INFO] (node:1774776) Warning: Accessing non-existent property 'mv' of module exports inside circular dependency
[INFO] (node:1774776) Warning: Accessing non-existent property 'sed' of module exports inside circular dependency
[INFO] (node:1774776) Warning: Accessing non-existent property 'set' of module exports inside circular dependency
[INFO] (node:1774776) Warning: Accessing non-existent property 'sort' of module exports inside circular dependency
[INFO] (node:1774776) Warning: Accessing non-existent property 'tail' of module exports inside circular dependency
[INFO] (node:1774776) Warning: Accessing non-existent property 'test' of module exports inside circular dependency
[INFO] (node:1774776) Warning: Accessing non-existent property 'to' of module exports inside circular dependency
[INFO] (node:1774776) Warning: Accessing non-existent property 'toEnd' of module exports inside circular dependency
[INFO] (node:1774776) Warning: Accessing non-existent property 'touch' of module exports inside circular dependency
[INFO] (node:1774776) Warning: Accessing non-existent property 'uniq' of module exports inside circular dependency
[INFO] (node:1774776) Warning: Accessing non-existent property 'which' of module exports inside circular dependency
[INFO] [12:45:57] Starting 'log-env'...
[INFO] [12:45:57] Source Dirs:
[INFO] [12:45:57]  - src: target/tstemp,less
[INFO] [12:45:57]  - test: src/test/js
[INFO] [12:45:57] Finished 'log-env' after 138 μs
[INFO] [12:45:57] Starting 'copy-src'...
[INFO] [12:45:57] Finished 'copy-src' after 40 ms
[INFO] [12:45:57] Starting 'compile-typescript-bundle'...
[INFO] [12:45:58] Finished 'compile-typescript-bundle' after 787 ms
[INFO] [12:45:58] Starting 'js_bundle_blueocean-core-js_bundle_1'...
[INFO] [12:45:58] Ignoring require mapping of "react@any" to "react:react@any". The bundle already has a mapping for "react@any".
[INFO] [12:45:58] Ignoring require mapping of "react-dom@any" to "react-dom:react-dom@any". The bundle already has a mapping for "react-dom@any".
[INFO] [12:45:58] Ignoring require mapping of "react-router@any" to "react-router:react-router@any". The bundle already has a mapping for "react-router@any".
[INFO] [12:45:58] LESS CSS pre-processing completed to 'target/classes/io/jenkins/blueocean'.
[INFO] [12:45:58] using browserify config = 
[INFO] {
[INFO]   "entries": [
[INFO]     "./target/js-bundle-src/_js_wrapper-index.js"
[INFO]   ],
[INFO]   "extensions": [
[INFO]     ".js",
[INFO]     ".es6",
[INFO]     ".jsx",
[INFO]     ".hbs"
[INFO]   ],
[INFO]   "cache": {},
[INFO]   "packageCache": {},
[INFO]   "fullPaths": true
[INFO] }
[INFO] [12:45:58] Will use babel config from .babelrc
[INFO] [12:46:01] Finished 'js_bundle_blueocean-core-js_bundle_1' after 3.32 s
[INFO] [12:46:01] Starting 'bundle'...
[INFO] [12:46:01] bundling: done
[INFO] [12:46:01] Finished 'bundle' after 71 μs
[INFO] [12:46:01] Starting 'test'...
[INFO] [12:46:01] running js-builder-jest:test
[INFO] [12:46:01] collectCoverageFrom: target/tstemp/**/*.{js,jsx}, less/**/*.{js,jsx}
[INFO] [12:46:01] cleaning coverage and reports
[INFO] [12:46:01] using jest CLI options = 
[INFO] {}
[INFO] [12:46:01] using jest config = 
[INFO] {
[INFO] 	"collectCoverage": true,
[INFO] 	"collectCoverageFrom": [
[INFO] 		"target/tstemp/**/*.{js,jsx}",
[INFO] 		"less/**/*.{js,jsx}"
[INFO] 	],
[INFO] 	"coverageDirectory": "target/jest-coverage",
[INFO] 	"testMatch": [
[INFO] 		"**/?(*-)(spec|test).js?(x)"
[INFO] 	],
[INFO] 	"testResultsProcessor": "jest-junit",
[INFO] 	"transform": {
[INFO] 		"^.+\\.tsx?$": "<rootDir>/node_modules/ts-jest/preprocessor.js",
[INFO] 		"^.+\\.jsx?$": "babel-jest"
[INFO] 	},
[INFO] 	"moduleFileExtensions": [
[INFO] 		"ts",
[INFO] 		"tsx",
[INFO] 		"js",
[INFO] 		"jsx",
[INFO] 		"json",
[INFO] 		"node"
[INFO] 	]
[INFO] }
[INFO] jest-haste-map: duplicate manual mock found: i18n
[INFO]   The following files share their name; please delete one of them:
[INFO]     * <rootDir>/src/js/i18n/__mocks__/i18n.js
[INFO]     * <rootDir>/target/tstemp/js/i18n/__mocks__/i18n.js
[INFO] 
[INFO] No tests found, exiting with code 1
[INFO] Run with `--passWithNoTests` to exit with code 0
[INFO] In /home/olamy/dev/sources/jenkins/blueocean-plugin/blueocean-core-js
[INFO]   358 files checked.
[INFO]   testMatch: **/__tests__/**/*.[jt]s?(x), **/?(*.)+(spec|test).[tj]s?(x) - 0 matches
[INFO]   testPathIgnorePatterns: /node_modules/ - 358 matches
[INFO]   testRegex:  - 0 matches
[INFO] Pattern:  - 0 matches
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Blue Ocean Parent 1.27.13-SNAPSHOT:
[INFO] 
[INFO] Blue Ocean Parent .................................. SUCCESS [  1.613 s]
[INFO] Jenkins Design Language ............................ SUCCESS [ 33.270 s]
[INFO] Blue Ocean Core JS ................................. FAILURE [01:09 min]
[INFO] Common API for Blue Ocean .......................... SKIPPED
[INFO] REST API for Blue Ocean ............................ SKIPPED
[INFO] i18n for Blue Ocean ................................ SKIPPED
[INFO] Web for Blue Ocean ................................. SKIPPED
[INFO] Pipeline SCM API for Blue Ocean .................... SKIPPED
[INFO] JWT for Blue Ocean ................................. SKIPPED
[INFO] REST Implementation for Blue Ocean ................. SKIPPED
[INFO] Pipeline implementation for Blue Ocean ............. SKIPPED
[INFO] Events API for Blue Ocean .......................... SKIPPED
[INFO] Dashboard for Blue Ocean ........................... SKIPPED
[INFO] Personalization for Blue Ocean ..................... SKIPPED
[INFO] Config API for Blue Ocean .......................... SKIPPED
[INFO] GitHub Pipeline for Blue Ocean ..................... SKIPPED
[INFO] Git Pipeline for Blue Ocean ........................ SKIPPED
[INFO] Bitbucket Pipeline for Blue Ocean .................. SKIPPED
[INFO] Blue Ocean Pipeline Editor ......................... SKIPPED
[INFO] DEPRECATED Blue Ocean Executor Info ................ SKIPPED
[INFO] Blue Ocean ......................................... SKIPPED
[INFO] JIRA Integration for Blue Ocean .................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:44 min
[INFO] Finished at: 2024-04-13T12:46:01+10:00
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "outside" could not be activated because it does not exist.
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.15.0:npm (npm mvntest) on project blueocean-core-js: Failed to run task: 'npm run mvntest' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :blueocean-core-js

@olamy
Copy link
Member

olamy commented Apr 13, 2024

using such patch turns into a lot more problems....

olamy@pop-os:~/dev/sources/jenkins/blueocean-plugin$ git diff
diff --git a/blueocean-core-js/package.json b/blueocean-core-js/package.json
index 91f432d0d..e5baa4bb3 100644
--- a/blueocean-core-js/package.json
+++ b/blueocean-core-js/package.json
@@ -116,10 +116,7 @@
     ]
   },
   "jest": {
-    "transform": {
-      "^.+\\.tsx?$": "<rootDir>/node_modules/ts-jest/preprocessor.js",
-      "^.+\\.jsx?$": "babel-jest"
-    },
+    "testMatch" : ["**/test/js/**/**-spec.js"],
     "moduleFileExtensions": [
       "ts",
       "tsx",

Does BlueOcean really worth such time investment? It's deprecated and just under very low maintenance.
To be honest not sure we should waste too much time.

@olamy
Copy link
Member

olamy commented Apr 13, 2024

I'm not sure where is it but @basil have tested and build master using the Dockefile.build.
So maybe it's a solution for osx users. (but there are not so many people building BlueOcean these days)

@timja
Copy link
Member Author

timja commented Apr 13, 2024

I'm not sure where is it but @basil have tested and build master using the Dockefile.build. So maybe it's a solution for osx users. (but there are not so many people building BlueOcean these days)

the project should build out of the box without having to use an old frozen build environment.
This shouldn't be hard to fix, I ran the tests in some of the projects when testing this but not all.

@@ -72,7 +72,7 @@ node() {
sh 'id'
//sh 'whoami'
sh 'pwd'
sh "mvn clean install -T2 -Pci -V -B -DcleanNode -ntp -DforkCount=3 -Dmaven.test.failure.ignore -s settings.xml -e -Dmaven.repo.local=/tmp/m2 -Dmaven.artifact.threads=30"
sh "mvn clean install -T2 -Pci -V -B -DcleanNode -ntp -DforkCount=3 -s settings.xml -e -Dmaven.repo.local=/tmp/m2 -Dmaven.artifact.threads=30"
Copy link
Member

@olamy olamy Apr 13, 2024

Choose a reason for hiding this comment

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

this will not change anything for ci.jenkins.io :) You have to change the provided script by ci.j.io.
look at the start of the file

if (JENKINS_URL == 'https://ci.jenkins.io/') {

this Jenkinsfile was only by the dead ci.blueocean.io

(the testMatch changes allow running from jest-cli quicker and easier to
work with than gulp
@timja
Copy link
Member Author

timja commented Apr 14, 2024

I'll spend a bit more time on it but yeah pretty painful to update =/.

@huyun3
Copy link

huyun3 commented May 15, 2024

I am a new user of blueocean, and I pushed the following error when building mvn clean install-DskipTests using 1.27.5.1: [ERROR] Failed to execute goal org.jenkins-ci.tools:maven-hpi-plugin:3.46:run (default-cli) on project blueocean: Unable to parse configuration of mojo org.jenkins-ci.tools:maven-hpi-plugin:3.46:run for parameter webApp: Cannot load implementation hint 'org.eclipse.jetty.maven.plugin.JettyWebAppContext' -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginConfigurationException

How do I fix it?

@timja
Copy link
Member Author

timja commented May 15, 2024

not sure exactly what you are doing, but if you see the change to blueocean/pom.xml in this PR that fixes the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants