licensed 2.6.1 → 2.6.2

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: 399ad5d09b5d158f3c1a51aa719dd0f353bf9a4714d495d3998dd0e38c6b7009
4
- data.tar.gz: 72a61d16fa72990cb12421bb29db09c80c15436eb5a85f962ffab089e78f7c99
3
+ metadata.gz: 01feaa48f4c38ee8a812dd909a05e46e0355c4a7e30add873c1410dca715df8f
4
+ data.tar.gz: ec09f82ba5ae08100b9c7e15631be48f6f14a302c26809172d0eb87a820b885a
5
5
  SHA512:
6
- metadata.gz: 4c267eaf2523970f7e890e8e08eca972fa07cf3b616f66dc68ba010677014cd3ab8f08f7d7496c22345b4cd9801e6386015ff13e0064eed5ee850c12b068f8a5
7
- data.tar.gz: ea1f68a031f398a43036648850325f34b44f28e5cfb9da630cc6d6bbdbe8e3b82b5d467b030256d4ed78bb4dda7e7c5820f5dd7fb97af08afe10105db8fc2946
6
+ metadata.gz: '03822f158d7aa6027eb6eb86856b271452bf0cd3f2bf202754a1391b65eee84c4c752fc857c40d5f4bac88dfd1490415cc0813a5003db3b127598e661a4360b2'
7
+ data.tar.gz: c7393d9cbd363f0dfc1dd5a919b990c31545bf9c6c6f7322174736bdba3dfad1fa30f579f63a6fe8374c5a931fe96c2b264277f717ceccc9dc5d9ebb0afdc600
@@ -20,6 +20,11 @@ jobs:
20
20
  uses: actions/setup-ruby@v1
21
21
  with:
22
22
  ruby-version: 2.6.x
23
+ - run: bundle lock
24
+ - uses: actions/cache@preview
25
+ with:
26
+ path: vendor/gems
27
+ key: ${{ runner.os }}-gem-2.6.x-${{ hashFiles(format('{0}{1}', github.workspace, '/Gemfile.lock')) }}
23
28
  - name: Bootstrap
24
29
  run: script/bootstrap
25
30
  - name: Set up fixtures
@@ -42,6 +47,11 @@ jobs:
42
47
  run: |
43
48
  yes | gem uninstall bundler --all
44
49
  gem install bundler -v "${{ matrix.bundler }}"
50
+ - run: bundle lock
51
+ - uses: actions/cache@preview
52
+ with:
53
+ path: vendor/gems
54
+ key: ${{ runner.os }}-gem-2.6.x-${{ hashFiles(format('{0}{1}', github.workspace, '/Gemfile.lock')) }}
45
55
  - name: Bootstrap
46
56
  run: script/bootstrap
47
57
  - name: Set up fixtures
@@ -66,6 +76,15 @@ jobs:
66
76
  with:
67
77
  ghc-version: ${{ matrix.ghc }}
68
78
  cabal-version: ${{ matrix.cabal }}
79
+ - run: bundle lock
80
+ - uses: actions/cache@preview
81
+ with:
82
+ path: vendor/gems
83
+ key: ${{ runner.os }}-gem-2.6.x-${{ hashFiles(format('{0}{1}', github.workspace, '/Gemfile.lock')) }}
84
+ - uses: actions/cache@preview
85
+ with:
86
+ path: test/fixtures/cabal/dist-newstyle
87
+ key: ${{ runner.os }}-fixtures-cabal-${{ matrix.ghc }}-${{ matrix.cabal }}-${{ hashFiles(format('{0}{1}', github.workspace, '/test/fixtures/cabal/app.cabal')) }}
69
88
  - name: Bootstrap
70
89
  run: script/bootstrap
71
90
  - name: Set up fixtures
@@ -86,6 +105,11 @@ jobs:
86
105
  ruby-version: ${{matrix.ruby}}
