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 Circle CI configuration #6

Closed
wants to merge 12 commits into from
160 changes: 124 additions & 36 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,131 @@
# Ruby CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
#
version: 2
jobs:
build:
reference:

workspace: &workspace ~/project

docker_image: &docker_image circleci/ruby:2.5.1

container_config: &container_config
docker:
# specify the version you desire here
- image: circleci/ruby:2.4.2
- image: *docker_image
working_directory: *workspace

config_environment: &config_environment
run:
name: Set up environment
command: source ci/scripts/install.sh

rake_test: &rake_test
run:
name: Run tests and linter
command: bundle exec rake

build_gem: &build_gem
run:
name: Build gem
command: gem build fastlane-plugin-test_report.gemspec

deploy_develop: &deploy_develop
run:
name: Deploy beta version
command: echo "deploying beta"

deploy_master: &deploy_master
run:
name: Deploy production version
command: echo "deploying production"

documentation: &documentation
run:
name: Send documentation to gh-pages
command: source ci/scripts/documentation.sh

working_directory: ~/repo
restore_yarn_cache: &restore_yarn_cache
restore_cache:
keys:
- yarn-dependencies-{{ checksum "yarn.lock" }}

save_yarn_cache: &save_yarn_cache
save_cache:
paths:
- ./node_modules/
key: yarn-dependencies-{{ checksum "yarn.lock" }}

restore_gem_cache: &restore_gem_cache
restore_cache:
keys:
- gem-dependencies-{{ checksum "Gemfile" }}

save_gem_cache: &save_gem_cache
save_cache:
paths:
- ./vendor
key: yarn-dependencies-{{ checksum "Gemfile" }}

jobs:
build:
<<: *container_config
steps:
- checkout
- *restore_gem_cache
- *restore_yarn_cache
- *config_environment
- *save_gem_cache
- *save_yarn_cache
- *build_gem
test:
<<: *container_config
steps:
- checkout
- *restore_gem_cache
- *restore_yarn_cache
- *config_environment
- *save_gem_cache
- *save_yarn_cache
- *rake_test
documentation:
<<: *container_config
steps:
- checkout
- *restore_gem_cache
- *restore_yarn_cache
- *config_environment
- *save_gem_cache
- *save_yarn_cache
- *rake_test
- *documentation

# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "Gemfile" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run:
name: install dependencies
command: bundle check || bundle install --jobs=4 --retry=3 --path vendor/bundle

- save_cache:
paths:
- ./vendor
key: v1-dependencies-{{ checksum "Gemfile" }}

# run tests!
- run:
name: run tests
command: bundle exec rake

# collect reports
- store_test_results:
path: ~/repo/test-results
- store_artifacts:
path: ~/repo/test-results
destination: test-results
workflows:
version: 2
build-test-deploy:
jobs:
- build
- test:
requires:
- build
filters:
branches:
ignore:
- master
- documentation:
requires:
- test
filters:
branches:
only:
- develop
- master
- deploy_develop:
requires:
- build
filters:
branches:
only:
- develop
- deploy_master:
requires:
- build
filters:
branches:
only:
- master
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ fastlane/report.xml
coverage
test-results
spec/fixture

## Package

node_modules/
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,4 @@ Style/MethodCallWithArgsParentheses:
- context
- before
- after
- include
28 changes: 28 additions & 0 deletions ci/scripts/documentation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
#
# LICENSE
#
# This file is part of Teclib Fastlane Plugin Test Report.
#
# Fastlane Plugin Test Report is a subproject of Teclib'
#
# Fastlane Plugin Test Report is free software: you can redistribute
# it and/or modify it under the terms of the MIT License.
#
# Fastlane Plugin Test Report is distributed in the hope that it will
# be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the MIT license for further details.
# -------------------------------------------------------------------
# @author Naylin Medina - <[email protected]>
# @copyright Copyright Teclib. All rights reserved.
# @license MIT https://opensource.org/licenses/MIT
# @link https://github.com/TECLIB/fastlane-plugin-test_report/
# @link https://teclib.github.io/fastlane-plugin-test_report/
# @link http://www.teclib-edition.com/en/
# -------------------------------------------------------------------
#

DOC_PATH="development/code-documentation/$CIRCLE_BRANCH"

yarn gh-pages --dist ./coverage --dest $DOC_PATH -m "docs(development): update code documentation"
43 changes: 43 additions & 0 deletions ci/scripts/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
#
# LICENSE
#
# This file is part of Teclib Fastlane Plugin Test Report.
#
# Fastlane Plugin Test Report is a subproject of Teclib'
#
# Fastlane Plugin Test Report is free software: you can redistribute
# it and/or modify it under the terms of the MIT License.
#
# Fastlane Plugin Test Report is distributed in the hope that it will
# be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the MIT license for further details.
# -------------------------------------------------------------------
# @author Naylin Medina - <[email protected]>
# @copyright Copyright Teclib. All rights reserved.
# @license MIT https://opensource.org/licenses/MIT
# @link https://github.com/TECLIB/fastlane-plugin-test_report/
# @link https://teclib.github.io/fastlane-plugin-test_report/
# @link http://www.teclib-edition.com/en/
# -------------------------------------------------------------------
#

# install node
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn

# install dependencies
bundle install --path vendor/bundle

yarn install

# configure git
git config --global user.email $GITHUB_EMAIL
git config --global user.name "Teclib"
git remote remove origin
git remote add origin https://$GITHUB_USER:[email protected]/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME.git
28 changes: 28 additions & 0 deletions ci/scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
#
# LICENSE
#
# This file is part of Teclib Fastlane Plugin Test Report.
#
# Fastlane Plugin Test Report is a subproject of Teclib'
#
# Fastlane Plugin Test Report is free software: you can redistribute
# it and/or modify it under the terms of the MIT License.
#
# Fastlane Plugin Test Report is distributed in the hope that it will
# be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the MIT license for further details.
# -------------------------------------------------------------------
# @author Naylin Medina - <[email protected]>
# @copyright Copyright Teclib. All rights reserved.
# @license MIT https://opensource.org/licenses/MIT
# @link https://github.com/TECLIB/fastlane-plugin-test_report/
# @link https://teclib.github.io/fastlane-plugin-test_report/
# @link http://www.teclib-edition.com/en/
# -------------------------------------------------------------------
#

mkdir ~/.gem
echo -e "---\n:rubygems_api_key: $KEY_RUBYGEMS" > ~/.gem/credentials
chmod 0600 ~/.gem/credential
2 changes: 1 addition & 1 deletion fastlane-plugin-test_report.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
spec.homepage = "https://github.com/TECLIB/fastlane-plugin-test_report"
spec.license = "MIT"

spec.files = Dir["lib/**/*"] + %w(README.md LICENSE)
spec.files = Dir["lib/**/*"] + %w(README.md LICENSE.md)
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ['lib']

Expand Down
6 changes: 3 additions & 3 deletions lib/fastlane/plugin/test_report/actions/test_report_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def self.run(params)
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>
Expand All @@ -40,7 +40,7 @@ def self.run(params)

<% 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">
Expand Down Expand Up @@ -76,7 +76,7 @@ def self.run(params)
result = ERB.new(template).result(binding())

open(File.join(params[:output_dir], '/index.html'), 'w') do |f|
f.puts result
f.puts(result)
end
end

Expand Down
Loading