issue while running git Actions Job related to chrome driver version - node.js

package.json dependencies :
"engines": {
"npm": "6.14.17",
"node": "14.20.0"
},
"devDependencies": {
"#babel/cli": "^7.20.7",
"#babel/core": "^7.20.12",
"#babel/preset-env": "^7.9.0",
"#babel/register": "^7.9.0",
"#rpii/wdio-html-reporter": "^1.0.3",
"#wdio/cli": "^6.12.1",
"#wdio/devtools-service": "^6.12.1",
"#wdio/jasmine-framework": "^6.11.0",
"#wdio/local-runner": "^6.12.1",
"#wdio/mocha-framework": "^6.11.0",
"#wdio/selenium-standalone-service": "^6.12.1",
"#wdio/spec-reporter": "^6.11.0",
"#wdio/sync": "^6.11.0",
"chromedriver": "^110.0.0",
"edgedriver": "^4.17134.1",
"eslint": "^6.8.0",
"eslint-plugin-wdio": "^6.6.0",
"expect-webdriverio": "^1.4.1",
"geckodriver": "^3.2.0",
"moment": "^2.29.4",
"wdio-chromedriver-service": "^8.1.1",
"wdio-html-reporter": "^1.0.2",
"wdio-timeline-reporter": "^5.1.4",
"webdriverio": "^6.12.1"
},
my workflow file :
jobs:
test:
name: BUILD & TEST
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
steps:
- uses: actions/checkout#v3
- uses: actions/setup-node#v3
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: npm install
- name: Run MWPL tests on staging environment
run: ENV=staging HEADLESS=true npx wdio run wdio.conf.js --spec e2eScenario.spec.js
error :
[0-0] RUNNING in chrome - /test/e2eScenario.spec.js
[0-0] 2023-02-16T10:02:37.840Z ERROR webdriver: Request failed with status 500 due to session not created: session not created: This version of ChromeDriver only supports Chrome version 110
Current browser version is 109.0.5414.119 with binary path /usr/bin/google-chrome
Logs of npm installing 110 chrome :
> chromedriver#110.0.0 install /home/runner/work/PlateRate-Tester/PlateRate-Tester/node_modules/chromedriver
> node install.js
Current existing ChromeDriver binary is unavailable, proceeding with download and extraction.
Downloading from file: https://chromedriver.storage.googleapis.com/110.0.5481.77/chromedriver_linux64.zip
Saving to file: /tmp/110.0.5481.77/chromedriver/chromedriver_linux64.zip
Received 1040K...
Received 2080K...
Received 3120K...
Received 4160K...
Received 5200K...
Received 6240K...
Received 7223K total.
Extracting zip contents to /tmp/110.0.5481.77/chromedriver.
Copying from /tmp/110.0.5481.77/chromedriver to target path /home/runner/work/PlateRate-Tester/PlateRate-Tester/node_modules/chromedriver/lib/chromedriver
Fixing file permissions.
Done. ChromeDriver binary available at /home/runner/work/PlateRate-Tester/PlateRate-Tester/node_modules/chromedriver/lib/chromedriver/chromedriver
on my local machine it works fine, but sounds like while executing the job the chrome version mentioned in package.json is not taken in considiration.
so why it says current browser version is 109 while in dependencies i have 110,
in logs clearly it installs 110 .

The preinstalled versions of Google Chrome browser and ChromeDriver are 109.0.5414.119 and 109.0.5414.74 respectively.
Seems like npm install is updating the ChromeDriver version only and the browser version is still 109. You need to update it accordingly or configure your CI to use the preinstalled versions.
This action might be helpful in this regard:
https://github.com/browser-actions/setup-chrome
Alternatively, you can use a docker container e.g. selenium/standalone-chrome:110.0.

Related

GitHub Actions only /tmp/unit-tests-2f311f40.sh: 1: jest: not found

