Skip to content

Commit

Permalink
Ignores timeout in .npmrc file while job update in npm_and_yarn (#10174)
Browse files Browse the repository at this point in the history
* Ignores timeout value while generating temporary .npmrc file while native helper run
  • Loading branch information
sachin-sandhu authored Jul 10, 2024
1 parent 61f3faf commit ccb9ffc
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,11 @@ def dependency_urls

sig { returns(String) }
def complete_npmrc_from_credentials
# removes attribute timeout to allow for job update,
# having a timeout=xxxxx value is causing some jobs to fail
initial_content = T.must(T.must(npmrc_file).content)
.gsub(/^.*\$\{.*\}.*/, "").strip + "\n"
.gsub(/^.*\$\{.*\}.*/, "").strip.gsub(/^timeout.*/, "").strip + "\n"

return initial_content unless yarn_lock || package_lock
return initial_content unless global_registry

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,57 @@
end
end
end

context "when dealing with an npmrc file with timeout" do
let(:dependency_files) { project_dependency_files("npm6/npmrc_env_timeout") }

it "populates the already existing npmrc" do
expect(npmrc_content)
.to eq("legacy-peer-deps=true\n" \
"loglevel=verbose\n\n" \
"fetch-retries=3\n" \
"fetch-retry-maxtimeout=4\n" \
"fetch-retry-mintimeout=3\n" \
"fetch-timeout=400000\n\n" \
"always-auth = true\n" \
"strict-ssl = true\n" \
"//npm.fury.io/dependabot/:_authToken=secret_token\n" \
"registry = https://npm.fury.io/dependabot\n" \
"//npm.fury.io/dependabot/:_authToken=my_token\n" \
"always-auth = true\n")
end

context "with basic auth credentials" do
let(:credentials) do
[Dependabot::Credential.new({
"type" => "git_source",
"host" => "github.com",
"username" => "x-access-token",
"password" => "token"
}), Dependabot::Credential.new({
"type" => "npm_registry",
"registry" => "npm.fury.io/dependabot",
"token" => "secret:token"
})]
end

it "populates the already existing npmrc" do
expect(npmrc_content)
.to eq("legacy-peer-deps=true\n" \
"loglevel=verbose\n\n" \
"fetch-retries=3\n" \
"fetch-retry-maxtimeout=4\n" \
"fetch-retry-mintimeout=3\n" \
"fetch-timeout=400000\n\n" \
"always-auth = true\n" \
"strict-ssl = true\n" \
"//npm.fury.io/dependabot/:_authToken=secret_token\n" \
"registry = https://npm.fury.io/dependabot\n" \
"//npm.fury.io/dependabot/:_auth=c2VjcmV0OnRva2Vu\n" \
"always-auth = true\n")
end
end
end
end
end

Expand Down
11 changes: 11 additions & 0 deletions npm_and_yarn/spec/fixtures/projects/npm6/npmrc_env_timeout/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
legacy-peer-deps=true
loglevel=verbose
timeout=90000
fetch-retries=3
fetch-retry-maxtimeout=4
fetch-retry-mintimeout=3
fetch-timeout=400000
_auth = ${NPM_AUTH}
always-auth = true
strict-ssl = true
//npm.fury.io/dependabot/:_authToken=secret_token

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "{{ name }}",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no\\ test\ specified\" && exit 1",
"prettify": "prettier --write \"{{packages/*/src,examples,cypress,scripts}/**/,}*.{js,jsx,ts,tsx,css,md}\""
},
"repository": {
"type": "git",
"url": "git+https://github.com/waltfy/PROTO_TEST.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/waltfy/PROTO_TEST/issues"
},
"homepage": "https://github.com/waltfy/PROTO_TEST#readme",
"dependencies": {
"fetch-factory": "^0.0.1"
},
"devDependencies": {
"etag" : "^1.0.0"
}}

0 comments on commit ccb9ffc

Please sign in to comment.