Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add plugin functions #1

Merged
merged 11 commits into from
Oct 5, 2018
9 changes: 9 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- File a GitHub issue only for bugs or feature requests related to the code **in this repository**. For other topics you can get more information in the README file. -->

#### Observed Results:

<!-- This could be a description, error output, steps to reproduce, a feature missed, etc. -->

#### Expected behavior:

<!-- What did you expect to happen? -->
35 changes: 35 additions & 0 deletions .github/ISSUE_TEMPLATE/Bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: Bug report
about: Create a report to help us improve

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/Feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Feature request
about: Suggest an idea for this project

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
28 changes: 28 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
### Changes description

<!-- Describe results, user mentions, screenshots, screencast (gif) -->

### Checklist

Please check if your PR fulfills the following specifications:

- [ ] Tests for the changes have been added
- [ ] Docs have been added/updated

### Estimated time

<!-- Add the number of pomodoros spent on this task -->

|Assignee|:tomato:|
|:---|:---:|
|@ |1|

<!--- Task not finished? Please give an update of the time --->

### References

<!-- issues related (for reference or to be closed), dependencies and/or links of discuss -->

Closes #N/A
Related #N/A
Depends on #N/A
3 changes: 3 additions & 0 deletions .github/invite-contributors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
isOutside: true
# Team Name
team: contributors
48 changes: 48 additions & 0 deletions .github/settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
repository:
name: fastlane-plugin-test_report
description: Create customized html for iOS test report
homepage: https://teclib.github.io/fastlane-plugin-test_report/
topics: fastlane-plugin, xml, test-report
private: false
has_issues: true
has_wiki: false
has_downloads: true
default_branch: develop
allow_squash_merge: true
allow_merge_commit: false
allow_rebase_merge: true
labels:
- name: bug
color: f44336
- name: build
color: 795548
- name: cherry-pick
color: af1c46
- name: ci
color: fbca04
- name: documentation
color: 607d8b
- name: duplicate
color: 9e9e9e
- name: feature
color: 3f51b5
- name: hacktoberfest
color: ff625f
- name: invalid
color: cddc39
- name: performance
color: 009688
- name: question
color: ff5722
- name: refactor
color: 9c27b0
- name: style
color: 2196f3
- name: test
color: 8bc34a
- name: wontfix
color: ffffff
- name: help wanted
color: 33aa3f
- name: good first issue
color: 7057ff
2 changes: 1 addition & 1 deletion LICENSE → LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2018 Naylin Medina <[email protected]>
Copyright (c) 2018 Teclib'

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
91 changes: 85 additions & 6 deletions lib/fastlane/plugin/test_report/actions/test_report_action.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,90 @@
require 'fastlane/action'
require_relative '../helper/test_report_helper'
require "erb"
require "rexml/document"

module Fastlane
module Actions
class TestReportAction < Action
def self.run(params)
UI.message("The test_report plugin is working!")

include REXML

File.rename("fastlane/test_output/report.junit", "fastlane/test_output/report.xml")

file = File.new(File.expand_path(params[:report_path]))
doc = Document.new(file)

if params[:template_path] == nil
template = '---
layout: testReport
---

<div class="total row">
<h2 class="col-sm-18">Test Results</h2>
<h2 class="col-sm-6 text-right"><%= doc.root.attributes["tests"] %> tests</h2>
</div>
<div>
<% i = 0 %>
<% doc.elements.each("testsuites/testsuite") do |name| %>
<% i = i + 1 %>
<% if name.attributes["failures"] == "0" %>
<div class="test-suite row test-suite--passing" onclick="changeDisplay(<%= "\'#test-#{i}\'"%>)">
<% else %>
<div class="test-suite row test-suite--failing" onclick="changeDisplay(<%= "\'#test-#{i}\'"%>)">
<% end %>
<h4 class="col-sm-20"><%= name.attributes["name"] %></h4>
<h4 class="col-sm-4 text-right"><%= name.attributes["tests"] %> tests</h4>
</div>
<!-- Failing or passing class -->
<div id="<%= "test-#{i}"%>">

<% doc.elements.each("testsuites/testsuite/testcase") do |test| %>
<% if test.attributes["classname"] == name.attributes["name"] %>

<% if test.attributes["time"] == nil %>
<div class="test-case--failing row">
<div class="col-sm-16">
<p><%= test.attributes["name"] %></p>
</div>
<div class="col-sm-4">
<p><%= test.elements["failure"].attributes["message"] %></p>
</div>
<div class="col-sm-4 text-right">
<p><%= test.elements["failure"].text %></p>
</div>
</div>
<% else %>
<div class="test-case--passing row">
<div class="col-sm-20">
<p><%= test.attributes["name"] %></p>
</div>
<div class="col-sm-4 text-right">
<p><%= test.attributes["time"] %></p>
</div>
</div>
<% end %>
<% end %>
<% end %>
</div>
<% end %>

</div>'
else
template = File.read(params[:template_path])
end

result = ERB.new(template).result(binding())

open('./fastlane/test_output/index.html', 'w') do |f|
f.puts result
end

end

def self.description
"customized template for test reports"
"Create customized HTML template for test reports"
end

def self.authors
Expand All @@ -27,11 +102,15 @@ def self.details

def self.available_options
[
# FastlaneCore::ConfigItem.new(key: :your_option,
# env_name: "TEST_REPORT_YOUR_OPTION",
# description: "A description of your option",
# optional: false,
# type: String)
FastlaneCore::ConfigItem.new(key: :report_path,
env_name: "TEST_REPORT_PATH",
description: "Path to the test report",
default_value: './fastlane/test_output/report.xml'),
FastlaneCore::ConfigItem.new(key: :template_path,
env_name: "TEMPLATE_PATH",
description: "Path to the template",
type: String,
optional: true)
]
end

Expand Down