I have a pipeline in GitHub Actions and it is suggesting that it cannot find Jest despite it working locally.
If I run npm run unit-tests locally it works fine, but in the CI I get the following error:
> jest --group=unit --coverage --verbose
/tmp/unit-tests-2f311f40.sh: 1: jest: not found
name: staging-pipeline
on:
push:
tags:
- 'v*-staging'
env:
CI: true
NODE_ENV: production
jobs:
unit-test:
name: unit-test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout#master
- name: Unit Tests
run: |
npm install
npm run unit-tests
{
"name": "app",
"version": "1.0.0",
"description": "app",
"main": "",
"scripts": {
"ts-node": "ts-node",
"test": "jest",
"unit-tests": "jest --group=unit --coverage --verbose",
"prisma-generate": "npx prisma generate && npm install #prisma/client"
},
"dependencies": {
"#prisma/client": "^4.3.1",
"axios": "^0.27.2",
"axios-retry": "^3.3.1",
"dotenv": "^16.0.2",
"mongodb": "^4.9.1",
"qs": "^6.11.0",
"winston": "^3.8.1",
"zod": "^3.18.0"
},
"devDependencies": {
"#types/aws-lambda": "^8.10.102",
"#types/jest": "^29.0.0",
"#types/node": "^18.7.15",
"#types/qs": "^6.9.7",
"#typescript-eslint/eslint-plugin": "^5.36.1",
"#typescript-eslint/parser": "^5.36.1",
"esbuild": "^0.15.7",
"eslint": "^8.23.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"jest": "^28.1.3",
"jest-mock-extended": "^2.0.7",
"jest-runner-groups": "^2.2.0",
"json-schema-to-ts": "^2.5.5",
"prettier": "2.7.1",
"prisma": "^4.3.1",
"ts-jest": "^28.0.8",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.1.0",
"typescript": "^4.8.2"
},
"author": "",
"license": "MIT"
}
The reason is you installed jest globally on your local machine so Jest command is available in your local machine but not the case in Github action environment(container), so you have to way to fix it :
1.install jest globally in in Github action environment.
jobs:
unit-test:
name: unit-test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout#master
- name: Unit Tests
run: |
npm install
npm install -g jest
npm run unit-tests
2.or in your package.json file change the npm run unit-test to
./node_modules/.bin/jest --group=unit --coverage --verbos to read
I recommend the second way.
You can see in my CI i have the following variable
NODE_ENV: production
This was causing npm to only install the dependencies and not the devDependencies. equivalant of doing npm install --prod once i removed this env variable, it was able to install jest and use it as normal.

I deployed my project, I am getting this error Input file contains unsupported image format

I am trying to build in my production environment (i using GitHub actions to do the deploy), but the wrong is what the node is not the same between in my local
in my local i have this version:
npm -v
-> 7.24.1
node -v
-> v14.13.1
but I don't know what is the node version on GitHub actions
I can not reproduce the error in my local, because the version are not the same
I am getting this error:
success extract queries from components - 4.464s
success write out redirect data - 0.001s
success Build manifest and related icons - 0.003s
error "gatsby-plugin-manifest" threw an error while running the onPostBootstrap lifecycle:
Input file contains unsupported image format
Error:Input file contains unsupported image format
not finished onPostBootstrap - 0.025s
npm ERR! code ELIFECYCLE
and these are my dependencies:
{
"dependencies": {
"#material-ui/core": "4.11.0",
"#material-ui/icons": "4.9.1",
"#material-ui/lab": "4.0.0-alpha.56",
"#material-ui/styles": "4.11.4",
"axios": "^0.21.0",
"file-saver": "^2.0.5",
"firebase": "^7.15.4",
"gatsby": "^2.22.15",
"gatsby-cli": "^2.12.87",
"gatsby-image": "^2.4.5",
"gatsby-plugin-manifest": "^2.4.9",
"gatsby-plugin-material-ui": "3.0.0",
"gatsby-plugin-react-helmet": "^3.3.2",
"gatsby-plugin-react-redux": "1.1.0",
"gatsby-plugin-react-svg": "^3.0.0",
"gatsby-plugin-robots-txt": "^1.6.8",
"gatsby-plugin-sharp": "^2.6.9",
"gatsby-plugin-sitemap": "3.3.0",
"gatsby-source-filesystem": "^2.3.8",
"gatsby-transformer-sharp": "2.5.3",
"material-ui-dropzone": "3.3.0",
"npm": "^7.5.6",
"prop-types": "^15.7.2",
"react": "^16.13.1",
"react-redux": "^7.2.1",
"redux": "^4.0.5",
"redux-mock-store": "^1.5.4",
"stopword": "^1.0.3",
"tracking-number-validation": "^2.0.2",
"uuid": "^8.3.2"
},
}
this is the build.yml to deploy to production
name: Build
on:
push:
branches:
- master
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout#v2
deploy:
name: Deploy
needs: build
runs-on: ubuntu-latest
steps:
- run: echo ${{ github.ref }}
- name: Checkout Repo
uses: actions/checkout#v2
but i dont know what is the node version on github actions i can not reproduce the error in my local, because of the version are not the same
You could use setup-node action to make the version exactly same with your local:
- uses: actions/setup-node#v2
with:
node-version: '14.13.1'
- run: npm install -g npm#7.24.1
- run: npm -v
- run: node -v
The output in github:
Run npm -v
npm -v
shell: /usr/bin/bash -e {0}
7.24.1
Run node -v
node -v
shell: /usr/bin/bash -e {0}
v14.13.1