87
106
  - name: Set up Bundler
88
107
  run: gem install bundler
108
+ - run: bundle lock
109
+ - uses: actions/cache@preview
110
+ with:
111
+ path: vendor/gems
112
+ key: ${{ runner.os }}-gem-${{ matrix.ruby }}-${{ hashFiles(format('{0}{1}', github.workspace, '/Gemfile.lock')) }}
89
113
  - name: Bootstrap
90
114
  run: script/bootstrap
91
115
  - name: Build and lint
@@ -105,6 +129,11 @@ jobs:
105
129
  uses: actions/setup-ruby@v1
106
130
  with:
107
131
  ruby-version: 2.6.x
132
+ - run: bundle lock
133
+ - uses: actions/cache@preview
134
+ with:
135
+ path: vendor/gems
136
+ key: ${{ runner.os }}-gem-2.6.x-${{ hashFiles(format('{0}{1}', github.workspace, '/Gemfile.lock')) }}
108
137
  - name: Bootstrap
109
138
  run: script/bootstrap
110
139
  - name: Set up fixtures
@@ -127,6 +156,11 @@ jobs:
127
156
  uses: actions/setup-ruby@v1
128
157
  with:
129
158
  ruby-version: 2.6.x
159
+ - run: bundle lock
160
+ - uses: actions/cache@preview
161
+ with:
162
+ path: vendor/gems
163
+ key: ${{ runner.os }}-gem-2.6.x-${{ hashFiles(format('{0}{1}', github.workspace, '/Gemfile.lock')) }}
130
164
  - name: Bootstrap
131
165
  run: script/bootstrap
132
166
  - name: Set up fixtures
@@ -149,6 +183,11 @@ jobs:
149
183
  uses: actions/setup-ruby@v1
150
184
  with:
151
185
  ruby-version: 2.6.x
186
+ - run: bundle lock
187
+ - uses: actions/cache@preview
188
+ with:
189
+ path: vendor/gems
190
+ key: ${{ runner.os }}-gem-2.6.x-${{ hashFiles(format('{0}{1}', github.workspace, '/Gemfile.lock')) }}
152
191
  - name: Bootstrap
153
192
  run: script/bootstrap
154
193
  - name: Set up fixtures
@@ -164,6 +203,11 @@ jobs:
164
203
  uses: actions/setup-ruby@v1
165
204
  with:
166
205
  ruby-version: 2.6.x
206
+ - run: bundle lock
207
+ - uses: actions/cache@preview
208
+ with:
209
+ path: vendor/gems
210
+ key: ${{ runner.os }}-gem-2.6.x-${{ hashFiles(format('{0}{1}', github.workspace, '/Gemfile.lock')) }}
167
211
  - name: Bootstrap
168
212
  run: script/bootstrap
169
213
  - name: Gradle version
@@ -187,6 +231,11 @@ jobs:
187
231
  uses: actions/setup-ruby@v1
188
232
  with:
189
233
  ruby-version: 2.6.x
234
+ - run: bundle lock
235
+ - uses: actions/cache@preview
236
+ with:
237
+ path: vendor/gems
238
+ key: ${{ runner.os }}-gem-2.6.x-${{ hashFiles(format('{0}{1}', github.workspace, '/Gemfile.lock')) }}
190
239
  - name: Bootstrap
191
240
  run: script/bootstrap
192
241
  - name: Install virtualenv
@@ -209,6 +258,11 @@ jobs:
209
258
  uses: actions/setup-ruby@v1
210
259
  with:
211
260
  ruby-version: 2.6.x
261
+ - run: bundle lock
262
+ - uses: actions/cache@preview
263
+ with:
264
+ path: vendor/gems
265
+ key: ${{ runner.os }}-gem-2.6.x-${{ hashFiles(format('{0}{1}', github.workspace, '/Gemfile.lock')) }}
212
266
  - name: Bootstrap
213
267
  run: script/bootstrap
