Skip to content

Commit 1bd0d88

Browse files
authored
Merge branch 'main' into add-bazel-lockfile
2 parents bed9594 + ac61dd5 commit 1bd0d88

File tree

54 files changed

+10401
-72
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+10401
-72
lines changed

bazel/lib/dependabot/bazel/file_fetcher.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class FileFetcher < Dependabot::FileFetchers::Base
1111

1212
WORKSPACE_FILES = T.let(%w(WORKSPACE WORKSPACE.bazel).freeze, T::Array[String])
1313
MODULE_FILES = T.let(%w(MODULE.bazel).freeze, T::Array[String])
14-
CONFIG_FILES = T.let(%w(.bazelrc MODULE.bazel.lock).freeze, T::Array[String])
14+
CONFIG_FILES = T.let(%w(.bazelrc MODULE.bazel.lock .bazelversion maven_install.json).freeze, T::Array[String])
1515
SKIP_DIRECTORIES = T.let(%w(.git .bazel-* bazel-* node_modules .github).freeze, T::Array[String])
1616

1717
sig { override.returns(String) }
@@ -86,14 +86,11 @@ def module_files
8686
def config_files
8787
files = T.let([], T::Array[DependencyFile])
8888

89-
CONFIG_FILES.each do |filename|
89+
CONFIG_FILES.map do |filename|
9090
file = fetch_file_if_present(filename)
9191
files << file if file
9292
end
9393

94-
bazelversion = fetch_file_if_present(".bazelversion")
95-
files << bazelversion if bazelversion
96-
9794
files
9895
end
9996

bazel/spec/dependabot/bazel/file_fetcher_spec.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,29 @@
113113
it "fetches the MODULE.bazel file" do
114114
expect(fetched_files.map(&:name)).to include("MODULE.bazel")
115115
end
116+
117+
context "with a maven_install.json file" do
118+
before do
119+
stub_request(:get, url + "?ref=sha")
120+
.to_return(
121+
status: 200,
122+
body: fixture("github", "contents_bazel_with_maven_install.json"),
123+
headers: { "content-type" => "application/json" }
124+
)
125+
126+
stub_request(:get, url + "maven_install.json?ref=sha")
127+
.to_return(
128+
status: 200,
129+
body: fixture("github", "contents_bazel_maven_install.json"),
130+
headers: { "content-type" => "application/json" }
131+
)
132+
end
133+
134+
it "includes maven_install.json" do
135+
puts "files: #{fetched_files.map(&:name)}"
136+
expect(fetched_files.map(&:name)).to include("maven_install.json")
137+
end
138+
end
116139
end
117140

118141
context "when beta ecosystems are not allowed" do
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "maven_install.json",
3+
"path": "maven_install.json",
4+
"sha": "abc123",
5+
"size": 1234,
6+
"url": "https://api.github.com/repos/example/repo/contents/maven_install.json?ref=sha",
7+
"html_url": "https://github.com/example/repo/blob/sha/maven_install.json",
8+
"git_url": "https://api.github.com/repos/example/repo/git/blobs/abc123",
9+
"download_url": "https://raw.githubusercontent.com/example/repo/sha/maven_install.json",
10+
"type": "file",
11+
"content": "bW9kdWxlKG5hbWUgPSAiZXhhbXBsZSIsIHZlcnNpb24gPSAiMS4wLjAiKQ==\n",
12+
"encoding": "base64"
13+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[
2+
{
3+
"name": "MODULE.bazel",
4+
"path": "MODULE.bazel",
5+
"sha": "abc123",
6+
"size": 1234,
7+
"url": "https://api.github.com/repos/example/repo/contents/MODULE.bazel?ref=sha",
8+
"html_url": "https://github.com/example/repo/blob/sha/MODULE.bazel",
9+
"git_url": "https://api.github.com/repos/example/repo/git/blobs/abc123",
10+
"download_url": "https://raw.githubusercontent.com/example/repo/sha/MODULE.bazel",
11+
"type": "file",
12+
"content": "bW9kdWxlKG5hbWUgPSAiZXhhbXBsZSIsIHZlcnNpb24gPSAiMS4wLjAiKQ==\n",
13+
"encoding": "base64"
14+
},
15+
{
16+
"name": "maven_install.json",
17+
"path": "maven_install.json",
18+
"sha": "abc123",
19+
"size": 1234,
20+
"url": "https://api.github.com/repos/example/repo/contents/maven_install.json?ref=sha",
21+
"html_url": "https://github.com/example/repo/blob/sha/maven_install.json",
22+
"git_url": "https://api.github.com/repos/example/repo/git/blobs/abc123",
23+
"download_url": "https://raw.githubusercontent.com/example/repo/sha/maven_install.json",
24+
"type": "file",
25+
"content": "bW9kdWxlKG5hbWUgPSAiZXhhbXBsZSIsIHZlcnNpb24gPSAiMS4wLjAiKQ==\n",
26+
"encoding": "base64"
27+
}
28+
]

