chore: run linkinator on merges to master (#243)
This commit is contained in:
parent
a6082d158b
commit
584ad57d7d
|
@ -3,7 +3,7 @@
|
|||
build_file: "google-auth-library-ruby/.kokoro/trampoline.sh"
|
||||
|
||||
# Configure the docker image for kokoro-trampoline.
|
||||
# Dockerfile is maintained at https://github.com/googleapis/google-cloud-ruby/tree/master/.kokoro/docker/ruby-multi
|
||||
# Dockerfile is maintained at https://github.com/googleapis/google-cloud-ruby/tree/master/.kokoro/docker/multi
|
||||
env_vars: {
|
||||
key: "TRAMPOLINE_IMAGE"
|
||||
value: "gcr.io/cloud-devrel-kokoro-resources/yoshi-ruby/ruby-multi"
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
# Format: //devtools/kokoro/config/proto/build.proto
|
||||
|
||||
build_file: "google-auth-library-ruby/.kokoro/trampoline.sh"
|
||||
|
||||
# Configure the docker image for kokoro-trampoline.
|
||||
# Dockerfile is maintained at https://github.com/googleapis/google-cloud-ruby/tree/master/.kokoro/docker/multi-node
|
||||
env_vars: {
|
||||
key: "TRAMPOLINE_IMAGE"
|
||||
value: "gcr.io/cloud-devrel-kokoro-resources/yoshi-ruby/multi-node"
|
||||
}
|
||||
|
||||
env_vars: {
|
||||
key: "TRAMPOLINE_BUILD_FILE"
|
||||
value: "github/google-auth-library-ruby/.kokoro/build.sh"
|
||||
}
|
||||
|
||||
env_vars: {
|
||||
key: "TRAMPOLINE_SCRIPT"
|
||||
value: "trampoline_v1.py"
|
||||
}
|
||||
|
||||
env_vars: {
|
||||
key: "OS"
|
||||
value: "linux"
|
||||
}
|
||||
|
||||
env_vars: {
|
||||
key: "JOB_TYPE"
|
||||
value: "post"
|
||||
}
|
|
@ -178,7 +178,7 @@ access and refresh tokens. Two storage implementations are included:
|
|||
* Google::Auth::Stores::RedisTokenStore
|
||||
|
||||
Custom storage implementations can also be used. See
|
||||
[token_store.rb](lib/googleauth/token_store.rb) for additional details.
|
||||
[token_store.rb](https://googleapis.dev/ruby/googleauth/latest/Google/Auth/TokenStore.html) for additional details.
|
||||
|
||||
## Supported Ruby Versions
|
||||
|
||||
|
@ -206,7 +206,6 @@ hesitate to
|
|||
[ask questions](http://stackoverflow.com/questions/tagged/google-auth-library-ruby)
|
||||
about the client or APIs on [StackOverflow](http://stackoverflow.com).
|
||||
|
||||
[google-apis-ruby-client]: (https://github.com/google/google-api-ruby-client)
|
||||
[application default credentials]: (https://developers.google.com/accounts/docs/application-default-credentials)
|
||||
[contributing]: https://github.com/google/google-auth-library-ruby/tree/master/CONTRIBUTING.md
|
||||
[copying]: https://github.com/google/google-auth-library-ruby/tree/master/COPYING
|
||||
[application default credentials]: https://developers.google.com/accounts/docs/application-default-credentials
|
||||
[contributing]: https://github.com/googleapis/google-auth-library-ruby/tree/master/.github/CONTRIBUTING.md
|
||||
[copying]: https://github.com/googleapis/google-auth-library-ruby/tree/master/COPYING
|
||||
|
|
8
Rakefile
8
Rakefile
|
@ -71,6 +71,14 @@ namespace :kokoro do
|
|||
Rake::Task["ci"].invoke
|
||||
end
|
||||
|
||||
task :post do
|
||||
require_relative "rakelib/link_checker.rb"
|
||||
|
||||
link_checker = LinkChecker.new
|
||||
link_checker.run
|
||||
exit link_checker.exit_status
|
||||
end
|
||||
|
||||
task :nightly do
|
||||
Rake::Task["ci"].invoke
|
||||
end
|
||||
|
|
|
@ -47,7 +47,7 @@ module Google
|
|||
#
|
||||
# Use this to obtain the Application Default Credentials for accessing
|
||||
# Google APIs. Application Default Credentials are described in detail
|
||||
# at http://goo.gl/IUuyuX.
|
||||
# at https://cloud.google.com/docs/authentication/production.
|
||||
#
|
||||
# If supplied, scope is used to create the credentials instance, when it can
|
||||
# be applied. E.g, on google compute engine and for user credentials the
|
||||
|
|
|
@ -45,7 +45,7 @@ module Google
|
|||
# from credentials from a json key file downloaded from the developer
|
||||
# console (via 'Generate new Json Key').
|
||||
#
|
||||
# cf [Application Default Credentials](http://goo.gl/mkAHpZ)
|
||||
# cf [Application Default Credentials](https://cloud.google.com/docs/authentication/production)
|
||||
class ServiceAccountCredentials < Signet::OAuth2::Client
|
||||
TOKEN_CRED_URI = "https://www.googleapis.com/oauth2/v4/token".freeze
|
||||
extend CredentialsLoader
|
||||
|
@ -123,7 +123,7 @@ module Google
|
|||
# console (via 'Generate new Json Key'). It is not part of any OAuth2
|
||||
# flow, rather it creates a JWT and sends that as a credential.
|
||||
#
|
||||
# cf [Application Default Credentials](http://goo.gl/mkAHpZ)
|
||||
# cf [Application Default Credentials](https://cloud.google.com/docs/authentication/production)
|
||||
class ServiceAccountJwtHeaderCredentials
|
||||
JWT_AUD_URI_KEY = :jwt_aud_uri
|
||||
AUTH_METADATA_KEY = Signet::OAuth2::AUTH_METADATA_KEY
|
||||
|
|
|
@ -44,7 +44,7 @@ module Google
|
|||
# 'gcloud auth login' saves a file with these contents in well known
|
||||
# location
|
||||
#
|
||||
# cf [Application Default Credentials](http://goo.gl/mkAHpZ)
|
||||
# cf [Application Default Credentials](https://cloud.google.com/docs/authentication/production)
|
||||
class UserRefreshCredentials < Signet::OAuth2::Client
|
||||
TOKEN_CRED_URI = "https://oauth2.googleapis.com/token".freeze
|
||||
AUTHORIZATION_URI = "https://accounts.google.com/o/oauth2/auth".freeze
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
require "open3"
|
||||
|
||||
class LinkChecker
|
||||
def initialize
|
||||
@failed = false
|
||||
end
|
||||
|
||||
def run
|
||||
job_info
|
||||
git_commit = ENV.fetch "KOKORO_GITHUB_COMMIT", "master"
|
||||
|
||||
markdown_files = Dir.glob "**/*.md"
|
||||
broken_markdown_links = check_links markdown_files,
|
||||
"https://github.com/googleapis/google-auth-library-ruby/tree/#{git_commit}",
|
||||
" --skip '^(?!(\\Wruby.*google|.*google.*\\Wruby|.*cloud\\.google\\.com))'"
|
||||
|
||||
broken_devsite_links = check_links ["googleauth"],
|
||||
"https://googleapis.dev/ruby",
|
||||
"/latest/ --recurse --skip https:.*github.*"
|
||||
|
||||
puts_broken_links broken_markdown_links
|
||||
puts_broken_links broken_devsite_links
|
||||
end
|
||||
|
||||
def check_links location_list, base, tail
|
||||
broken_links = Hash.new { |h, k| h[k] = [] }
|
||||
location_list.each do |location|
|
||||
out, err, st = Open3.capture3 "npx linkinator #{base}/#{location}#{tail}"
|
||||
puts out
|
||||
unless st.to_i.zero?
|
||||
@failed = true
|
||||
puts err
|
||||
end
|
||||
checked_links = out.split "\n"
|
||||
checked_links.select! { |link| link =~ /\[\d+\]/ && !link.include?("[200]") }
|
||||
unless checked_links.empty?
|
||||
@failed = true
|
||||
broken_links[location] += checked_links
|
||||
end
|
||||
end
|
||||
broken_links
|
||||
end
|
||||
|
||||
def puts_broken_links link_hash
|
||||
link_hash.each do |location, links|
|
||||
puts "#{location} contains the following broken links:"
|
||||
links.each { |link| puts " #{link}" }
|
||||
puts ""
|
||||
end
|
||||
end
|
||||
|
||||
def job_info
|
||||
line_length = "Using Ruby - #{RUBY_VERSION}".length + 8
|
||||
puts ""
|
||||
puts "#" * line_length
|
||||
puts "### Using Ruby - #{RUBY_VERSION} ###"
|
||||
puts "#" * line_length
|
||||
puts ""
|
||||
end
|
||||
|
||||
def exit_status
|
||||
@failed ? 1 : 0
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue