Skip to content

Commit

Permalink
fix: upgrade devDependencies and image of config-parse-error to node:…
Browse files Browse the repository at this point in the history
…10 (#88)
  • Loading branch information
tk3fftk authored and tkyi committed Jun 17, 2019
1 parent 53930d5 commit 19018f4
Show file tree
Hide file tree
Showing 9 changed files with 319 additions and 327 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ npm-debug.log
.*.swp
.nyc_output/
package-lock.json
.idea
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const phaseGeneratePermutations = require('./lib/phase/permutation');
function parseYaml(yaml) {
// If no yaml exists, throw error
if (!yaml) {
return Promise.reject('screwdriver.yaml does not exist. Please ' +
'create a screwdriver.yaml and try to rerun your build.');
return Promise.reject(new Error('screwdriver.yaml does not exist. Please '
+ 'create a screwdriver.yaml and try to rerun your build.'));
}

return new Promise((resolve) => {
Expand Down Expand Up @@ -79,7 +79,7 @@ module.exports = function configParser(yaml, templateFactory, buildClusterFactor
annotations: {},
jobs: {
main: [{
image: 'node:6',
image: 'node:10',
commands: [{
name: 'config-parse-error',
command: `echo "${err}"; exit 1`
Expand Down
10 changes: 4 additions & 6 deletions lib/phase/flatten.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ const clone = require('clone');
* @return {Array} List of errors or null if no error
*/
function checkAdditionalRules(doc) {
let steps = [];
const errors = [];

Object.keys(doc.jobs).forEach((job) => {
const { steps } = doc.jobs[job];
const stepList = [];

steps = doc.jobs[job].steps;

if (steps) {
for (let i = 0; i < steps.length; i += 1) {
const stepName = Object.keys(steps[i])[0];
Expand Down Expand Up @@ -126,7 +124,7 @@ function merge(newJob, oldJob, fromTemplate) {
}, {});

for (let i = 0; i < newJob.steps.length; i += 1) {
stepName = Object.keys(newJob.steps[i])[0];
[stepName] = Object.keys(newJob.steps[i]);
preStepName = `pre${stepName}`;
postStepName = `post${stepName}`;

Expand Down Expand Up @@ -231,8 +229,8 @@ function mergeTemplateIntoJob(jobName, jobConfig, newJobs, templateFactory) {

// If template.images contains a label match for the image defined in the job
// set the job image to the respective template image
if (typeof template.images !== 'undefined' &&
typeof template.images[newJob.image] !== 'undefined') {
if (typeof template.images !== 'undefined'
&& typeof template.images[newJob.image] !== 'undefined') {
newJob.image = template.images[newJob.image];
}

Expand Down
18 changes: 8 additions & 10 deletions lib/phase/functional.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,11 @@ function validateBuildClusterAnnotation(doc, buildClusterFactory) {

if (buildClusterName && buildClusterFactory) {
return buildClusterFactory.list()
.then(buildClusters => buildClusters.some(buildCluster =>
buildCluster.name === buildClusterName
))
.then(buildClusters => buildClusters.some(cluster => cluster.name === buildClusterName))
.then((hasValidBuildCluster) => {
if (!hasValidBuildCluster) {
return [`Annotation "${buildClusterAnnotation}": ` +
`${buildClusterName} is not a valid build cluster`];
return [`Annotation "${buildClusterAnnotation}": `
+ `${buildClusterName} is not a valid build cluster`];
}

return [];
Expand Down Expand Up @@ -69,18 +67,18 @@ function validateJobMatrix(job, prefix) {
const environmentSize = Object.keys(matrix).length + userEnv.length;

if (environmentSize > MAX_ENVIRONMENT_VARS) {
errors.push(`${prefix}: "environment" and "matrix" can only have a combined ` +
` maxiumum of ${MAX_ENVIRONMENT_VARS} environment variables defined ` +
`(currently ${environmentSize})`);
errors.push(`${prefix}: "environment" and "matrix" can only have a combined `
+ ` maxiumum of ${MAX_ENVIRONMENT_VARS} environment variables defined `
+ `(currently ${environmentSize})`);
}

Object.keys(matrix).forEach((row) => {
matrixSize *= matrix[row].length;
});

if (matrixSize > MAX_PERMUTATIONS) {
errors.push(`${prefix}: "matrix" cannot contain >${MAX_PERMUTATIONS} permutations ` +
`(currently ${matrixSize})`);
errors.push(`${prefix}: "matrix" cannot contain >${MAX_PERMUTATIONS} permutations `
+ `(currently ${matrixSize})`);
}

return errors;
Expand Down
4 changes: 1 addition & 3 deletions lib/phase/structural.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ const SCHEMA_CONFIG = require('screwdriver-data-schema').config.base.config;
* @return {Array} List of errors
*/
function checkAdditionalRules(data) {
let steps = [];
const errors = [];

Object.keys(data.jobs).forEach((job) => {
let firstUserTeardownStep = -1;

steps = data.jobs[job].steps;
const { steps } = data.jobs[job];

if (steps) { // if there are user-defined steps
for (let i = 0; i < steps.length; i += 1) {
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
},
"engine-strict": true,
"devDependencies": {
"chai": "^3.5.0",
"chai": "^4.2.0",
"eslint": "^4.19.1",
"eslint-config-screwdriver": "^3.0.1",
"jenkins-mocha": "^6.0.0",
"sinon": "^2.4.1"
"eslint-config-screwdriver": "^4.0.0",
"jenkins-mocha": "^7.0.0",
"sinon": "^7.3.2"
},
"dependencies": {
"clone": "^2.1.2",
Expand Down
2 changes: 1 addition & 1 deletion test/data/bad-build-cluster.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"jobs": {
"main": [
{
"image": "node:6",
"image": "node:10",
"commands": [
{
"name": "config-parse-error",
Expand Down
2 changes: 1 addition & 1 deletion test/data/pipeline-cache-nonexist-job.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"jobs": {
"main": [
{
"image": "node:6",
"image": "node:10",
"commands": [
{
"name": "config-parse-error",
Expand Down
Loading

0 comments on commit 19018f4

Please sign in to comment.