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

WIP Add CI workflow #8

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
190 changes: 155 additions & 35 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,163 @@
# Ruby CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
#
version: 2
jobs:
build:
docker:
# specify the version you desire here
- image: circleci/ruby:2.4.2
reference:

working_directory: ~/repo
workspace: &workspace ~/project

steps:
- checkout
docker_image: &docker_image circleci/ruby:2.5.1

# 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-
container_config: &container_config
docker:
- image: *docker_image
working_directory: *workspace

- run:
name: install dependencies
command: bundle check || bundle install --jobs=4 --retry=3 --path vendor/bundle
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

- save_cache:
paths:
- ./vendor
key: v1-dependencies-{{ checksum "Gemfile" }}
deploy_beta: &deploy_beta
run:
name: Deploy beta version
command: echo "deploying beta"

release: &release
run:
name: Release
command: echo "running release"

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

# run tests!
- run:
name: run tests
command: bundle exec rake
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" }}

# collect reports
- store_test_results:
path: ~/repo/test-results
- store_artifacts:
path: ~/repo/test-results
destination: test-results
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
deploy_beta:
<<: *container_config
steps:
- checkout
- *restore_gem_cache
- *restore_yarn_cache
- *config_environment
- *save_gem_cache
- *save_yarn_cache
- *deploy_beta
release:
<<: *container_config
steps:
- checkout
- *restore_gem_cache
- *restore_yarn_cache
- *config_environment
- *save_gem_cache
- *save_yarn_cache
- *build_gem
# - run:
# name: Publish to RubyGems
# command: source ci/scripts/publish.sh
- run:
name: GitHub release
command: source ci/scripts/release.sh
workflows:
version: 2
build-test-deploy:
jobs:
- build
- test:
requires:
- build
filters:
branches:
ignore:
- master
- documentation:
requires:
- test
filters:
branches:
only:
- develop
- master
- deploy_beta:
requires:
- test
filters:
branches:
only:
- develop
- release:
requires:
- build
filters:
branches:
only:
- /ˆrelease/.*/
# - 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
32 changes: 32 additions & 0 deletions ci/scripts/deploy_beta.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/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/
# -------------------------------------------------------------------
#

export CURRENT_VERSION=$(jq -r ".version" package.json)
yarn standard-version --prerelease 'rc'
export NEW_VERSION=$(jq -r ".version" package.json)
ruby ./ci/scripts/version.rb $CURRENT_VERSION $NEW_VERSION

gem build fastlane-plugin-test_report.gemspec
gem push *.gem
8 changes: 8 additions & 0 deletions ci/scripts/deploy_master.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#publish new version

export CURRENT_VERSION=$(jq -r ".version" package.json)
yarn standard-version
export NEW_VERSION=$(jq -r ".version" package.json)
ruby ./ci/scripts/version.rb $CURRENT_VERSION $NEW_VERSION
gem build fastlane-plugin-test_report.gemspec
gem push *.gem
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
Loading