Serverless Framework not excluding dev dependencies when packaging

Why is my one computer including dev dependencies when packaging a Serverless Framework project but my other computer is not?
When packaging and deploying my Serverless project targeted for AWS, I found that the zip package contained dev dependencies in the node_modules folder. This only happened on one of my two computers. When performing the same build steps on AWS CodeBuild, the package was also ok with not including dev dependencies.
package.json
{
"name": "project-name",
"version": "0.0.1",
"description": "description",
"main": "index.js",
"dependencies": {
"amazon-cognito-identity-js": "^3.0.10",
"aws-sdk": "^2.488.0",
"axios": "^0.18.0",
"js-sha256": "^0.9.0",
"jsonwebtoken": "^8.5.1",
"jwk-to-pem": "^2.0.1",
"node-fetch": "^2.3.0",
"uuid": "^3.3.2",
"lodash": "^4.17.11"
},
"devDependencies": {
"chai": "^4.2.0",
"eslint": "^5.16.0",
"eslint-config-node": "^4.0.0",
"mocha": "^6.0.2",
"serverless": "^1.69.0",
"sinon": "^7.4.2",
"sinon-test": "^2.4.0"
},
"scripts": {
"test": "mocha ./test --recursive"
},
"repository": {
"type": "git",
"url": "https://git-codecommit.us-east-1.amazonaws.com/v1/repos/reponame"
},
"author": "",
"license": "ISC"
}
serverless.yml file that tried packaging but included dev dependencies.
service: service-name
# pinning serverless version for this project so all contributors are using the same version for consisten results
frameworkVersion: ">=1.60.0"
provider:
name: aws
runtime: nodejs10.x
stage: ${opt:stage, 'dev'} # default stage to use, unless overridden on command lin
region: us-east-1
functions:
create:
handler: create/index.create
events:
- http:
path: /{id}
method: post
cors: true
Both computers were windows 10 with the following Node versions
- npm version
6.4.1
- node version
10.15.3
I tried completely uninstalling Node.js from my Windows computer following Uninstall Node.js and reinstalling Node.js but it did not work.
I tried searching for other node_modules folders on my computer and removing them but the project still included the dev dependencies.
I tried building a simple Serverless project but it also included the dev dependencies.
The only solution I found to solve my problem was to perform a reset of windows (keeping user data, only removing application data). There must have been something in the applications, AppData, etc. that caused this issue.
After resetting windows 10 where user data was kept and only application data was removed, installing Node.js (same version as before) and installing Serverless (same version as before), the dev dependencies were no longer included in the node_modules section of the package that was generated.

Bitbucket Pipelines from Docker Image has Missing NPM Modules