214
268
  - name: Install pipenv
@@ -233,6 +287,11 @@ jobs:
233
287
  uses: actions/setup-ruby@v1
234
288
  with:
235
289
  ruby-version: 2.6.x
290
+ - run: bundle lock
291
+ - uses: actions/cache@preview
292
+ with:
293
+ path: vendor/gems
294
+ key: ${{ runner.os }}-gem-2.6.x-${{ hashFiles(format('{0}{1}', github.workspace, '/Gemfile.lock')) }}
236
295
  - name: Bootstrap
237
296
  run: script/bootstrap
238
297
  - name: Set up fixtures
@@ -256,6 +315,11 @@ jobs:
256
315
  uses: actions/setup-ruby@v1
257
316
  with:
258
317
  ruby-version: 2.6.x
318
+ - run: bundle lock
319
+ - uses: actions/cache@preview
320
+ with:
321
+ path: vendor/gems
322
+ key: ${{ runner.os }}-gem-2.6.x-${{ hashFiles(format('{0}{1}', github.workspace, '/Gemfile.lock')) }}
259
323
  - name: Bootstrap
260
324
  run: script/bootstrap
261
325
  - name: Set up fixtures
@@ -271,6 +335,11 @@ jobs:
271
335
  uses: actions/setup-ruby@v1
272
336
  with:
273
337
  ruby-version: 2.6.x
338
+ - run: bundle lock
339
+ - uses: actions/cache@preview
340
+ with:
341
+ path: vendor/gems
342
+ key: ${{ runner.os }}-gem-2.6.x-${{ hashFiles(format('{0}{1}', github.workspace, '/Gemfile.lock')) }}
274
343
  - name: Bootstrap
275
344
  run: script/bootstrap
276
345
  - name: Run tests
@@ -6,6 +6,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## 2.6.2
10
+ 2019-11-03
11
+
12
+ ### Changed
13
+ - A number of improvements to the go dependency enumerator
14
+ - use `go env GOPATH` as a default if no other GOPATH is found
15
+ - better compatibility with go modules when finding license content
16
+ - better compatibility with vendored go modules
17
+ - use a packages godoc.org page as it's homepage
18
+ - better checks for standard packages, reducing the amount of cached content
19
+
9
20
  ## 2.6.1
10
21
  2019-10-26
11
22
 
@@ -235,4 +246,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
235
246
 
236
247
  Initial release :tada:
237
248
 
238
- [Unreleased]: https://github.com/github/licensed/compare/2.6.1...HEAD
249
+ [Unreleased]: https://github.com/github/licensed/compare/2.6.2...HEAD
data/README.md CHANGED
@@ -65,8 +65,17 @@ See the [commands documentation](./docs/commands.md) for additional documentatio
65
65
 
66
66
  ### Automation
67
67
 
