From 88370647150ac60508c836e97d6184b7ea04dc34 Mon Sep 17 00:00:00 2001 From: 3v0k4 Date: Thu, 6 Jul 2023 16:02:01 +0200 Subject: [PATCH] chore: update changelog --- CHANGELOG.md | 8 ++ .../repository_adapters/git_adapter.rb | 4 + .../v1/build_distributions/subset/timeout.yml | 109 ++++++++++++++++++ .../api/v1/build_subsets/create/timeout.yml | 106 +++++++++++++++++ .../repository_adapters/git_adapter_spec.rb | 20 ++++ 5 files changed, 247 insertions(+) create mode 100644 spec/fixtures/vcr_cassettes/api/v1/build_distributions/subset/timeout.yml create mode 100644 spec/fixtures/vcr_cassettes/api/v1/build_subsets/create/timeout.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index dad5b29e..97513e31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +### 5.2.0 + +* Send authors to the API + + https://github.com/KnapsackPro/knapsack_pro-ruby/pull/208 + +https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v5.1.2...v5.2.0 + ### 5.1.2 * Fix broken RSpec split by test examples feature when `SPEC_OPTS` is set in Queue Mode. Ignore `SPEC_OPTS` when generating test examples report for slow test files. diff --git a/lib/knapsack_pro/repository_adapters/git_adapter.rb b/lib/knapsack_pro/repository_adapters/git_adapter.rb index ce39ec63..4e9d84bc 100644 --- a/lib/knapsack_pro/repository_adapters/git_adapter.rb +++ b/lib/knapsack_pro/repository_adapters/git_adapter.rb @@ -22,10 +22,14 @@ def authors .map do |commits, author| { commits: commits.to_i, author: KnapsackPro::MaskString.call(author) } end + rescue Exception + [{ commits: 0, author: "no git " }] end def author KnapsackPro::MaskString.call(git_author.strip) + rescue Exception + "no git " end private diff --git a/spec/fixtures/vcr_cassettes/api/v1/build_distributions/subset/timeout.yml b/spec/fixtures/vcr_cassettes/api/v1/build_distributions/subset/timeout.yml new file mode 100644 index 00000000..df247275 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/api/v1/build_distributions/subset/timeout.yml @@ -0,0 +1,109 @@ +--- +http_interactions: +- request: + method: post + uri: http://api.fake-knapsackpro.test:3000/v1/build_distributions/subset + body: + encoding: UTF-8 + string: '{"fixed_test_suite_split":true,"cache_read_attempt":true,"commit_hash":"abcdefg","branch":"master","node_total":"2","node_index":"1","ci_build_id":"some-build-id","user_seat":null,"author":"3v0*4 + ","authors":[{"commits":8,"author":"3v0*4 "},{"commits":10,"author":"Ar*** + Tr*** "},{"commits":2,"author":"Ri****** "},{"commits":3,"author":"sh**** + "}]}' + headers: + Content-Type: + - application/json + Accept: + - application/json + Knapsack-Pro-Client-Name: + - knapsack_pro-ruby + Knapsack-Pro-Client-Version: + - 5.1.2 + Knapsack-Pro-Test-Suite-Token: + - 3fa64859337f6e56409d49f865d13fd7 + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + User-Agent: + - Ruby + response: + status: + code: 403 + message: Forbidden + headers: + Content-Type: + - text/html; charset=UTF-8 + Content-Length: + - '5413' + body: + encoding: UTF-8 + string: "\n\n\n \n \n + \ Action Controller: Exception caught\n \n\n \n\n\n\n
\n

Blocked host: api.fake-knapsackpro.test

\n
\n
\n

To allow requests to api.fake-knapsackpro.test + make sure it is a valid hostname (containing only numbers, letters, dashes + and dots), then add the following to your environment configuration:

\n + \
config.hosts << \"api.fake-knapsackpro.test\"
\n

For + more details view: the + Host Authorization guide

\n
\n\n\n\n\n" + recorded_at: Fri, 07 Jul 2023 09:25:57 GMT +recorded_with: VCR 6.1.0 diff --git a/spec/fixtures/vcr_cassettes/api/v1/build_subsets/create/timeout.yml b/spec/fixtures/vcr_cassettes/api/v1/build_subsets/create/timeout.yml new file mode 100644 index 00000000..a7e82363 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/api/v1/build_subsets/create/timeout.yml @@ -0,0 +1,106 @@ +--- +http_interactions: +- request: + method: post + uri: http://api.fake-knapsackpro.test:3000/v1/build_subsets + body: + encoding: UTF-8 + string: '{"commit_hash":"abcdefg","branch":"master","node_total":"2","node_index":"1","test_files":[{"path":"a_spec.rb","time_execution":1.2},{"path":"b_spec.rb","time_execution":0.3}]}' + headers: + Content-Type: + - application/json + Accept: + - application/json + Knapsack-Pro-Client-Name: + - knapsack_pro-ruby + Knapsack-Pro-Client-Version: + - 5.1.2 + Knapsack-Pro-Test-Suite-Token: + - 3fa64859337f6e56409d49f865d13fd7 + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + User-Agent: + - Ruby + response: + status: + code: 403 + message: Forbidden + headers: + Content-Type: + - text/html; charset=UTF-8 + Content-Length: + - '5413' + body: + encoding: UTF-8 + string: "\n\n\n \n \n + \ Action Controller: Exception caught\n \n\n \n\n\n\n
\n

Blocked host: api.fake-knapsackpro.test

\n
\n
\n

To allow requests to api.fake-knapsackpro.test + make sure it is a valid hostname (containing only numbers, letters, dashes + and dots), then add the following to your environment configuration:

\n + \
config.hosts << \"api.fake-knapsackpro.test\"
\n

For + more details view: the + Host Authorization guide

\n
\n\n\n\n\n" + recorded_at: Fri, 07 Jul 2023 09:24:41 GMT +recorded_with: VCR 6.1.0 diff --git a/spec/knapsack_pro/repository_adapters/git_adapter_spec.rb b/spec/knapsack_pro/repository_adapters/git_adapter_spec.rb index 9187b21c..fabe6fc2 100644 --- a/spec/knapsack_pro/repository_adapters/git_adapter_spec.rb +++ b/spec/knapsack_pro/repository_adapters/git_adapter_spec.rb @@ -42,6 +42,16 @@ expect(subject.author).to eq 'Jo** Do* ' end + + context "when git_author raises an exception" do + it "returns the the no git author" do + allow_any_instance_of(KnapsackPro::RepositoryAdapters::GitAdapter).to receive(:git_author).and_raise(Exception) + + subject = KnapsackPro::RepositoryAdapters::GitAdapter.new + + expect(subject.author).to eq 'no git ' + end + end end describe '#authors' do @@ -62,5 +72,15 @@ { commits: 3, author: "sh**** " }, ] end + + context "when git_authors raises an exception" do + it "returns the the no git author" do + allow_any_instance_of(KnapsackPro::RepositoryAdapters::GitAdapter).to receive(:git_authors).and_raise(Exception) + + subject = KnapsackPro::RepositoryAdapters::GitAdapter.new + + expect(subject.authors).to eq [{ commits: 0, author: "no git " }] + end + end end end