bun/Dockerfile

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,64 +3,37 @@ FROM ghcr.io/dependabot/dependabot-updater-core
33
# Check for updates at https://github.com/nodejs/corepack/releases
44
ARG COREPACK_VERSION=0.33.0
55

6-
# Check for updates at https://github.com/pnpm/pnpm/releases
7-
ARG PNPM_VERSION=9.15.5
8-
9-
# Check for updates at https://github.com/yarnpkg/berry/releases
10-
ARG YARN_VERSION=4.5.3
11-
126
# Check for updates at https://github.com/oven-sh/bun/releases
137
ARG BUN_VERSION=1.2.5
148

159
# See https://github.com/nodesource/distributions#installation-instructions
1610
ARG NODEJS_VERSION=20
1711

18-
# Check for updates at https://github.com/npm/cli/releases
19-
# This version should be compatible with the Node.js version declared above. See https://nodejs.org/en/download/releases as well
20-
# TODO: Upgrade to 9.6.7 depending on the outcome of https://github.com/npm/cli/issues/6742
21-
ARG NPM_VERSION=9.6.5
22-
23-
# Install Node and npm
12+
# Install Node and bun
2413
RUN mkdir -p /etc/apt/keyrings \
2514
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
2615
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODEJS_VERSION}.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \
2716
&& apt-get update \
2817
&& apt-get install -y --no-install-recommends \
2918
nodejs \
3019
&& rm -rf /var/lib/apt/lists/* \
31-
&& npm install -g corepack@$COREPACK_VERSION \
3220
&& npm install -g corepack@$COREPACK_VERSION bun@$BUN_VERSION \
3321
&& rm -rf ~/.npm
3422

3523
USER dependabot
3624

37-
# Install pnpm and set it to a stable version
38-
RUN corepack install pnpm@$PNPM_VERSION --global
39-
40-
# Install yarn berry and set it to a stable version
41-
RUN corepack install yarn@$YARN_VERSION --global
42-
43-
# Install npm and set it to a stable version
44-
RUN corepack install npm@$NPM_VERSION --global
45-
4625
ENV DEPENDABOT_NATIVE_HELPERS_PATH="/opt"
4726
COPY --chown=dependabot:dependabot bun/helpers /opt/bun/helpers
4827
RUN bash /opt/bun/helpers/build
4928

50-
# START: HACKY WORKAROUND FOR NPM GIT INSTALLS SPAWNING CHILD PROCESS
51-
52-
# TODO: Remove these hacks once we've deprecated npm 6 support as it no longer
53-
# spawns a child process to npm install git dependencies.
54-
5529
# Create the config file manually instead of using yarn/npm config set as this
5630
# executes the package manager outputs to every job log
57-
COPY --chown=dependabot:dependabot updater/config/.yarnrc updater/config/.npmrc $DEPENDABOT_HOME/
31+
# This is here because bun supports .npmrc as well. See https://bun.com/docs/pm/npmrc#npmrc-support
32+
COPY --chown=dependabot:dependabot updater/config/.npmrc $DEPENDABOT_HOME/
5833

59-
# For Yarn Berry we can set this via an environment variable
34+
# Configure Node to use our custom CA bundle
6035
ENV NODE_EXTRA_CA_CERTS=/etc/ssl/certs/ca-certificates.crt
6136

62-
# END: HACKY WORKAROUND FOR NPM GIT INSTALLS SPAWNING CHILD PROCESS
63-
6437
COPY --chown=dependabot:dependabot bun $DEPENDABOT_HOME/bun
6538
COPY --chown=dependabot:dependabot common $DEPENDABOT_HOME/common
6639
COPY --chown=dependabot:dependabot updater $DEPENDABOT_HOME/dependabot-updater

github_actions/lib/dependabot/github_actions/constants.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ module GithubActions
3535

3636
OWNER_KEY = T.let("owner", String)
3737
REPO_KEY = T.let("repo", String)
38+
PATH_KEY = T.let("path", String)
3839
REF_KEY = T.let("ref", String)
3940
USES_KEY = T.let("uses", String)
4041
STEPS_KEY = T.let("steps", String)

github_actions/lib/dependabot/github_actions/file_parser.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,19 @@ def build_github_dependency(file, string)
112112
def github_dependency(file, string, hostname)
113113
details = T.must(string.match(GITHUB_REPO_REFERENCE)).named_captures
114114
repo_name = "#{details.fetch(OWNER_KEY)}/#{details.fetch(REPO_KEY)}"
115+
path = details[PATH_KEY]
115116
ref = details.fetch(REF_KEY)
116117
version = version_class.new(ref).to_s if version_class.correct?(ref)
117-
name = version_class.path_based?(ref) ? string : repo_name
118+
119+
# For reusable workflows (.github/workflows/*.yml), use the repository name + workflow path
120+
# to distinguish between different workflow files in the same repository
121+
name = if path&.match?(%r{/\.github/workflows/.*\.ya?ml$})
122+
"#{repo_name}#{path}"
123+
elsif version_class.path_based?(ref)
124+
string
125+
else
126+
repo_name
127+
end
118128
Dependency.new(
119129
name: name,
120130
version: version,

github_actions/spec/dependabot/github_actions/file_parser_spec.rb

Lines changed: 119 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def mock_service_pack_request(nwo)
214214

215215
it "has the right details" do
216216
expect(dependency).to be_a(Dependabot::Dependency)
217-
expect(dependency.name).to eq("actions/checkout")
217+
expect(dependency.name).to eq("actions/checkout/.github/workflows/test.yml")
218218
expect(dependency.version).to eq("2.1.0")
219219
expect(dependency.requirements).to eq(expected_requirements)
220220
end
@@ -228,6 +228,123 @@ def mock_service_pack_request(nwo)
228228
end
229229
end
230230

231+
describe "with multiple reusable workflows from the same repository" do
232+
let(:workflow_file_fixture_name) { "workflow_multiple_reusable_workflows.yml" }
233+
234+
before do
235+
mock_service_pack_request("dsp-testing/github-action-with-multiple-reusable-workflow-10619")
236+
end
237+
238+
its(:length) { is_expected.to eq(2) }
239+
240+
describe "the first dependency (action-one.yml)" do
241+
subject(:dependency) { dependencies.first }
242+
243+
let(:expected_requirements) do
244+
[{
245+
requirement: nil,
246+
groups: [],
247+
file: ".github/workflows/workflow.yml",
248+
source: {
249+
type: "git",
250+
url: "https://github.com/dsp-testing/github-action-with-multiple-reusable-workflow-10619",
251+
ref: "v1.0.0",
252+
branch: nil
253+
},
254+
metadata: {
255+
declaration_string: "dsp-testing/github-action-with-multiple-reusable-workflow-10619" \
256+
"/.github/workflows/action-one.yml@v1.0.0"
257+
}
258+
}]
259+
end
260+
261+
it "has the right details" do
262+
expect(dependency).to be_a(Dependabot::Dependency)
263+
expect(dependency.name).to eq(
264+
"dsp-testing/github-action-with-multiple-reusable-workflow-10619" \
265+
"/.github/workflows/action-one.yml"
266+
)
267+
expect(dependency.version).to eq("1.0.0")
268+
expect(dependency.requirements).to eq(expected_requirements)
269+
end
270+
end
271+
272+
describe "the second dependency (action-two.yml)" do
273+
subject(:dependency) { dependencies.last }
274+
275+
let(:expected_requirements) do
276+
[{
277+
requirement: nil,
278+
groups: [],
279+
file: ".github/workflows/workflow.yml",
280+
source: {
281+
type: "git",
282+
url: "https://github.com/dsp-testing/github-action-with-multiple-reusable-workflow-10619",
283+
ref: "v1.0.0",
284+
branch: nil
285+
},
286+
metadata: {
287+
declaration_string: "dsp-testing/github-action-with-multiple-reusable-workflow-10619" \
288+
"/.github/workflows/action-two.yml@v1.0.0"
289+
}
290+
}]
291+
end
292+
293+
it "has the right details" do
294+
expect(dependency).to be_a(Dependabot::Dependency)
295+
expect(dependency.name).to eq(
296+
"dsp-testing/github-action-with-multiple-reusable-workflow-10619" \
297+
"/.github/workflows/action-two.yml"
298+
)
299+
expect(dependency.version).to eq("1.0.0")
300+
expect(dependency.requirements).to eq(expected_requirements)
301+
end
302+
end
303+
end
304+
305+
describe "with reusable workflow using .yaml extension" do
306+
let(:workflow_file_fixture_name) { "workflow_reusable_yaml_extension.yml" }
307+
308+
before do
309+
mock_service_pack_request("dsp-testing/github-action-with-yaml-extension")
310+
end
311+
312+
its(:length) { is_expected.to eq(1) }
313+
314+
describe "the dependency with .yaml extension" do
315+
subject(:dependency) { dependencies.first }
316+
317+
let(:expected_requirements) do
318+
[{
319+
requirement: nil,
320+
groups: [],
321+
file: ".github/workflows/workflow.yml",
322+
source: {
323+
type: "git",
324+
url: "https://github.com/dsp-testing/github-action-with-yaml-extension",
325+
ref: "v1.0.0",
326+
branch: nil
327+
},
328+
metadata: {
329+
declaration_string:
330+
"dsp-testing/github-action-with-yaml-extension" \
331+
"/.github/workflows/action-test.yaml@v1.0.0"
332+
}
333+
}]
334+
end
335+
336+
it "has the right details" do
337+
expect(dependency).to be_a(Dependabot::Dependency)
338+
expect(dependency.name).to eq(
339+
"dsp-testing/github-action-with-yaml-extension" \
340+
"/.github/workflows/action-test.yaml"
341+
)
342+
expect(dependency.version).to eq("1.0.0")
343+
expect(dependency.requirements).to eq(expected_requirements)
344+
end
345+
end
346+
end
347+
231348
describe "with composite actions" do
232349
let(:workflow_file_fixture_name) { "composite_action.yml" }
233350
let(:workflow_files) do
@@ -410,7 +527,7 @@ def mock_service_pack_request(nwo)
410527

411528
it "has the right details" do
412529
expect(dependency).to be_a(Dependabot::Dependency)
413-
expect(dependency.name).to eq("actions/checkout")
530+
expect(dependency.name).to eq("actions/checkout/.github/workflows/test.yml")
414531
expect(dependency.version).to eq("2.1.0")
415532
expect(dependency.requirements).to eq(expected_requirements)
416533
end
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
on:
2+
pull_request:
3+
4+
jobs:
5+
test-action-one:
6+
uses: dsp-testing/github-action-with-multiple-reusable-workflow-10619/.github/workflows/action-one.yml@v1.0.0
7+
8+
test-action-two:
9+
uses: dsp-testing/github-action-with-multiple-reusable-workflow-10619/.github/workflows/action-two.yml@v1.0.0
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
on:
2+
pull_request:
3+
4+
jobs:
5+
test-yaml-workflow:
6+
uses: dsp-testing/github-action-with-yaml-extension/.github/workflows/action-test.yaml@v1.0.0

0 commit comments

Comments
 (0)