Skip to content

Commit

Permalink
feat(2683): nodejs upgrade (#55)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Node 18 upgrade && eslint upgrade
  • Loading branch information
klu909 authored Dec 15, 2022
1 parent 7367004 commit 4609c4c
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 53 deletions.
56 changes: 23 additions & 33 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,36 +142,21 @@ class GitlabScm extends Scm {
config,
Joi.object()
.keys({
gitlabProtocol: Joi.string()
.optional()
.default('https'),
gitlabHost: Joi.string()
.optional()
.default('gitlab.com'),
username: Joi.string()
.optional()
.default('sd-buildbot'),
email: Joi.string()
.optional()
.default('[email protected]'),
commentUserToken: Joi.string()
.optional()
.description('Token for PR comments'),
gitlabProtocol: Joi.string().optional().default('https'),
gitlabHost: Joi.string().optional().default('gitlab.com'),
username: Joi.string().optional().default('sd-buildbot'),
email: Joi.string().optional().default('[email protected]'),
commentUserToken: Joi.string().optional().description('Token for PR comments'),
readOnly: Joi.object()
.keys({
enabled: Joi.boolean().optional(),
username: Joi.string().optional(),
accessToken: Joi.string().optional(),
cloneType: Joi.string()
.valid('https', 'ssh')
.optional()
.default('https')
cloneType: Joi.string().valid('https', 'ssh').optional().default('https')
})
.optional()
.default({}),
https: Joi.boolean()
.optional()
.default(false),
https: Joi.boolean().optional().default(false),
oauthClientId: Joi.string().required(),
oauthClientSecret: Joi.string().required(),
fusebox: Joi.object().default({})
Expand Down Expand Up @@ -342,10 +327,13 @@ class GitlabScm extends Scm {
* @return {Promise} Resolves to an ID of 'serviceName:repoId:branchName:rootDir'
*/
async _parseUrl({ checkoutUrl, rootDir, token }) {
const { hostname, owner, reponame, branch, rootDir: sourceDir } = getRepoInfoByCheckoutUrl(
checkoutUrl,
rootDir
);
const {
hostname,
owner,
reponame,
branch,
rootDir: sourceDir
} = getRepoInfoByCheckoutUrl(checkoutUrl, rootDir);
const myHost = this.config.gitlabHost || 'gitlab.com';

if (hostname !== myHost) {
Expand Down Expand Up @@ -433,9 +421,7 @@ class GitlabScm extends Scm {

return {
action: 'push',
branch: Hoek.reach(webhookPayload, 'ref')
.split('/')
.slice(-1)[0],
branch: Hoek.reach(webhookPayload, 'ref').split('/').slice(-1)[0],
checkoutUrl,
sha: Hoek.reach(webhookPayload, 'checkout_sha'),
type: 'repo',
Expand Down Expand Up @@ -567,10 +553,12 @@ class GitlabScm extends Scm {
// Git clone
command.push(`echo Cloning external config repo ${parentCheckoutUrl}`);
command.push(
`${'if [ ! -z $GIT_SHALLOW_CLONE ] && [ $GIT_SHALLOW_CLONE = false ]; ' +
`${
'if [ ! -z $GIT_SHALLOW_CLONE ] && [ $GIT_SHALLOW_CLONE = false ]; ' +
'then $SD_GIT_WRAPPER ' +
`"git clone --recursive --quiet --progress --branch ${parentBranch} ` +
'$CONFIG_URL $SD_CONFIG_DIR"; '}${shallowCloneCmd}` +
'$CONFIG_URL $SD_CONFIG_DIR"; '
}${shallowCloneCmd}` +
`--recursive --quiet --progress --branch ${parentBranch} ` +
'$CONFIG_URL $SD_CONFIG_DIR"; fi'
);
Expand All @@ -582,10 +570,12 @@ class GitlabScm extends Scm {
// Git clone
command.push(`echo 'Cloning ${checkoutUrl}, on branch ${branch}'`);
command.push(
`${'if [ ! -z $GIT_SHALLOW_CLONE ] && [ $GIT_SHALLOW_CLONE = false ]; ' +
`${
'if [ ! -z $GIT_SHALLOW_CLONE ] && [ $GIT_SHALLOW_CLONE = false ]; ' +
'then $SD_GIT_WRAPPER ' +
`"git clone --recursive --quiet --progress --branch '${branch}' ` +
'$SCM_URL $SD_CHECKOUT_DIR_FINAL"; '}${shallowCloneCmd}` +
'$SCM_URL $SD_CHECKOUT_DIR_FINAL"; '
}${shallowCloneCmd}` +
`--recursive --quiet --progress --branch '${branch}' ` +
'$SCM_URL $SD_CHECKOUT_DIR_FINAL"; fi'
);
Expand Down
32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "screwdriver-scm-gitlab",
"version": "2.0.0",
"version": "3.0.0",
"description": "GitLab implementation for the scm-base class",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -31,25 +31,25 @@
"Tiffany Kyi <[email protected]>"
],
"devDependencies": {
"chai": "^4.3.6",
"eslint": "^7.31.0",
"eslint-config-screwdriver": "^5.0.1",
"mocha": "^8.4.0",
"chai": "^4.3.7",
"eslint": "^8.28.0",
"eslint-config-screwdriver": "^7.0.0",
"mocha": "^10.1.0",
"mocha-multi-reporters": "^1.5.1",
"mocha-sonarqube-reporter": "^1.0.2",
"mockery": "^2.0.0",
"nock": "^13.2.4",
"nyc": "^15.0.0",
"sinon": "^9.0.0"
"mockery": "^2.1.0",
"nock": "^13.2.9",
"nyc": "^15.1.0",
"sinon": "^15.0.0"
},
"dependencies": {
"@hapi/hoek": "^9.2.1",
"circuit-fuses": "^4.1.2",
"joi": "^17.6.0",
"screwdriver-data-schema": "^21.24.0",
"screwdriver-logger": "^1.1.0",
"screwdriver-request": "^1.0.2",
"screwdriver-scm-base": "^7.4.0"
"@hapi/hoek": "^10.0.1",
"circuit-fuses": "^5.0.0",
"joi": "^17.7.0",
"screwdriver-data-schema": "^22.0.1",
"screwdriver-logger": "^2.0.0",
"screwdriver-request": "^2.0.1",
"screwdriver-scm-base": "^8.0.0"
},
"release": {
"branches": [
Expand Down
2 changes: 1 addition & 1 deletion screwdriver.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
shared:
image: node:12
image: node:18

jobs:
main:
Expand Down
5 changes: 2 additions & 3 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const prefixUrl = 'https://gitlab.com/api/v4';

sinon.assert.expose(assert, { prefix: '' });

describe('index', function() {
describe('index', function () {
// Time not important. Only life important.
this.timeout(5000);

Expand Down Expand Up @@ -1023,8 +1023,7 @@ describe('index', function() {
assert.calledWith(requestMock, {
method: 'GET',
searchParams: { ref: 'master' },
url:
'https://gitlab.com/api/v4/projects/screwdriver-cd%2Fscm-gitlab/repository/files/path%2Fto%2Fa%2Ffile.yaml',
url: 'https://gitlab.com/api/v4/projects/screwdriver-cd%2Fscm-gitlab/repository/files/path%2Fto%2Fa%2Ffile.yaml',
context: { token: 'somerandomtoken' }
});
}));
Expand Down

0 comments on commit 4609c4c

Please sign in to comment.