dependabot-github_actions 0.290.0 → 0.292.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73086dbabc2a140abac38cd611ad0935b94551ac037b0471ce724bffef9f793b
4
- data.tar.gz: 3c383709a692102f4c10f8835c87a8fabd19ea2767fcf7b4d23b46dcab2d8a80
3
+ metadata.gz: ec9317297cf1d6f91689b4dbfd495361463c4da20b5e1cdfb8b1bec345fb6fdc
4
+ data.tar.gz: 108569a3859425a5c8120fa66f9f04f1a93d24f4d394ba6b36d19e5431e02071
5
5
  SHA512:
6
- metadata.gz: c72d7de19ff07f28daf2c6561f00ad6e676267ed8441583757c309608f0b17c55229cc6961b23d970d5de42764afc947e11882466974c7fbbfaa4a7cc8945957
7
- data.tar.gz: 81ae8260af6064da9f00632528a767d120542b894b1700c83934a3988ad01181bd38765bca7cc270a4d67332d44a5a9c326ff5a8c99f053a157b8f1bf0aa9954
6
+ metadata.gz: 5fbf5b457cf937c2b4856b6a2993c229b10218d541d288f31e4c80c36a84e75a3505b229057484dbd5e19fad22c7a4a99a9c3e9aa72e643e54abbc39cdb668aa
7
+ data.tar.gz: f2618bb10546af53d065eb2364fd0de958fdf98537b9de8d163d6191fd5c4ad3fa8714bb0688bc481a7aa977b6361ab05c01564323bb03e2280e0fe5eb23dc44
@@ -0,0 +1,44 @@
1
+ # typed: strong
2
+ # frozen_string_literal: true
3
+
4
+ module Dependabot
5
+ module GithubActions
6
+ # Reference to the GitHub.com domain
7
+ GITHUB_COM = T.let("github.com", String)
8
+
9
+ # Regular expression to match a GitHub repository reference
10
+ GITHUB_REPO_REFERENCE = T.let(%r{
11
+ ^(?<owner>[\w.-]+)/
12
+ (?<repo>[\w.-]+)
13
+ (?<path>/[^\@]+)?
14
+ @(?<ref>.+)
15
+ }x, Regexp)
16
+
17
+ # Matches .yml or .yaml files in the .github/workflows directories
18
+ WORKFLOW_YAML_REGEX = %r{\.github/workflows/.+\.ya?ml$}
19
+ # Matches .yml or .yaml files anywhere
20
+ ALL_YAML_FILES = %r{(?:^|/).+\.ya?ml$}
21
+
22
+ # The ecosystem name for GitHub Actions
23
+ ECOSYSTEM = T.let("github_actions", String)
24
+
25
+ # The pattern to match manifest files
26
+ MANIFEST_FILE_PATTERN = /\.ya?ml$/
27
+ # The name of the manifest file
28
+ MANIFEST_FILE_YML = T.let("action.yml", String)
29
+ # The name of the manifest file
30
+ MANIFEST_FILE_YAML = T.let("action.yaml", String)
31
+ # The pattern to match any .yml or .yaml file
32
+ ANYTHING_YML = T.let("<anything>.yml", String)
33
+ # The path to the workflow directory
34
+ WORKFLOW_DIRECTORY = T.let(".github/workflows", String)
35
+ # The path to the config .yml file
36
+ CONFIG_YMLS = T.let("#{WORKFLOW_DIRECTORY}/#{ANYTHING_YML}".freeze, String)
37
+
38
+ OWNER_KEY = T.let("owner", String)
39
+ REPO_KEY = T.let("repo", String)
40
+ REF_KEY = T.let("ref", String)
41
+ USES_KEY = T.let("uses", String)
42
+ STEPS_KEY = T.let("steps", String)
43
+ end
44
+ end
@@ -5,6 +5,7 @@ require "sorbet-runtime"
5
5
 
6
6
  require "dependabot/file_fetchers"
7
7
  require "dependabot/file_fetchers/base"
8
+ require "dependabot/github_actions/constants"
8
9
 
9
10
  module Dependabot
10
11
  module GithubActions
@@ -12,11 +13,9 @@ module Dependabot
12
13
  extend T::Sig
13
14
  extend T::Helpers
14
15
 
