From acd2eabae649e372f22d7c05f4eaacfda1b97703 Mon Sep 17 00:00:00 2001 From: Kevin Dew Date: Wed, 13 Jan 2021 22:53:08 +0000 Subject: [PATCH] Detect and install yarn dependencies automatically It's common for GOV.UK Rails apps to have yarn dependencies, currently many any apps have a hook of: `beforeTest: { sh("yarn install") },`. The changes in this commit will mean this can be removed. --- README.md | 1 + vars/govuk.groovy | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index 02a468c..5203251 100644 --- a/README.md +++ b/README.md @@ -78,3 +78,4 @@ postgres96Lint | Whether or not to forbid newer postgres features | `true` publishingE2ETests | Whether or not to run the Publishing end-to-end tests. | `false` sassLint | Whether or not to run the SASS linter | `true` skipDeployToIntegration | Whether or not to skip the "Deploy to integration" stage | `false` +yarnInstall | Whether or not to install Yarn dependencies if a yarn.lock file is found | `true` diff --git a/vars/govuk.groovy b/vars/govuk.groovy index 15b979e..e79bd52 100644 --- a/vars/govuk.groovy +++ b/vars/govuk.groovy @@ -166,6 +166,12 @@ def nonDockerBuildTasks(options, jobName, repoName) { } } + if (options.yarnInstall != false && fileExists(file: "yarn.lock")) { + stage("yarn install") { + sh("yarn install --frozen-lockfile") + } + } + if (hasAssets() && hasSCSSLint() && options.sassLint != false) { stage("Lint SCSS") { lintSCSS()