Skip to content

Commit 094addf

Browse files
committed
github_actions: gate lockfile updates behind experiment
1 parent 389b400 commit 094addf

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

github_actions/lib/dependabot/github_actions/file_fetcher.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
require "dependabot/file_fetchers"
77
require "dependabot/file_fetchers/base"
8+
require "dependabot/experiments"
89
require "dependabot/github_actions/constants"
910

1011
module Dependabot
@@ -79,6 +80,7 @@ def fetch_files
7980
# repository workflows. Composite-action directories cannot own a lockfile.
8081
sig { returns(T.nilable(DependencyFile)) }
8182
def actions_lockfile
83+
return unless Dependabot::Experiments.enabled?(:github_actions_lockfile)
8284
return unless source.hostname == GITHUB_COM
8385
return fetch_file_if_present(LOCKFILE_PATH) if directory == "/"
8486

github_actions/spec/dependabot/github_actions/file_fetcher_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191

9292
context "when an actions.lock is present" do
9393
before do
94+
Dependabot::Experiments.register(:github_actions_lockfile, true)
9495
stub_request(:get, url + ".github/workflows?ref=sha")
9596
.with(headers: { "Authorization" => "token token" })
9697
.to_return(
@@ -117,6 +118,7 @@
117118

118119
context "when an actions.lock is present" do
119120
before do
121+
Dependabot::Experiments.register(:github_actions_lockfile, true)
120122
# Re-stub the workflows listing to include the lockfile alongside the
121123
# workflow files, then stub the lockfile content fetch.
122124
stub_request(:get, url + ".github/workflows?ref=sha")
@@ -146,6 +148,19 @@
146148
)
147149
end
148150

151+
context "when the experiment is disabled" do
152+
before { Dependabot::Experiments.reset! }
153+
154+
it "keeps the existing workflow-only behavior" do
155+
expect(file_fetcher_instance.files.map(&:name))
156+
.to match_array(
157+
%w(.github/workflows/sherlock-workflow.yaml
158+
.github/workflows/integration-workflow.yml)
159+
)
160+
expect(a_request(:get, url + ".github/workflows/actions.lock?ref=sha")).not_to have_been_made
161+
end
162+
end
163+
149164
context "with a non-github.com source" do
150165
let(:credentials) do
151166
[{
@@ -210,6 +225,7 @@
210225

211226
context "when an actions.lock is present" do
212227
before do
228+
Dependabot::Experiments.register(:github_actions_lockfile, true)
213229
stub_request(:get, url + ".github/workflows?ref=sha")
214230
.with(headers: { "Authorization" => "token token" })
215231
.to_return(

0 commit comments

Comments
 (0)