Question
What is wrong with my Dockerfile or bitbucket-pipelines.yml? Why are modules missing from the bitbucket pipelines environment?
Error
When I try to npm run build my Vue2 project with webpack using Bitbucket Pipelines, I get errors regarding missing modules.
From Logs
npm run build
> people-is#1.0.0 build /opt/atlassian/pipelines/agent/build
> node build/build.js
module.js:549
throw err;
^
Error: Cannot find module 'cli-spinners'
Files
Here are the files for configuration.
Dockerfile - builds cportwine/people-is
FROM node:8.10.0
RUN npm install
RUN npm install -g firebase-tools
CMD [ "npm", "run", "build" ]
bitbucket-pipelines.yml
image:
name: cportwine/people-is
pipelines:
default:
- step:
script:
- npm run build
package.json
{
"name": "people-is",
"version": "1.0.0",
"description": "A Vue.js project",
"author": "cportwine",
"private": true,
"scripts": {
"dev": "node build/dev-server.js",
"start": "node build/dev-server.js",
"build": "node build/build.js",
"deploy": "firebase deploy --token $FIREBASE_TOKEN"
},
"dependencies": {
"rxjs": "^5.5.8",
"uuid": "^3.2.1",
"vue": "^2.5.16",
"vue-json-excel": "^0.1.9",
"vue-router": "^2.8.1",
"vue-rx": "^5.0.0",
"vuefire": "^1.4.5",
"vuetify": "^0.15.2"
},
"devDependencies": {
"autoprefixer": "^7.2.6",
"babel-core": "^6.22.1",
"babel-loader": "^7.1.4",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-preset-env": "^1.6.1",
"babel-preset-stage-2": "^6.22.0",
"babel-register": "^6.22.0",
"chalk": "^2.3.2",
"connect-history-api-fallback": "^1.5.0",
"copy-webpack-plugin": "^4.5.1",
"css-loader": "^0.28.11",
"cssnano": "^3.10.0",
"eslint": "^4.19.1",
"eslint-config-standard": "^11.0.0",
"eslint-friendly-formatter": "^3.0.0",
"eslint-loader": "^1.9.0",
"eslint-plugin-html": "^4.0.2",
"eslint-plugin-promise": "^3.7.0",
"eslint-plugin-standard": "^3.0.1",
"eventsource-polyfill": "^0.9.6",
"express": "^4.16.3",
"extract-text-webpack-plugin": "^2.0.0",
"file-loader": "^0.11.1",
"firebase": "^4.12.0",
"firebase-tools": "^3.17.7",
"friendly-errors-webpack-plugin": "^1.1.3",
"html-webpack-plugin": "^2.28.0",
"http-proxy-middleware": "^0.17.3",
"opn": "^5.3.0",
"optimize-css-assets-webpack-plugin": "^2.0.0",
"ora": "^1.4.0",
"rimraf": "^2.6.0",
"semver": "^5.5.0",
"shelljs": "^0.7.6",
"url-loader": "^0.5.8",
"vue-loader": "^13.7.1",
"vue-style-loader": "^3.1.2",
"vue-template-compiler": "^2.5.16",
"vuex": "^2.5.0",
"webpack": "^2.6.1",
"webpack-bundle-analyzer": "^2.11.1",
"webpack-dev-middleware": "^1.12.2",
"webpack-hot-middleware": "^2.21.2",
"webpack-merge": "^4.1.2"
},
"engines": {
"node": ">=8.10.0",
"npm": ">= 5.6.0"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
],
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://chaddportwine#bitbucket.org/jahnelgroup/people-is.git"
},
"keywords": [],
"license": "ISC",
"homepage": "https://bitbucket.org/jahnelgroup/people-is#readme"
}
What I see
When I ls the node_modules folder in both environments, they do not match. Modules are missing from bitbucket pipelines.
local folder
people-is/node_modules
...
chalk
char-spinner
chardet
check-types
chokidar
chownr
cipher-base
circular-json
cjson
clap
class-utils
clean-css
cli-boxes
cli-cursor
cli-spinners
cli-table
cli-table2
cli-width
cliui
...
bitbucket folder
/opt/atlassian/pipelines/agent/build/node_modules
Woah, missing modules!
...
chalk
cli-cursor
co
...
What I have tried
I added a command to the bitbucket-pipelines.yml to npm install before I build.
bitbucket-pipelines.yml
image:
name: cportwine/people-is
pipelines:
default:
- step:
script:
- npm install
- npm run build
This adds some additional modules (like cli-spinners from the error) to /opt/atlassian/pipelines/agent/build/node_modules.
bitbucket folder
/opt/atlassian/pipelines/agent/build/node_modules
...
chalk
char-spinner
chardet
check-types
chokidar
chownr
cipher-base
circular-json
cjson
clap
class-utils
clean-css
cli-boxes
cli-cursor
cli-spinners
cli-table
cli-table2
cli-width
cliui
clone
clone-response
co
...
However, the build command still fails, due to a different missing module.
Error
> people-is#1.0.0 build /opt/atlassian/pipelines/agent/build
> node build/build.js
module.js:549
throw err;
^
Error: Cannot find module './_safeGet'
Solutions
I can now build the app, but I don't know why!
1 - Simplify the Dockerfile
I removed all the npm commands. Maybe the npm install commands were redundant? There was no advantage using the Docker Image to pre-install npm packages.
2 - Remove Node_Modules before install
Using the bitbucket-pipelines.yml, remove the node_modules folder, and then perform npm install -g npm and npm install and npm install -g firebase-tools.
File Changes
bitbucket-pipelines.yml (added lines)
image:
name: cportwine/people-is
pipelines:
default:
- step:
script:
- rm -r node_modules <---- remove
- npm install -g npm <---- install
- npm install <---- install
- npm install -g firebase-tools <---- install
- npm run build
Dockerfile (lines removed)
FROM node:8.10.0
<---- remove
CMD [ "npm", "run", "build" ]
Answer ?
I'm not sure why moving all the npm install stuff into the bitbucket.pipelines.yml solved my issue building the project. I thought Docker would enable me to define my environment, e.g., install a version of node/npm and firebase. And pipelines would "run" that.
If someone could explain what I am missing, I would accept that answer.
Answer
I received support from the Atlassian Team
Leave npm install -g firebase in the docker image.
Move npm install from the docker image to the
bitbucket-pipelines.yml file.
Reason
The node_modules folder was listed in .gitignore
tl;dr
My mistake - I forgot about .gitignore and how that affects the node_modules folder in source control, e.g., Bitbucket Pipelines.
I was looking at my local node_modules folder and building locally which worked.
However
The node_modules in source control, by design, is not in-sync with my local folder because it's included in the .gitignore file.
So
It was necessary for me to rm node_modules and npm install using the bitbucket-pipelines.yml. Now, BitPipes finds the modules I have installed locally.
This is sort of the point of maintaining the package.json, but I got confused.

