dependabot-github_actions 0.291.0 → 0.293.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7526b6dc97e519c47294f5c251c0fff5f893069662464e86c9ffaff188ffde1
4
- data.tar.gz: 16e683adfe613d60ae5c290c7654bead63b66d2eaf0ec4f9b2e6685feecdddca
3
+ metadata.gz: 97a39fd214b18afb927295d590e8ea8e3270015da3998b80a85106ae9cc203c2
4
+ data.tar.gz: 8b63e4e18e5f3c4695b70c8a8e4a1c7083e4d8bfabe1ac14d78b736150a71935
5
5
  SHA512:
6
- metadata.gz: 05ab5a39956dbc0ce6a25a91c0a180337abc89c5c7d82d99cc1ef8d77b94beae073d5d8eefc741b160134008b1034fc5fb4a8f34fe2a4f60f86f3735f9a921d6
7
- data.tar.gz: 54e9c432648188d4e7e36e6e5c663e495504d6979008179e826b49d2dadd8ac59b7a91a9cfb029ac20c6d5c5b6c812a4e518e7a0d7cc887b4b0d48b5100511b6
6
+ metadata.gz: 7c926a9ef211db6152426254d7926536d6cb3116b48089bab873a1e0a99bcd509f05c5daf46ea6005334c8c3f0470a6650c9323568ea2a12dd7f150bb26ade7c
7
+ data.tar.gz: e9ba4aaede0323e01bc3abc8792bb5b1327981a44ea91650b9d69ac87166260177b1b6ab1452f9e103bf6125860ae6074bc2dc830d0827ae36494d9fc29a9252
@@ -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,17 +30,27 @@ module Dependabot
35
30
  dependency_set += workfile_file_dependencies(file)
36
31
  end
37
32
 
38
- dependencies_without_version = dependency_set.dependencies.select { |dep| dep.version.nil? }
39
- unless dependencies_without_version.empty?
40
- raise UnresolvableVersionError,
41
- dependencies_without_version.map(&:name)
42
- end
43
-
44
33
  dependency_set.dependencies
45
34
  end
46
35
 
36
+ sig { returns(Ecosystem) }
37
+ def ecosystem
38
+ @ecosystem ||= T.let(
39
+ Ecosystem.new(
40
+ name: ECOSYSTEM,
41
+ package_manager: package_manager
42
+ ),
43
+ T.nilable(Ecosystem)
44
+ )
45
+ end
46
+
47
47
  private
48
48
 
49
+ sig { returns(Ecosystem::VersionManager) }
50
+ def package_manager
51
+ @package_manager ||= T.let(PackageManager.new, T.nilable(Dependabot::GithubActions::PackageManager))
52
+ end
53
+
49
54
  sig { params(file: Dependabot::DependencyFile).returns(Dependabot::FileParsers::Base::DependencySet) }
50
55
  def workfile_file_dependencies(file)
51
56
  dependency_set = DependencySet.new
@@ -94,20 +99,20 @@ module Dependabot
94
99
 
95
100
  sig { params(file: Dependabot::DependencyFile, string: String).returns(Dependabot::Dependency) }
96
101
  def build_github_dependency(file, string)
97
- unless source&.hostname == "github.com"
102
+ unless source&.hostname == GITHUB_COM
98
103
  dep = github_dependency(file, string, T.must(source).hostname)
99
104
  git_checker = Dependabot::GitCommitChecker.new(dependency: dep, credentials: credentials)
100
105
  return dep if git_checker.git_repo_reachable?
101
106
  end
102
107
 
103
- github_dependency(file, string, "github.com")
108
+ github_dependency(file, string, GITHUB_COM)
104
109
  end
105
110
 
106
111
  sig { params(file: Dependabot::DependencyFile, string: String, hostname: String).returns(Dependabot::Dependency) }
107
112
  def github_dependency(file, string, hostname)
108
113
  details = T.must(string.match(GITHUB_REPO_REFERENCE)).named_captures
109
- name = "#{details.fetch('owner')}/#{details.fetch('repo')}"
110
- ref = details.fetch("ref")
114
+ name = "#{details.fetch(OWNER_KEY)}/#{details.fetch(REPO_KEY)}"
115
+ ref = details.fetch(REF_KEY)
111
116
  version = version_class.new(ref).to_s if version_class.correct?(ref)
112
117
  Dependency.new(
113
118
  name: name,
@@ -124,7 +129,7 @@ module Dependabot
124
129
  file: file.name,
125
130
  metadata: { declaration_string: string }
126
131
  }],
127
- package_manager: "github_actions"
132
+ package_manager: PackageManager::NAME
128
133
  )
129
134
  end
130
135
 
@@ -139,11 +144,11 @@ module Dependabot
139
144
 
140
145
  sig { params(json_object: T::Hash[String, T.untyped], found_uses: T::Array[String]).returns(T::Array[String]) }
141
146
  def deep_fetch_uses_from_hash(json_object, found_uses)
142
- if json_object.key?("uses")
143
- found_uses << json_object["uses"]
144
- elsif json_object.key?("steps")
147
+ if json_object.key?(USES_KEY)
148
+ found_uses << json_object[USES_KEY]
149
+ elsif json_object.key?(STEPS_KEY)
145
150
  # Bypass other fields as uses are under steps if they exist
146
- deep_fetch_uses(json_object["steps"], found_uses)
151
+ deep_fetch_uses(json_object[STEPS_KEY], found_uses)
147
152
  else
148
153
  json_object.values.flat_map { |obj| deep_fetch_uses(obj, found_uses) }
149
154
  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.291.0
4
+ version: 0.293.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-19 00:00:00.000000000 Z
11
+ date: 2025-01-16 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.291.0
19
+ version: 0.293.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.291.0
26
+ version: 0.293.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.291.0
260
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.293.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