15
- FILENAME_PATTERN = /\.ya?ml$/
16
-
17
16
  sig { override.params(filenames: T::Array[String]).returns(T::Boolean) }
18
17
  def self.required_files_in?(filenames)
19
- filenames.any? { |f| f.match?(FILENAME_PATTERN) }
18
+ filenames.any? { |f| f.match?(MANIFEST_FILE_PATTERN) }
20
19
  end
21
20
 
22
21
  sig { override.returns(String) }
@@ -49,9 +48,9 @@ module Dependabot
49
48
  if incorrectly_encoded_workflow_files.none?
50
49
  expected_paths =
51
50
  if directory == "/"
52
- File.join(directory, "action.yml") + " or /.github/workflows/<anything>.yml"
51
+ File.join(directory, MANIFEST_FILE_YML) + " or /#{CONFIG_YMLS}"
53
52
  else
54
- File.join(directory, "<anything>.yml")
53
+ File.join(directory, ANYTHING_YML)
55
54
  end
56
55
 
57
56
  raise(
@@ -75,16 +74,19 @@ module Dependabot
75
74
  # In the special case where the root directory is defined we also scan
76
75
  # the .github/workflows/ folder.
77
76
  if directory == "/"
78
- @workflow_files += [fetch_file_if_present("action.yml"), fetch_file_if_present("action.yaml")].compact
77
+ @workflow_files += [
78
+ fetch_file_if_present(MANIFEST_FILE_YML),
79
+ fetch_file_if_present(MANIFEST_FILE_YAML)
80
+ ].compact
79
81
 
80
- workflows_dir = ".github/workflows"
82
+ workflows_dir = WORKFLOW_DIRECTORY
81
83
  else
82
84
  workflows_dir = "."
83
85
  end
84
86
 
85
87
  @workflow_files +=
86
88
  repo_contents(dir: workflows_dir, raise_errors: false)
87
- .select { |f| f.type == "file" && f.name.match?(FILENAME_PATTERN) }
89
+ .select { |f| f.type == "file" && f.name.match?(MANIFEST_FILE_PATTERN) }
88
90
  .map { |f| fetch_file_from_host("#{workflows_dir}/#{f.name}") }
89
91
  end
90
92
 
@@ -8,7 +8,9 @@ require "dependabot/dependency"
8
8
  require "dependabot/errors"
9
9
  require "dependabot/file_parsers"
10
10
  require "dependabot/file_parsers/base"
11
+ require "dependabot/github_actions/constants"
11
12
  require "dependabot/github_actions/version"
13
+ require "dependabot/github_actions/package_manager"
12
14
 
13
15
  # For docs, see
14
16
  # https://help.github.com/en/articles/configuring-a-workflow#referencing-actions-in-your-workflow
@@ -20,13 +22,6 @@ module Dependabot
20
22
 
21
23
  require "dependabot/file_parsers/base/dependency_set"
22
24
 
23
- GITHUB_REPO_REFERENCE = %r{
24
- ^(?<owner>[\w.-]+)/
25
- (?<repo>[\w.-]+)
26
- (?<path>/[^\@]+)?
27
- @(?<ref>.+)
28
- }x
29
-
30
25
  sig { override.returns(T::Array[Dependabot::Dependency]) }
31
26
  def parse
32
27
  dependency_set = DependencySet.new
@@ -35,11 +30,33 @@ module Dependabot
35
30
  dependency_set += workfile_file_dependencies(file)
36
31
  end
37
32
 
33
+ dependencies_without_version = dependency_set.dependencies.select { |dep| dep.version.nil? }
34
+ unless dependencies_without_version.empty?
35
+ raise UnresolvableVersionError,
36
+ dependencies_without_version.map(&:name)
37
+ end
38
+
38
39
  dependency_set.dependencies
39
40
  end
40
41
 
42
+ sig { returns(Ecosystem) }
43
+ def ecosystem
44
+ @ecosystem ||= T.let(
45
+ Ecosystem.new(
46
+ name: ECOSYSTEM,
47
+ package_manager: package_manager
48
+ ),
49
+ T.nilable(Ecosystem)
50
+ )
51
+ end
52
+
41
53
  private
42
54
 
55
+ sig { returns(Ecosystem::VersionManager) }
56
+ def package_manager
57
+ @package_manager ||= T.let(PackageManager.new, T.nilable(Dependabot::GithubActions::PackageManager))
58
+ end
59
+
43
60
  sig { params(file: Dependabot::DependencyFile).returns(Dependabot::FileParsers::Base::DependencySet) }
44
61
  def workfile_file_dependencies(file)
45
62
  dependency_set = DependencySet.new
@@ -88,20 +105,20 @@ module Dependabot
88
105
 
89
106
  sig { params(file: Dependabot::DependencyFile, string: String).returns(Dependabot::Dependency) }
90
107
  def build_github_dependency(file, string)
91
- unless source&.hostname == "github.com"
108
+ unless source&.hostname == GITHUB_COM
92
109
  dep = github_dependency(file, string, T.must(source).hostname)
93
110
  git_checker = Dependabot::GitCommitChecker.new(dependency: dep, credentials: credentials)
94
111
  return dep if git_checker.git_repo_reachable?
95
112
  end
96
113
 
97
- github_dependency(file, string, "github.com")
114
+ github_dependency(file, string, GITHUB_COM)
98
115
  end
99
116
 
100
117
  sig { params(file: Dependabot::DependencyFile, string: String, hostname: String).returns(Dependabot::Dependency) }
101
118
  def github_dependency(file, string, hostname)
102
119
  details = T.must(string.match(GITHUB_REPO_REFERENCE)).named_captures
103
- name = "#{details.fetch('owner')}/#{details.fetch('repo')}"
104
- ref = details.fetch("ref")
120
+ name = "#{details.fetch(OWNER_KEY)}/#{details.fetch(REPO_KEY)}"
121
+ ref = details.fetch(REF_KEY)
105
122
  version = version_class.new(ref).to_s if version_class.correct?(ref)
106
123
  Dependency.new(
107
124
  name: name,
@@ -118,7 +135,7 @@ module Dependabot
118
135
  file: file.name,
119
136
  metadata: { declaration_string: string }
120
137
  }],