Javascript (Jest) tests on Semaphore CI ruby project

I've had a Ruby on Rails project for several years set up with Semaphore CI. The Semaphore project is set to use Ruby 2.2.2 as it's language. Over time the project adopted npm with browserify and babelify, and we're using all the latest ES6 features. We added npm install as a setup step to our Semaphore build, and this was working fine.
Now we are starting to use Jest to test our javascripts, and this is working fine locally. But when I added npm test to our Semaphore test commands, npm test fails on semaphore CI with the following errors:
FAIL app/assets/javascripts/tests/selectors/conversations.test.js
● Test suite failed to run
SyntaxError: Unexpected token {
at _load_jsdom (node_modules/jest/node_modules/jest-cli/node_modules/jest-environment-jsdom/build/index.js:17:41)
FAIL app/assets/javascripts/tests/reducers/conversations.test.js
● Test suite failed to run
SyntaxError: Unexpected token {
at _load_jsdom (node_modules/jest/node_modules/jest-cli/node_modules/jest-environment-jsdom/build/index.js:17:41)
Test Suites: 2 failed, 2 total
Tests: 0 total
Snapshots: 0 total
Time: 0.65s
Ran all test suites.
npm ERR! Test failed. See above for more details.
This is some relavent information from the project's package.json:
"scripts": {
"test": "jest --debug --verbose"
},
"jest": {
"roots": [
"<rootDir>/app/assets/javascripts"
]
},
"dependencies": {
"babel-plugin-syntax-async-functions": "^6.3.13",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-regenerator": "^6.3.18",
"babel-polyfill": "^6.3.14",
"babel-preset-env": "^1.5.2",
"babel-preset-es2015": "^6.24.1",
"babel-preset-es2016": "^6.24.1",
"babel-preset-es2017": "^6.24.1",
"babel-preset-react": "^6.3.13",
"babel-preset-stage-0": "^6.3.13",
"babelify": "^7.2.0",
"browserify": "^14.0.0",
"browserify-incremental": "^3.1.0",
"es6-promise": "^3.0.2",
"fetch": "^0.3.6"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-jest": "^22.1.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"bootstrap": "^4.0.0-beta.3",
"browserify": "^14.4.0",
"browserify-incremental": "^3.1.1",
"jest": "^22.1.1"
}
This is the .babelrc file located in the project :
{
"presets": ["env", "es2015", "es2016", "es2017", "stage-0", "react"]
}
Locally, I am on node v7.10.0. I SSH'ed into my Semaphore CI session and discovered that node v4.8.4 is installed there. I tried installing node v4.8.4 on my local machine and with that version installed, I get the same test errors (posted above) locally as I did on CI. So this is a node version issue.
I added:
"engines": {
"node": ">= 7.1.0"
}
to my package.json file, but that did not affect the node version installed on Semaphore.
So if I already have Ruby 2.2.2 chosen as my language and version in the Semaphore Build Settings, how to I change my node version?
Thanks in advance for the help.
It looks like SemaphoreCI is not using the same version of NPM as you. But you can set that within the build settings like this :
nvm install v8.9.4
npm install
npm test
You can test it out in the SSH
Ervin from Semaphore here,
To change the current Node.js version in the environment, whilst Ruby 2.2 is selected, add nvm use 7.1 to your setup steps. This will switch to the desired Node.js version and everything should work as expected. There's also an example of this in the docs.
Get in touch on support if you run into any issues.

Resources