Skip to content

Commit

Permalink
Merge pull request #5 from qawolf/simon/gen-333-fix-fastlane-plugin-t…
Browse files Browse the repository at this point in the history
…o-also-consider-duplicate_suite_id

add success check for `duplicate_suite_id`
  • Loading branch information
smonn authored Dec 19, 2024
2 parents eec8dec + 85880c6 commit 343b15b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To

```
# Add this to your Gemfile
gem "fastlane-plugin-qawolf", git: "https://github.com/qawolf/fastlane-plugin-qawolf", tag: "0.3.0"
gem "fastlane-plugin-qawolf", git: "https://github.com/qawolf/fastlane-plugin-qawolf", tag: "0.3.1"
```

## About qawolf
Expand Down
2 changes: 1 addition & 1 deletion fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ lane :test do
)
notify_deploy_qawolf(
deployment_type: "android",
sha: false,
sha: "random_sha",
executable_environment_key: "ANDROID_APP",
variables: {
HELLO: "WORLD"
Expand Down
14 changes: 11 additions & 3 deletions lib/fastlane/plugin/qawolf/helper/qawolf_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,24 @@ def self.process_notify_response(response)

results = response_json["results"]

failed_trigger = results.find { |result| result["failure_reason"].nil? == false }
success_trigger = results.find { |result| result["created_suite_id"].nil? == false }
failed_trigger = get_failed_trigger(results)
success_trigger = get_success_trigger(results)

if failed_trigger.nil? && success_trigger.nil?
raise "no matched trigger, reach out to QA Wolf support"
elsif failed_trigger.nil? == false
raise failed_trigger["failure_reason"]
end

return success_trigger["created_suite_id"]
return success_trigger["created_suite_id"] || success_trigger["duplicate_suite_id"]
end

def self.get_failed_trigger(results)
results.find { |result| result["failure_reason"].nil? == false }
end

def self.get_success_trigger(results)
results.find { |result| result["created_suite_id"].nil? == false || result["duplicate_suite_id"].nil? == false }
end

# Triggers QA Wolf deploy success webhook to start test runs.
Expand Down
2 changes: 1 addition & 1 deletion lib/fastlane/plugin/qawolf/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Fastlane
module Qawolf
VERSION = "0.3.0"
VERSION = "0.3.1"
end
end
14 changes: 14 additions & 0 deletions spec/fastlane/actions/notify_deploy_qawolf_action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,19 @@
end.to raise_error(FastlaneCore::Interface::FastlaneError)
end
end

context "with duplicate suite id set" do
let(:deploy_response) do
{
results: [{ duplicate_suite_id: "duplicate_suite_id" }]
}
end

it "returns the duplicate suite id" do
result = described_class.run(params)
expect(result).to eq(deploy_response[:results][0][:duplicate_suite_id
])
end
end
end
end

0 comments on commit 343b15b

Please sign in to comment.