121
- package_manager: "github_actions"
138
+ package_manager: PackageManager::NAME
122
139
  )
123
140
  end
124
141
 
@@ -133,11 +150,11 @@ module Dependabot
133
150
 
134
151
  sig { params(json_object: T::Hash[String, T.untyped], found_uses: T::Array[String]).returns(T::Array[String]) }
135
152
  def deep_fetch_uses_from_hash(json_object, found_uses)
136
- if json_object.key?("uses")
137
- found_uses << json_object["uses"]
138
- elsif json_object.key?("steps")
153
+ if json_object.key?(USES_KEY)
154
+ found_uses << json_object[USES_KEY]
155
+ elsif json_object.key?(STEPS_KEY)
139
156
  # Bypass other fields as uses are under steps if they exist
140
- deep_fetch_uses(json_object["steps"], found_uses)
157
+ deep_fetch_uses(json_object[STEPS_KEY], found_uses)
141
158
  else
142
159
  json_object.values.flat_map { |obj| deep_fetch_uses(obj, found_uses) }
143
160
  end
@@ -6,6 +6,7 @@ require "sorbet-runtime"
6
6
  require "dependabot/errors"
7
7
  require "dependabot/file_updaters"
8
8
  require "dependabot/file_updaters/base"
9
+ require "dependabot/github_actions/constants"
9
10
 
10
11
  module Dependabot
11
12
  module GithubActions
@@ -16,10 +17,10 @@ module Dependabot
16
17
  def self.updated_files_regex
17
18
  [
18
19
  # Matches .yml or .yaml files in the .github/workflows directories
19
- %r{\.github/workflows/.+\.ya?ml$},
20
+ WORKFLOW_YAML_REGEX,
20
21
 
21
22
  # Matches .yml or .yaml files in the root directory or any subdirectory
22
- %r{(?:^|/).+\.ya?ml$}
23
+ ALL_YAML_FILES
23
24
  ]
24
25
  end
25
26
 
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "sorbet-runtime"
5
-
5
+ require "dependabot/github_actions/constants"
6
6
  require "dependabot/metadata_finders"
7
7
  require "dependabot/metadata_finders/base"
8
8
 
@@ -19,7 +19,7 @@ module Dependabot
19
19
 
20
20
  url =
