diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 5a74326e..21737fc5 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -14,19 +14,32 @@ jobs: runs-on: ${{ matrix.os_and_command.os }} strategy: matrix: - ruby: [ '2.5', '2.6', '2.7', '3.0', '3.1', 'ruby-head', 'truffleruby-head' ] + ruby: [ '2.5', '2.6', '2.7', '3.0', '3.1', 'ruby-head' ] + # The k0s script does more testing but needs docker, only works on ubuntu. os_and_command: - - os: 'macos-latest' + - os: macos-latest + command: 'env TESTOPTS="--verbose" bundle exec rake test' + - os: windows-latest command: 'env TESTOPTS="--verbose" bundle exec rake test' - os: ubuntu-latest # Sometimes minitest starts and then just hangs printing nothing. # Github by default kills after 6hours(!). Hopefully SIGTERM may let it print some details? command: 'timeout --signal=TERM 3m env TESTOPTS="--verbose" test/config/update_certs_k0s.rb' include: - # run rubocop against lowest supported ruby - - os: ubuntu-latest - ruby: '2.5' - command: 'bundle exec rake rubocop' + # As of 2022 Aug, truffleruby-dev-builder had no build for windows. + - ruby: 'truffleruby-head' + os_and_command: + - os: macos-latest + command: 'env TESTOPTS="--verbose" bundle exec rake test' + - ruby: 'truffleruby-head' + os_and_command: + os: ubuntu-latest + command: 'timeout --signal=TERM 3m env TESTOPTS="--verbose" test/config/update_certs_k0s.rb' + # Run rubocop in 1 job only, against lowest supported ruby. + - ruby: '2.5' + os_and_command: + - os: ubuntu-latest + command: 'bundle exec rake rubocop' name: ${{ matrix.os_and_command.os }} ${{ matrix.ruby }} rake ${{ matrix.os_and_command.command }} steps: - uses: actions/checkout@v2 @@ -35,7 +48,6 @@ jobs: with: ruby-version: ${{ matrix.ruby }} bundler-cache: false # disable running 'bundle install' and caching installed gems see https://github.com/httprb/http/issues/572 - - run: gem install rake bundler - run: bundle install - run: ${{ matrix.os_and_command.command }} timeout-minutes: 10 diff --git a/kubeclient.gemspec b/kubeclient.gemspec index cf3100a5..8bc0717b 100644 --- a/kubeclient.gemspec +++ b/kubeclient.gemspec @@ -30,6 +30,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency('mocha', '~> 1.5') spec.add_development_dependency 'openid_connect', '~> 1.1' spec.add_development_dependency 'net-smtp' + # needed on Windows, at least for openid_connect + spec.add_development_dependency 'tzinfo-data' spec.add_dependency 'faraday', '~> 1.1' spec.add_dependency 'faraday_middleware', '~> 1.0' diff --git a/lib/kubeclient.rb b/lib/kubeclient.rb index add931f4..cf122938 100644 --- a/lib/kubeclient.rb +++ b/lib/kubeclient.rb @@ -482,7 +482,8 @@ def delete_entity(resource_name, name, namespace = nil, delete_options: {}) # :orphan_dependents (bool) - should the dependent objects be orphaned # :propagation_policy (string) - one of Foreground|Background|Orphan # :resource_version (string) - sets a limit on the resource versions that can be served - # :resource_version_match (string) - determines how the resource_version constraint will be applied + # :resource_version_match (string) - determines how the resource_version constraint + # will be applied. # :timeout_seconds (integer) - limits the duraiton of the call # :continue (string) - a token used to retrieve the next chunk of entities # :as (:raw|:ros) - defaults to :ros @@ -761,7 +762,7 @@ def http_options(uri) http_proxy_uri: @http_proxy_uri, http_max_redirects: http_max_redirects, bearer_token_file: @auth_options[:bearer_token_file], - bearer_token: @auth_options[:bearer_token], + bearer_token: @auth_options[:bearer_token] } if uri.scheme == 'https' diff --git a/test/test_watch.rb b/test/test_watch.rb index 9ffe5c03..1ca07f88 100644 --- a/test/test_watch.rb +++ b/test/test_watch.rb @@ -113,18 +113,18 @@ def test_watch_pod_api_bearer_token_file_success watcher = client.watch_pods(as: :raw) begin - file.write("valid_token") + file.write('valid_token') file.rewind stub_token = stub_request(:get, %r{/watch/pods}) - .with(headers: { Authorization: 'Bearer valid_token' }) - .to_return(body: open_test_file('watch_stream.json'), status: 200) + .with(headers: { Authorization: 'Bearer valid_token' }) + .to_return(body: open_test_file('watch_stream.json'), status: 200) got = nil watcher.each { |notice| got = notice } assert_match(/\A{"type":"DELETED"/, got) remove_request_stub(stub_token) - file.write("rotated_token") + file.write('rotated_token') file.close stub_request(:get, %r{/watch/pods}) .with(headers: { Authorization: 'Bearer rotated_token' }) @@ -134,8 +134,8 @@ def test_watch_pod_api_bearer_token_file_success watcher.each { |notice| got = notice } assert_match(/\A{"type":"DELETED"/, got) ensure - file.close - file.unlink # deletes the temp file + file.close + file.unlink # deletes the temp file end end @@ -145,16 +145,19 @@ def test_watch_pod_api_bearer_token_success file = Tempfile.new('token') client = Kubeclient::Client.new( 'http://localhost:8080/api/', 'v1', - auth_options: { bearer_token: "valid_token" } + auth_options: { bearer_token: 'valid_token' } ) - stub_token = stub_request(:get, %r{/watch/pods}) + stub_request(:get, %r{/watch/pods}) .with(headers: { Authorization: 'Bearer valid_token' }) .to_return(body: open_test_file('watch_stream.json'), status: 200) got = nil client.watch_pods(as: :raw).each { |notice| got = notice } assert_match(/\A{"type":"DELETED"/, got) + ensure + file.close + file.unlink # deletes the temp file end # Ensure that WatchStream respects a format that's not JSON