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

feat(3282): upgrade Node.js v22 and dependencies. BREAKING CHANGE: Node22 #70

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
6 changes: 3 additions & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
artifacts
node_modules
.git
node_modules/
artifacts/
features/*.feature
7 changes: 0 additions & 7 deletions .eslintrc

This file was deleted.

1 change: 1 addition & 0 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extends: screwdriver
11 changes: 0 additions & 11 deletions .github/dependabot.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ CVS/
.svn
*~
.com.apple.timemachine.supported
.nyc_output
.nyc_output
package-lock.json
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Contributing to Screwdriver

Have a look at our guidelines, as well as pointers on where to start making changes, in our official [documentation](https://docs.screwdriver.cd/about/contributing/pull-requests).
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
[![Version][npm-image]][npm-url] [![Build Status][status-image]][status-url] [![Open Issues][issues-image]][issues-url] ![License][license-image]

# retry-function
Wrapper to retry function calls with an exponential backoff strategy

## Installation:
```npm install --save retry-function```
```npm install --save screwdriver-retry-function```

## Usage:
Pass a function and callback to retryFn and it will retry with exponential backoff.
Expand Down Expand Up @@ -76,3 +78,17 @@ retryFn({
```

Code licensed under the MIT license. See LICENSE file for terms.

[![Version][npm-image]][npm-url]
[![Build Status][status-image]][status-url]
[![Open Issues][issues-image]][issues-url]
![License][license-image]

[npm-image]: https://img.shields.io/npm/v/screwdriver-retry-function.svg
[npm-url]: https://npmjs.org/package/screwdriver-retry-function
[license-image]: https://img.shields.io/badge/license-MIT-green
[issues-image]: https://img.shields.io/github/issues/screwdriver-cd/screwdriver.svg
[issues-url]: https://github.com/screwdriver-cd/screwdriver/issues
[status-image]: https://cd.screwdriver.cd/pipelines/10797/badge
[status-url]: https://cd.screwdriver.cd/pipelines/10797
[screwdriver job-tools]: https://github.com/screwdriver-cd/job-tools
17 changes: 7 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// Copyright 2015 Yahoo Inc.
// Licensed under the MIT license.
// See the included LICENSE file for terms.
'use strict';

const retry = require('retry');
const joi = require('joi');
Expand All @@ -15,8 +13,9 @@ const joi = require('joi');
function execRetry(config, callback) {
const c = config;

c.shouldRetry = c.shouldRetry
|| function shouldRetry() {
c.shouldRetry =
c.shouldRetry ||
function shouldRetry() {
return true;
};
c.options = c.options || {};
Expand Down Expand Up @@ -60,13 +59,13 @@ function validateRetry(config, callback) {
factor: joi.number().optional(),
minTimeout: joi.number().optional(),
maxTimeout: joi.number().optional(),
randomize: joi.boolean().optional(),
randomize: joi.boolean().optional()
})
.optional(),
context: joi.object().optional(),
arguments: joi.array().optional(),
shouldRetry: joi.func().optional(),
method: joi.func().required(),
method: joi.func().required()
})
.required();

Expand All @@ -77,9 +76,7 @@ function validateRetry(config, callback) {
const result = schema.validate(config);

if (result.error) {
throw new Error(
result.error.details.map((detail) => detail.message).join(','),
);
throw new Error(result.error.details.map(detail => detail.message).join(','));
}

execRetry(config, callback);
Expand Down
6 changes: 6 additions & 0 deletions mocha.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"reporterEnabled": "spec, mocha-sonarqube-reporter",
"mochaSonarqubeReporterReporterOptions": {
"output": "./artifacts/report/test.xml"
}
}
60 changes: 38 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,53 @@
{
"name": "retry-function",
"version": "3.0.0",
"name": "screwdriver-retry-function",
"version": "1.0.0",
"description": "Wrapper to retry function calls with an exponential backoff strategy",
"main": "index.js",
"scripts": {
"test": "nyc --reporter=lcov --reporter=text-summary mocha tests/*",
"lint": "eslint ."
"pretest": "eslint .",
"test": "nyc --report-dir ./artifacts/coverage --reporter=lcov mocha --reporter mocha-multi-reporters --reporter-options configFile=./mocha.config.json --recursive --timeout 4000 --retries 1 --exit --allow-uncaught true --color true"
},
"repository": {
"type": "git",
"url": "git://github.com/petey/retry-function.git"
"url": "git+https://github.com/screwdriver-cd/retry-function.git"
},
"homepage": "https://github.com/screwdriver-cd/retry-function",
"bugs": "https://github.com/screwdriver-cd/screwdriver/issues",
"keywords": [
"screwdriver",
"yahoo"
],
"license": "BSD-3-Clause",
"author": "Pete Peterson <petey31@yahoo.com>",
"bugs": {
"url": "https://github.com/petey/retry-function/issues"
},
"engines": {
"node": ">=10.0.0"
},
"homepage": "https://github.com/petey/retry-function",
"contributors": [
"Alan Dong <alandong2016@gmail.com>",
"Dao Lam <daolam112@gmail.com>",
"Dekus Lam <dekusdenial@hotmail.com>",
"Jithin Emmanuel <jithin1987@gmail.com>",
"Kevin Lu <klu13960@gmail.com>",
"Lakshminarasimhan Parthasarathy <laky@ymail.com>",
"Pritam Paul <pritam.paul09@hotmail.com>",
"Tiffany Kyi <tiffanykyi@gmail.com>"
],
"dependencies": {
"joi": "^17.3.0",
"retry": "^0.12.0"
"joi": "^17.13.3",
"retry": "^0.13.1"
},
"devDependencies": {
"chai": "^4.2.0",
"eslint": "^7.12.1",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-plugin-import": "^2.22.1",
"jenkins-mocha": "^8.0.0",
"mocha": "^8.2.0",
"chai": "^4.3.7",
"eslint": "^8.57.0",
"eslint-config-screwdriver": "^8.0.0",
"mocha": "^10.1.0",
"mocha-multi-reporters": "^1.5.1",
"mocha-sonarqube-reporter": "^1.0.2",
"nyc": "^15.1.0",
"sinon": "^9.2.1"
"mockery": "^2.1.0",
"sinon": "^15.0.0"
},
"engines": {
"node": ">=22.0.0"
},
"license": "MIT"
"release": {
"debug": false
}
}
17 changes: 13 additions & 4 deletions screwdriver.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
shared:
image: node:6
image: node:22

jobs:
main:
environment:
SD_SONAR_OPTS: "-Dsonar.sources=app -Dsonar.tests=test -Dsonar.javascript.lcov.reportPaths=artifacts/coverage/lcov.info -Dsonar.testExecutionReportPaths=artifacts/report/test.xml"
requires: [~pr, ~commit]
steps:
- install: npm install
- test: npm test
requires:
- ~pr
- ~commit

publish:
requires: [main]
template: screwdriver-cd/semantic-release
secrets:
# Publishing to NPM
- NPM_TOKEN
# Pushing tags to Git
- GH_TOKEN
50 changes: 23 additions & 27 deletions tests/index.test.js → test/index.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
/* eslint-env mocha */

// Copyright 2015 Yahoo Inc.
// Licensed under the MIT license.
// See the included LICENSE file for terms.
'use strict';

const sinon = require('sinon');
const { assert } = require('chai');
Expand All @@ -17,8 +13,8 @@ describe('retry-function test case', () => {
});

describe('retryFn', () => {
it('should not retry if first run successful', (done) => {
myCallback = (err) => {
it('should not retry if first run successful', done => {
myCallback = err => {
assert.isNull(err);
assert.isTrue(myFunc.calledOnce);
done();
Expand All @@ -28,14 +24,14 @@ describe('retry-function test case', () => {

retryFn(
{
method: myFunc,
method: myFunc
},
myCallback,
myCallback
);
});

it('should retry fn until success', (done) => {
myCallback = (err) => {
it('should retry fn until success', done => {
myCallback = err => {
assert.isNull(err);
assert.isTrue(myFunc.calledThrice);
done();
Expand All @@ -49,15 +45,15 @@ describe('retry-function test case', () => {
method: myFunc,
options: {
minTimeout: 10,
retries: 5,
},
retries: 5
}
},
myCallback,
myCallback
);
});

it('should have error if never succeeds', (done) => {
myCallback = (err) => {
it('should have error if never succeeds', done => {
myCallback = err => {
assert.isNotNull(err);
assert.equal(err.message, 'nope');
assert.isTrue(myFunc.calledThrice);
Expand All @@ -71,15 +67,15 @@ describe('retry-function test case', () => {
method: myFunc,
options: {
minTimeout: 10,
retries: 2,
},
retries: 2
}
},
myCallback,
myCallback
);
});

it('should not continue if shouldRetry says not to', (done) => {
myCallback = (err) => {
it('should not continue if shouldRetry says not to', done => {
myCallback = err => {
assert.isNotNull(err);
assert.equal(err.message, 'yep');
assert.isTrue(myFunc.calledThrice);
Expand All @@ -92,13 +88,13 @@ describe('retry-function test case', () => {
retryFn(
{
method: myFunc,
shouldRetry: (err) => err.message === 'nope',
shouldRetry: err => err.message === 'nope',
options: {
minTimeout: 10,
retries: 5,
},
retries: 5
}
},
myCallback,
myCallback
);
});

Expand All @@ -108,7 +104,7 @@ describe('retry-function test case', () => {
retryFn({}, () => ({}));
},
Error,
'"method" is required',
'"method" is required'
);
});

Expand All @@ -118,7 +114,7 @@ describe('retry-function test case', () => {
retryFn({});
},
Error,
'"callback" must be a function',
'"callback" must be a function'
);
});
});
Expand Down
Loading