21
21
  if info.nil?
22
- "https://github.com/#{dependency.name}"
22
+ "https://#{GITHUB_COM}/#{dependency.name}"
23
23
  else
24
24
  info[:url] || info.fetch("url")
25
25
  end
@@ -0,0 +1,40 @@
1
+ # typed: strong
2
+ # frozen_string_literal: true
3
+
4
+ require "sorbet-runtime"
5
+ require "dependabot/github_actions/constants"
6
+ require "dependabot/github_actions/version"
7
+ require "dependabot/ecosystem"
8
+ require "dependabot/github_actions/requirement"
9
+
10
+ module Dependabot
11
+ module GithubActions
12
+ class PackageManager < Dependabot::Ecosystem::VersionManager
13
+ extend T::Sig
14
+
15
+ # The package manager name for GitHub Actions
16
+ NAME = T.let("github_actions", String)
17
+
18
+ # The version of the package manager
19
+ VERSION = T.let("1.0.0", String)
20
+
21
+ sig { void }
22
+ def initialize
23
+ super(
24
+ name: NAME,
25
+ version: Version.new(VERSION)
26
+ )
27
+ end
28
+
29
+ sig { override.returns(T::Boolean) }
30
+ def deprecated?
31
+ false
32
+ end
33
+
34
+ sig { override.returns(T::Boolean) }
35
+ def unsupported?
36
+ false
37
+ end
38
+ end
39
+ end
40
+ end
@@ -4,6 +4,7 @@
4
4
  require "sorbet-runtime"
5
5
 
6
6
  require "dependabot/errors"
7
+ require "dependabot/github_actions/constants"
7
8
  require "dependabot/github_actions/requirement"
8
9
  require "dependabot/github_actions/version"
9
10
  require "dependabot/update_checkers"
@@ -3,6 +3,7 @@
3
3
 
4
4
  # These all need to be required so the various classes can be registered in a
5
5
  # lookup table of package manager names to concrete classes.
6
+ require "dependabot/github_actions/constants"
6
7
  require "dependabot/github_actions/file_fetcher"
7
8
  require "dependabot/github_actions/file_parser"
8
9
  require "dependabot/github_actions/update_checker"
@@ -10,6 +11,7 @@ require "dependabot/github_actions/file_updater"
10
11
  require "dependabot/github_actions/metadata_finder"
11
12
  require "dependabot/github_actions/requirement"
12
13
  require "dependabot/github_actions/version"
14
+ require "dependabot/github_actions/package_manager"
13
15
 
14
16
  require "dependabot/pull_request_creator/labeler"
15
17
  Dependabot::PullRequestCreator::Labeler
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-github_actions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.290.0
4
+ version: 0.292.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-12 00:00:00.000000000 Z
11
+ date: 2025-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dependabot-common
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.290.0
19
+ version: 0.292.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.290.0
26
+ version: 0.292.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: debug
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -243,10 +243,12 @@ extensions: []
243
243
  extra_rdoc_files: []
244
244
  files:
245
245
  - lib/dependabot/github_actions.rb
246
+ - lib/dependabot/github_actions/constants.rb
246
247
  - lib/dependabot/github_actions/file_fetcher.rb
247
248
  - lib/dependabot/github_actions/file_parser.rb
248
249
  - lib/dependabot/github_actions/file_updater.rb
249
250
  - lib/dependabot/github_actions/metadata_finder.rb
251
+ - lib/dependabot/github_actions/package_manager.rb
250
252
  - lib/dependabot/github_actions/requirement.rb
251
253
  - lib/dependabot/github_actions/update_checker.rb
252
254
  - lib/dependabot/github_actions/version.rb
@@ -255,7 +257,7 @@ licenses:
255
257
  - MIT
256
258
  metadata:
257
259
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
258
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.290.0
260
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.292.0
259
261
  post_install_message:
260
262
  rdoc_options: []
261
263
  require_paths:
@@ -271,7 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
271
273
  - !ruby/object:Gem::Version
272
274
  version: 3.1.0
273
275
  requirements: []
274
- rubygems_version: 3.5.9
276
+ rubygems_version: 3.5.22
275
277
  signing_key:
276
278
  specification_version: 4
277
279
  summary: Provides Dependabot support for GitHub Actions