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 support for Solano CI and AppVeyor #66

Merged
merged 6 commits into from
Sep 6, 2018
Merged
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

* TODO

### 0.57.0

* Add support for Solano CI and AppVeyor

https://github.com/KnapsackPro/knapsack_pro-ruby/pull/66

https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v0.56.0...v0.57.0

### 0.56.0

* Add support for Cirrus CI
Expand Down
72 changes: 68 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ The knapsack_pro has also [queue mode](#queue-mode) to get an optimal test suite
- [Info for Gitlab CI users](#info-for-gitlab-ci-users)
- [Info for codeship.com users](#info-for-codeshipcom-users)
- [Info for Heroku CI users](#info-for-heroku-ci-users)
- [Info for Solano CI users](#info-for-solano-ci-users)
- [Info for AppVeyor users](#info-for-appveyor-users)
- [Info for snap-ci.com users](#info-for-snap-cicom-users)
- [Info for cirrus-ci.org users](#info-for-cirrus-ciorg-users)
- [Info for Jenkins users](#info-for-jenkins-users)
Expand Down Expand Up @@ -842,7 +844,7 @@ Knapsack Pro supports semaphoreapp ENVs `SEMAPHORE_THREAD_COUNT` and `SEMAPHORE_

Tests will be split across threads.

Please remember to set up token like `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` as global environment.
Please remember to set up API token like `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` as global environment.

#### Info for buildkite.com users

Expand All @@ -863,7 +865,7 @@ Knapsack Pro supports buildkite ENVs `BUILDKITE_PARALLEL_JOB_COUNT` and `BUILDKI
# Step for Spinach
bundle exec rake knapsack_pro:spinach

Please remember to set up token like `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` as global environment.
Please remember to set up API token like `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` as global environment.

Here you can find article [how to set up a new pipeline for your project in Buildkite and configure Knapsack Pro](http://docs.knapsackpro.com/2017/auto-balancing-7-hours-tests-between-100-parallel-jobs-on-ci-buildkite-example) and 2 example repositories for Ruby/Rails projects:

Expand Down Expand Up @@ -978,6 +980,68 @@ Note the [Heroku CI Parallel Test Runs](https://devcenter.heroku.com/articles/he

You can learn more about [Heroku CI](https://devcenter.heroku.com/articles/heroku-ci).

#### Info for Solano CI users

[Solano CI](https://www.solanolabs.com) does not provide parallel jobs environment variables so you will have to define `KNAPSACK_PRO_CI_NODE_TOTAL` and `KNAPSACK_PRO_CI_NODE_INDEX` for each parallel job running as part of the same CI build.

# Step for RSpec for first CI node
KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 bundle exec rake knapsack_pro:rspec
# Step for RSpec for second CI node
KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=1 bundle exec rake knapsack_pro:rspec

# Step for Cucumber for first CI node
KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 bundle exec rake knapsack_pro:cucumber
# Step for Cucumber for second CI node
KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=1 bundle exec rake knapsack_pro:cucumber

# Step for Minitest for first CI node
KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 bundle exec rake knapsack_pro:minitest
# Step for Minitest for second CI node
KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=1 bundle exec rake knapsack_pro:minitest

# Step for test-unit for first CI node
KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 bundle exec rake knapsack_pro:test_unit
# Step for test-unit for second CI node
KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=1 bundle exec rake knapsack_pro:test_unit

# Step for Spinach for first CI node
KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 bundle exec rake knapsack_pro:spinach
# Step for Spinach for second CI node
KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=1 bundle exec rake knapsack_pro:spinach

Please remember to set up API token like `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` as global environment.

#### Info for AppVeyor users

[AppVeyor](https://www.appveyor.com) does not provide parallel jobs environment variables so you will have to define `KNAPSACK_PRO_CI_NODE_TOTAL` and `KNAPSACK_PRO_CI_NODE_INDEX` for each parallel job running as part of the same CI build.

# Step for RSpec for first CI node
KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 bundle exec rake knapsack_pro:rspec
# Step for RSpec for second CI node
KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=1 bundle exec rake knapsack_pro:rspec

# Step for Cucumber for first CI node
KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 bundle exec rake knapsack_pro:cucumber
# Step for Cucumber for second CI node
KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=1 bundle exec rake knapsack_pro:cucumber

# Step for Minitest for first CI node
KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 bundle exec rake knapsack_pro:minitest
# Step for Minitest for second CI node
KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=1 bundle exec rake knapsack_pro:minitest

# Step for test-unit for first CI node
KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 bundle exec rake knapsack_pro:test_unit
# Step for test-unit for second CI node
KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=1 bundle exec rake knapsack_pro:test_unit

# Step for Spinach for first CI node
KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 bundle exec rake knapsack_pro:spinach
# Step for Spinach for second CI node
KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=1 bundle exec rake knapsack_pro:spinach

Please remember to set up API token like `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` as global environment.

#### Info for snap-ci.com users

Knapsack Pro supports snap-ci.com ENVs `SNAP_WORKER_TOTAL` and `SNAP_WORKER_INDEX`. The only thing you need to do is to configure number of workers for your project in configuration settings in order to enable parallelism. Next thing is to set below commands to be executed in your stage:
Expand All @@ -997,7 +1061,7 @@ Knapsack Pro supports snap-ci.com ENVs `SNAP_WORKER_TOTAL` and `SNAP_WORKER_INDE
# Step for Spinach
bundle exec rake knapsack_pro:spinach

Please remember to set up token like `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` as global environment.
Please remember to set up API token like `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` as global environment.

#### Info for cirrus-ci.org users

Expand All @@ -1018,7 +1082,7 @@ Knapsack Pro supports cirrus-ci.org ENVs `CI_NODE_TOTAL` and `CI_NODE_INDEX`. Th
# Step for Spinach
bundle exec rake knapsack_pro:spinach

Please remember to set up token like `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` as global environment.
Please remember to set up API token like `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` as global environment.

Here is example for [`.cirrus.yml` configuration file](https://cirrus-ci.org/examples/#ruby).

Expand Down
2 changes: 2 additions & 0 deletions lib/knapsack_pro.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
require_relative 'knapsack_pro/utils'
require_relative 'knapsack_pro/logger_wrapper'
require_relative 'knapsack_pro/config/ci/base'
require_relative 'knapsack_pro/config/ci/app_veyor'
require_relative 'knapsack_pro/config/ci/circle'
require_relative 'knapsack_pro/config/ci/cirrus_ci'
require_relative 'knapsack_pro/config/ci/gitlab_ci'
require_relative 'knapsack_pro/config/ci/semaphore'
require_relative 'knapsack_pro/config/ci/buildkite'
require_relative 'knapsack_pro/config/ci/travis'
require_relative 'knapsack_pro/config/ci/snap_ci'
require_relative 'knapsack_pro/config/ci/solano_ci'
require_relative 'knapsack_pro/config/ci/codeship'
require_relative 'knapsack_pro/config/ci/heroku'
require_relative 'knapsack_pro/config/env'
Expand Down
32 changes: 32 additions & 0 deletions lib/knapsack_pro/config/ci/app_veyor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# https://www.appveyor.com/docs/environment-variables/
module KnapsackPro
module Config
module CI
class AppVeyor < Base
def node_total
# not provided
end

def node_index
# not provided
end

def node_build_id
ENV['APPVEYOR_BUILD_ID']
end

def commit_hash
ENV['APPVEYOR_REPO_COMMIT']
end

def branch
ENV['APPVEYOR_REPO_BRANCH']
end

def project_dir
ENV['APPVEYOR_BUILD_FOLDER']
end
end
end
end
end
32 changes: 32 additions & 0 deletions lib/knapsack_pro/config/ci/solano_ci.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# http://docs.solanolabs.com/Setup/tddium-set-environment-variables/
module KnapsackPro
module Config
module CI
class SolanoCI < Base
def node_total
# not provided
end

def node_index
# not provided
end

def node_build_id
ENV['TDDIUM_SESSION_ID']
end

def commit_hash
ENV['TDDIUM_CURRENT_COMMIT']
end

def branch
ENV['TDDIUM_CURRENT_BRANCH']
end

def project_dir
ENV['TDDIUM_REPO_ROOT']
end
end
end
end
end
73 changes: 73 additions & 0 deletions spec/knapsack_pro/config/ci/app_veyor_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
describe KnapsackPro::Config::CI::AppVeyor do
let(:env) { {} }

before do
stub_const('ENV', env)
end

it { should be_kind_of KnapsackPro::Config::CI::Base }

describe '#node_total' do
subject { described_class.new.node_total }

it { should be nil }
end

describe '#node_index' do
subject { described_class.new.node_index }

it { should be nil }
end

describe '#node_build_id' do
subject { described_class.new.node_build_id }

context 'when environment exists' do
let(:env) { { 'APPVEYOR_BUILD_ID' => 123 } }
it { should eql 123 }
end

context "when environment doesn't exist" do
it { should be nil }
end
end

describe '#commit_hash' do
subject { described_class.new.commit_hash }

context 'when environment exists' do
let(:env) { { 'APPVEYOR_REPO_COMMIT' => '2e13512fc230d6f9ebf4923352718e4d' } }
it { should eql '2e13512fc230d6f9ebf4923352718e4d' }
end

context "when environment doesn't exist" do
it { should be nil }
end
end

describe '#branch' do
subject { described_class.new.branch }

context 'when environment exists' do
let(:env) { { 'APPVEYOR_REPO_BRANCH' => 'master' } }
it { should eql 'master' }
end

context "when environment doesn't exist" do
it { should be nil }
end
end

describe '#project_dir' do
subject { described_class.new.project_dir }

context 'when environment exists' do
let(:env) { { 'APPVEYOR_BUILD_FOLDER' => '/path/to/clone/repo' } }
it { should eql '/path/to/clone/repo' }
end

context "when environment doesn't exist" do
it { should be nil }
end
end
end
73 changes: 73 additions & 0 deletions spec/knapsack_pro/config/ci/solano_ci_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
describe KnapsackPro::Config::CI::SolanoCI do
let(:env) { {} }

before do
stub_const('ENV', env)
end

it { should be_kind_of KnapsackPro::Config::CI::Base }

describe '#node_total' do
subject { described_class.new.node_total }

it { should be nil }
end

describe '#node_index' do
subject { described_class.new.node_index }

it { should be nil }
end

describe '#node_build_id' do
subject { described_class.new.node_build_id }

context 'when environment exists' do
let(:env) { { 'TDDIUM_SESSION_ID' => 123 } }
it { should eql 123 }
end

context "when environment doesn't exist" do
it { should be nil }
end
end

describe '#commit_hash' do
subject { described_class.new.commit_hash }

context 'when environment exists' do
let(:env) { { 'TDDIUM_CURRENT_COMMIT' => '2e13512fc230d6f9ebf4923352718e4d' } }
it { should eql '2e13512fc230d6f9ebf4923352718e4d' }
end

context "when environment doesn't exist" do
it { should be nil }
end
end

describe '#branch' do
subject { described_class.new.branch }

context 'when environment exists' do
let(:env) { { 'TDDIUM_CURRENT_BRANCH' => 'master' } }
it { should eql 'master' }
end

context "when environment doesn't exist" do
it { should be nil }
end
end

describe '#project_dir' do
subject { described_class.new.project_dir }

context 'when environment exists' do
let(:env) { { 'TDDIUM_REPO_ROOT' => '/example/repo/root' } }
it { should eql '/example/repo/root' }
end

context "when environment doesn't exist" do
it { should be nil }
end
end
end