68
+ #### Bundler
69
+
68
70
  The [bundler-licensed plugin](https://github.com/sergey-alekseev/bundler-licensed) runs `licensed cache` automatically when using `bundler`. See the linked repo for usage and details.
69
71
 
72
+ #### GitHub Actions
73
+
74
+ The [licensed-ci](https://github.com/marketplace/actions/licensed-ci) GitHub Action runs `licensed` as part of an opinionated CI workflow and can be configured to run on any GitHub Action event. See the linked actions for usage and details.
75
+
76
+ The [setup-licensed](https://github.com/marketplace/actions/setup-github-licensed) GitHub Action installs `licensed` to the workflow environment. See the linked actions for usage and details.
77
+ - This action is intended for projects that don't have a ruby installation setup. If your workflow has ruby setup please install `licensed` via `Gemfile` + `bundle install` or with `gem install`.
78
+
70
79
  ### Configuration
71
80
 
72
81
  All commands, except `version`, accept a `-c|--config` option to specify a path to a configuration file or directory.
@@ -40,3 +40,13 @@ The go source supports multiple versioning strategies to determine if cached dep
40
40
  ```yaml
41
41
  version_strategy: contents
42
42
  ```
43
+
44
+ #### Go modules support
45
+
46
+ The go source fully supports go modules, provided that the calling environment has been configured to use go modules.
47
+
48
+ The go source can be configured to support vendored go modules
49
+ ```yaml
50
+ go:
51
+ mod: vendor
52
+ ```
@@ -20,7 +20,7 @@ module Licensed
20
20
  search_root: search_root.to_s,
21
21
  metadata: {
22
22
  "type" => Dep.type,
23
- "homepage" => "https://#{package[:name]}"
23
+ "homepage" => homepage(package[:name])
24
24
  }
25
25
  )
26
26
  end
@@ -40,10 +40,17 @@ module Licensed
40
40
  end
41
41
  end
42
42
 
43
+ # Returns the godoc.org page for a package.
44
+ def homepage(import_path)
45
+ return unless import_path
46
+ "https://godoc.org/#{import_path}"
47
+ end
48
+
43
49
  # Returns whether the package is part of the go std list. Replaces
44
50
  # "golang.org" with "golang_org" to match packages listed in `go list std`
45
51
  # as "vendor/golang_org/*" but are vendored as "vendor/golang.org/*"
46
52
  def go_std_package?(import_path)
53
+ return true if go_std_packages.include? "vendor/#{import_path}"
47
54
  go_std_packages.include? "vendor/#{import_path.sub(/^golang.org/, "golang_org")}"
48
55
  end
49
56
 
@@ -17,13 +17,12 @@ module Licensed
17
17
  packages.map do |package|
18
18
  import_path = non_vendored_import_path(package["ImportPath"])
19
19
  error = package.dig("Error", "Err") if package["Error"]
20
- package_dir = package["Dir"]
21
20
 
22
21
  Dependency.new(
23
22
  name: import_path,
24
23
  version: package_version(package),
25
- path: package_dir,
26
- search_root: search_root(package_dir),
24
+ path: package["Dir"],
25
+ search_root: search_root(package),
27
26
  errors: Array(error),
28
27
  metadata: {
29
28
  "type" => Go.type,
@@ -60,11 +59,14 @@ module Licensed
60
59
  # Returns the list of dependencies as returned by "go list -json -deps"
61
60
  # available in go 1.11
62
61
  def go_list_deps
62
+ args = ["-deps"]
63
+ args << "-mod=vendor" if config.dig("go", "mod") == "vendor"
64
+
63
65
  # the CLI command returns packages in a pretty-printed JSON format but
64
66
  # not separated by commas. this gsub adds commas after all non-indented
65
67
  # "}" that close root level objects.
66
68
  # (?!\z) uses negative lookahead to not match the final "}"
67
- deps = package_info_command("-deps").gsub(/^}(?!\z)$/m, "},")
69
+ deps = package_info_command(*args).gsub(/^}(?!\z)$/m, "},")
68
70
  JSON.parse("[#{deps}]")
69
71
  end
70
72
 
@@ -74,14 +76,23 @@ module Licensed
74
76
  # package - package to check as part of the go standard library
75
77
  def go_std_package?(package)
76
78
  return false unless package
79
+
80
+ # return true if package self-identifies
77
81
  return true if package["Standard"]
78
82
 
79
83
  import_path = package["ImportPath"]
80
84
  return false unless import_path
81
85
 
86
+ # true if go standard packages includes the import path as given
87
+ return true if go_std_packages.include?(import_path)
88
+
89
+ # additional checks are only for vendored dependencies - return false
90
+ # if package isn't vendored
91
+ return false unless vendored_path?(import_path)
92
+
82
93
  # modify the import path to look like the import path `go list` returns for vendored std packages
83
- std_vendor_import_path = import_path.sub(%r{^#{root_package["ImportPath"]}/vendor/golang.org}, "vendor/golang_org")
84
- go_std_packages.include?(import_path) || go_std_packages.include?(std_vendor_import_path)
94
+ vendor_path = import_path.sub("#{root_package["ImportPath"]}/", "")
95
+ go_std_packages.include?(vendor_path) || go_std_packages.include?(vendor_path.sub("golang.org", "golang_org"))
85
96
  end
86
97
 
87
98
  # Returns whether the package is local to the current project
@@ -121,28 +132,29 @@ module Licensed
121
132
  end
122
133
  end
123
134
 
124
- # Returns the homepage for a package import_path. Assumes that the
125
- # import path itself is a url domain and path
135
+ # Returns the godoc.org page for a package.
126
136
  def homepage(import_path)
127
137
  return unless import_path
128
-
129
- # hacky but generally works due to go packages looking like
130
- # "github.com/..." or "golang.org/..."
131
- "https://#{import_path}"
138
+ "https://godoc.org/#{import_path}"
132
139
  end
133
140
 
134
141
  # Returns the root directory to search for a package license
135
142
  #
136
143
  # package - package object obtained from package_info
137
- def search_root(package_dir)
138
- return nil if package_dir.nil? || package_dir.empty?
144
+ def search_root(package)
145
+ return if package.nil?
139
146
 
140
147
  # search root choices:
141
- # 1. vendor folder if package is vendored
142
- # 2. GOPATH
143
- # 3. nil (no search up directory hierarchy)
144
- return package_dir.match("^(.*/vendor)/.*$")[1] if vendored_path?(package_dir)
145
- gopath
148
+ # 1. module directory if using go modules
149
+ # 2. vendor folder if package is vendored
150
+ # 3. package root value if available
151
+ # 4. GOPATH if the package directory is under the gopath
152
+ # 5. nil
153
+ return package.dig("Module", "Dir") if package["Module"]
154
+ return package["Dir"].match("^(.*/vendor)/.*$")[1] if vendored_path?(package["Dir"])
155
+ return package["Root"] if package["Root"]
156
+ return gopath if package["Dir"]&.start_with?(gopath)
157
+ nil
146
158
  end
147
159
 
148
160
  # Returns whether a package is vendored or not based on the package
@@ -150,7 +162,8 @@ module Licensed
150
162
  #
151
163
  # path - Package path to test
152
164
  def vendored_path?(path)
153
- path && path.include?("vendor/")
165
+ return false if path.nil?
166
+ path.start_with?(root_package["ImportPath"]) && path.include?("vendor/")
154
167
  end
155
168
 
156
169
  # Returns the import path parameter without the vendor component
@@ -196,17 +209,12 @@ module Licensed
196
209
  def gopath
197
210
  return @gopath if defined?(@gopath)
198
211
 
199
- path = config.dig("go", "GOPATH")
200
- @gopath = if path.nil? || path.empty?
201
- ENV["GOPATH"]
202
- else
203
- root = begin
204
- config.root
205
- rescue Licensed::Shell::Error
206
- Pathname.pwd
207
- end
208
- File.expand_path(path, root)
209
- end
212
+ @gopath = begin
213
+ path = config.dig("go", "GOPATH")
214
+ return File.expand_path(path, config.root) unless path.to_s.empty?
215
+ return ENV["GOPATH"] if ENV["GOPATH"]
216
+ Licensed::Shell.execute("go", "env", "GOPATH")
217
+ end
210
218
  end
211
219
 
212
220
  # Returns the current version of go available, as a Gem::Version
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module Licensed
3
- VERSION = "2.6.1".freeze
3
+ VERSION = "2.6.2".freeze
4
4
 
5
5
  def self.previous_major_versions
6
6
  major_version = Gem::Version.new(Licensed::VERSION).segments.first
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: licensed
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.1
4
+ version: 2.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-26 00:00:00.000000000 Z
11
+ date: 2019-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: licensee