knapsack_pro 1.14.0 → 1.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -1
- data/CHANGELOG.md +8 -0
- data/README.md +221 -3
- data/lib/knapsack_pro.rb +1 -0
- data/lib/knapsack_pro/config/ci/codefresh.rb +32 -0
- data/lib/knapsack_pro/version.rb +1 -1
- data/spec/knapsack_pro/config/ci/codefresh_spec.rb +66 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6de10d3f404a03841c25d3a554c9b44a9b0c9ca97386d46ebe38a3b9eb0eed5f
|
4
|
+
data.tar.gz: 625ad48ee1f6d3a1961f60bf7ce23fe209b26f4f03ec565876050969630eca3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c05eec67c0d656f85049b73f625678b15c813997d84d3ecbdefaa063532a445ecb888b8a08c928dbcf46314dafbf155b1bfb8a2319c923be3e7f958fc04f879
|
7
|
+
data.tar.gz: 0ffbca55a18ab1e35e741edcc90020e3ff7ef1fe58296aa860e9397b48557f85d0d0ae327d3be84794ac062528220e4ed9165aa7223e65d37534be71403bd2e3
|
data/.circleci/config.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
### 1.15.0
|
4
|
+
|
5
|
+
* Add support for Codefresh.io CI provider
|
6
|
+
|
7
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/92
|
8
|
+
|
9
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v1.14.0...v1.15.0
|
10
|
+
|
3
11
|
### 1.14.0
|
4
12
|
|
5
13
|
* Add support for GitHub Actions
|
data/README.md
CHANGED
@@ -113,6 +113,7 @@ You can see list of questions for common problems and tips in below [Table of Co
|
|
113
113
|
- [Info for cirrus-ci.org users](#info-for-cirrus-ciorg-users)
|
114
114
|
- [Info for Jenkins users](#info-for-jenkins-users)
|
115
115
|
- [Info for GitHub Actions users](#info-for-github-actions-users)
|
116
|
+
- [Info for Codefresh.io users](#info-for-codefreshio-users)
|
116
117
|
- [FAQ](#faq)
|
117
118
|
- [Common problems](#common-problems)
|
118
119
|
- [Why I see API error commit_hash parameter is required?](#why-i-see-api-error-commit_hash-parameter-is-required)
|
@@ -140,6 +141,7 @@ You can see list of questions for common problems and tips in below [Table of Co
|
|
140
141
|
- [Why when I reran the same build (same commit hash, etc) on Codeship then no tests would get executed in Queue Mode?](#why-when-i-reran-the-same-build-same-commit-hash-etc-on-codeship-then-no-tests-would-get-executed-in-queue-mode)
|
141
142
|
- [Why knapsack_pro hangs / freezes / is stale i.e. for Codeship in Queue Mode?](#why-knapsack_pro-hangs--freezes--is-stale-ie-for-codeship-in-queue-mode)
|
142
143
|
- [How to find seed in RSpec output when I use Queue Mode for RSpec?](#how-to-find-seed-in-rspec-output-when-i-use-queue-mode-for-rspec)
|
144
|
+
- [How to configure puffing-billy gem with Knapsack Pro Queue Mode?](#how-to-configure-puffing-billy-gem-with-knapsack-pro-queue-mode)
|
143
145
|
- [General questions](#general-questions)
|
144
146
|
- [How to run tests for particular CI node in your development environment](#how-to-run-tests-for-particular-ci-node-in-your-development-environment)
|
145
147
|
- [for knapsack_pro regular mode](#for-knapsack_pro-regular-mode)
|
@@ -168,6 +170,8 @@ You can see list of questions for common problems and tips in below [Table of Co
|
|
168
170
|
- [How many API keys I need?](#how-many-api-keys-i-need)
|
169
171
|
- [What is optimal order of test commands?](#what-is-optimal-order-of-test-commands)
|
170
172
|
- [How to set `before(:suite)` and `after(:suite)` RSpec hooks in Queue Mode (Percy.io example)?](#how-to-set-beforesuite-and-aftersuite-rspec-hooks-in-queue-mode-percyio-example)
|
173
|
+
- [percy-capybara gem version < 4 (old)](#percy-capybara-gem-version--4-old)
|
174
|
+
- [percy-capybara gem version >= 4](#percy-capybara-gem-version--4)
|
171
175
|
- [How to call `before(:suite)` and `after(:suite)` RSpec hooks only once in Queue Mode?](#how-to-call-beforesuite-and-aftersuite-rspec-hooks-only-once-in-queue-mode)
|
172
176
|
- [What hooks are supported in Queue Mode?](#what-hooks-are-supported-in-queue-mode)
|
173
177
|
- [How to run knapsack_pro with parallel_tests gem?](#how-to-run-knapsack_pro-with-parallel_tests-gem)
|
@@ -247,7 +251,7 @@ end
|
|
247
251
|
|
248
252
|
# add below when you hook into webmock
|
249
253
|
require 'webmock/rspec'
|
250
|
-
WebMock.disable_net_connect!(allow: ['api.knapsackpro.com'])
|
254
|
+
WebMock.disable_net_connect!(allow_localhost: true, allow: ['api.knapsackpro.com'])
|
251
255
|
|
252
256
|
# add below when you use FakeWeb
|
253
257
|
require 'fakeweb'
|
@@ -265,6 +269,22 @@ group :test do
|
|
265
269
|
end
|
266
270
|
```
|
267
271
|
|
272
|
+
If you happen to see your tests failing due to WebMock not allowing requests to Knapsack Pro API it means you probably reconfigure WebMock in some of your tests.
|
273
|
+
For instance, you may use `WebMock.reset!` or it's called automatically in `after(:each)` block, if you `require 'webmock/rspec'` ([more about the issue](https://github.com/bblimke/webmock/issues/484#issuecomment-116193449)). It will remove api.knapsackpro.com from whitelisted domains. Please try below:
|
274
|
+
|
275
|
+
```ruby
|
276
|
+
RSpec.configure do |config|
|
277
|
+
config.after(:suite) do
|
278
|
+
WebMock.disable_net_connect!(
|
279
|
+
allow_localhost: true,
|
280
|
+
allow: [
|
281
|
+
'api.knapsackpro.com',
|
282
|
+
],
|
283
|
+
)
|
284
|
+
end
|
285
|
+
end
|
286
|
+
```
|
287
|
+
|
268
288
|
### Usage (How to set up 1 of 3)
|
269
289
|
|
270
290
|
__Tip:__ You can find here an example of a rails app with knapsack_pro already configured.
|
@@ -1419,6 +1439,7 @@ knapsack_pro gem supports environment variables provided by GitHub Actions to ru
|
|
1419
1439
|
Below you can find full GitHub Actions config for Ruby on Rails project.
|
1420
1440
|
|
1421
1441
|
```yaml
|
1442
|
+
# .github/workflows/main.yaml
|
1422
1443
|
name: Main
|
1423
1444
|
|
1424
1445
|
on: [push]
|
@@ -1444,6 +1465,7 @@ jobs:
|
|
1444
1465
|
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
1445
1466
|
|
1446
1467
|
strategy:
|
1468
|
+
fail-fast: false
|
1447
1469
|
matrix:
|
1448
1470
|
# Set N number of parallel jobs you want to run tests on.
|
1449
1471
|
# Use higher number if you have slow tests to split them on more parallel jobs.
|
@@ -1501,6 +1523,128 @@ jobs:
|
|
1501
1523
|
bundle exec rake knapsack_pro:queue:minitest
|
1502
1524
|
```
|
1503
1525
|
|
1526
|
+
#### Info for Codefresh.io users
|
1527
|
+
|
1528
|
+
knapsack_pro gem supports environment variables provided by Codefresh.io to run your tests. You will have to define a few things in `.codefresh/codefresh.yml` config file.
|
1529
|
+
|
1530
|
+
* You need to set an API token like `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` in Codefresh dashboard, see left menu Pipelines -> settings (cog icon next to the pipeline) -> Variables tab (see a vertical menu on the right side). Add there new API token depending on the test runner you use:
|
1531
|
+
* `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC`
|
1532
|
+
* `KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER`
|
1533
|
+
* `KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST`
|
1534
|
+
* `KNAPSACK_PRO_TEST_SUITE_TEST_UNIT`
|
1535
|
+
* `KNAPSACK_PRO_TEST_SUITE_TOKEN_SPINACH`
|
1536
|
+
* Set where Codefresh YAML file can be found. In Codefresh dashboard, see left menu Pipelines -> settings (cog icon next to pipeline) -> Workflow tab (horizontal menu on the top) -> Path to YAML (set there `./.codefresh/codefresh.yml`).
|
1537
|
+
* Set how many parallel jobs (parallel CI nodes) you want to run with `KNAPSACK_PRO_CI_NODE_TOTAL` environment variable in `.codefresh/codefresh.yml` file.
|
1538
|
+
* Ensure in the `matrix` section you listed all `KNAPSACK_PRO_CI_NODE_INDEX` environment variables with a value from `0` to `KNAPSACK_PRO_CI_NODE_TOTAL-1`. Codefresh will generate a matrix of parallel jobs where each job has a different value for `KNAPSACK_PRO_CI_NODE_INDEX`. Thanks to that Knapsack Pro knows what tests should be run on each parallel job.
|
1539
|
+
|
1540
|
+
Below you can find Codefresh YAML config and `Test.Dockerfile` used by Codefresh to run Ruby on Rails project with PostgreSQL inside of Docker container.
|
1541
|
+
|
1542
|
+
```yaml
|
1543
|
+
# .codefresh/codefresh.yml
|
1544
|
+
version: "1.0"
|
1545
|
+
|
1546
|
+
stages:
|
1547
|
+
- "clone"
|
1548
|
+
- "build"
|
1549
|
+
- "tests"
|
1550
|
+
|
1551
|
+
steps:
|
1552
|
+
main_clone:
|
1553
|
+
type: "git-clone"
|
1554
|
+
description: "Cloning main repository..."
|
1555
|
+
repo: "${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}"
|
1556
|
+
revision: "${{CF_BRANCH}}"
|
1557
|
+
stage: "clone"
|
1558
|
+
BuildTestDockerImage:
|
1559
|
+
title: Building Test Docker image
|
1560
|
+
type: build
|
1561
|
+
arguments:
|
1562
|
+
image_name: '${{CF_ACCOUNT}}/${{CF_REPO_NAME}}-test'
|
1563
|
+
tag: '${{CF_BRANCH_TAG_NORMALIZED}}-${{CF_SHORT_REVISION}}'
|
1564
|
+
dockerfile: Test.Dockerfile
|
1565
|
+
stage: "build"
|
1566
|
+
|
1567
|
+
run_tests:
|
1568
|
+
stage: "tests"
|
1569
|
+
image: '${{BuildTestDockerImage}}'
|
1570
|
+
working_directory: /src
|
1571
|
+
fail_fast: false
|
1572
|
+
environment:
|
1573
|
+
- RAILS_ENV=test
|
1574
|
+
# set how many parallel jobs you want to run
|
1575
|
+
- KNAPSACK_PRO_CI_NODE_TOTAL=2
|
1576
|
+
- PGHOST=postgres
|
1577
|
+
- PGUSER=rails-app-with-knapsack_pro
|
1578
|
+
- PGPASSWORD=password
|
1579
|
+
services:
|
1580
|
+
composition:
|
1581
|
+
postgres:
|
1582
|
+
image: postgres:latest
|
1583
|
+
environment:
|
1584
|
+
- POSTGRES_DB=rails-app-with-knapsack_pro_test
|
1585
|
+
- POSTGRES_PASSWORD=password
|
1586
|
+
- POSTGRES_USER=rails-app-with-knapsack_pro
|
1587
|
+
ports:
|
1588
|
+
- 5432
|
1589
|
+
matrix:
|
1590
|
+
environment:
|
1591
|
+
# please ensure you have here listed N-1 indexes
|
1592
|
+
# where N is KNAPSACK_PRO_CI_NODE_TOTAL
|
1593
|
+
- KNAPSACK_PRO_CI_NODE_INDEX=0
|
1594
|
+
- KNAPSACK_PRO_CI_NODE_INDEX=1
|
1595
|
+
commands:
|
1596
|
+
- bin/rails db:prepare
|
1597
|
+
|
1598
|
+
# run tests in Knapsack Pro Regular Mode
|
1599
|
+
- bundle exec rake knapsack_pro:rspec
|
1600
|
+
- bundle exec rake knapsack_pro:cucumber
|
1601
|
+
- bundle exec rake knapsack_pro:minitest
|
1602
|
+
- bundle exec rake knapsack_pro:test_unit
|
1603
|
+
- bundle exec rake knapsack_pro:spinach
|
1604
|
+
|
1605
|
+
# you can use Knapsack Pro in Queue Mode once recorded first CI build with Regular Mode
|
1606
|
+
- bundle exec rake knapsack_pro:queue:rspec
|
1607
|
+
- bundle exec rake knapsack_pro:queue:cucumber
|
1608
|
+
- bundle exec rake knapsack_pro:queue:minitest
|
1609
|
+
```
|
1610
|
+
|
1611
|
+
Add `Test.Dockerfile` to your project repository.
|
1612
|
+
|
1613
|
+
```Dockerfile
|
1614
|
+
# Test.Dockerfile
|
1615
|
+
FROM ruby:2.6.5-alpine3.10
|
1616
|
+
|
1617
|
+
# Prepare Docker image for Nokogiri
|
1618
|
+
RUN apk add --update \
|
1619
|
+
build-base \
|
1620
|
+
libxml2-dev \
|
1621
|
+
libxslt-dev \
|
1622
|
+
jq \
|
1623
|
+
nodejs \
|
1624
|
+
npm \
|
1625
|
+
postgresql-dev \
|
1626
|
+
python3-dev \
|
1627
|
+
sqlite-dev \
|
1628
|
+
git \
|
1629
|
+
&& rm -rf /var/cache/apk/*
|
1630
|
+
|
1631
|
+
# Install AWS CLI
|
1632
|
+
RUN pip3 install awscli
|
1633
|
+
|
1634
|
+
# Use libxml2, libxslt a packages from alpine for building nokogiri
|
1635
|
+
RUN bundle config build.nokogiri --use-system-libraries
|
1636
|
+
|
1637
|
+
# Install Codefresh CLI
|
1638
|
+
RUN wget https://github.com/codefresh-io/cli/releases/download/v0.31.1/codefresh-v0.31.1-alpine-x64.tar.gz
|
1639
|
+
RUN tar -xf codefresh-v0.31.1-alpine-x64.tar.gz -C /usr/local/bin/
|
1640
|
+
|
1641
|
+
COPY . /src
|
1642
|
+
|
1643
|
+
WORKDIR /src
|
1644
|
+
|
1645
|
+
RUN bundle install
|
1646
|
+
```
|
1647
|
+
|
1504
1648
|
## FAQ
|
1505
1649
|
|
1506
1650
|
### Common problems
|
@@ -1896,6 +2040,51 @@ bundle exec rspec --seed 11055 --default-path spec "spec/a_spec.rb" "spec/b_spec
|
|
1896
2040
|
|
1897
2041
|
If you don't use RSpec argument `--order random` then you don't need to provide `--seed` number when you want to reproduce tests in development.
|
1898
2042
|
|
2043
|
+
##### How to configure puffing-billy gem with Knapsack Pro Queue Mode?
|
2044
|
+
|
2045
|
+
If you use [puffing-billy](https://github.com/oesmith/puffing-billy) gem you may notice [puffing-billy may crash](https://github.com/oesmith/puffing-billy/issues/253). It happen due to the way how knapsack_pro in Queue Mode uses `RSpec::Core::Runner` ([see](#why-when-i-use-queue-mode-for-rspec-then-my-tests-fail)).
|
2046
|
+
|
2047
|
+
Here is a patch for puffing-billy to make it work in knapsack_pro Queue Mode:
|
2048
|
+
|
2049
|
+
```ruby
|
2050
|
+
# rails_helper.rb or spec_helper.rb
|
2051
|
+
|
2052
|
+
# A patch to `puffing-billy`'s proxy so that it doesn't try to stop
|
2053
|
+
# eventmachine's reactor if it's not running.
|
2054
|
+
module BillyProxyPatch
|
2055
|
+
def stop
|
2056
|
+
return unless EM.reactor_running?
|
2057
|
+
super
|
2058
|
+
end
|
2059
|
+
end
|
2060
|
+
Billy::Proxy.prepend(BillyProxyPatch)
|
2061
|
+
|
2062
|
+
# A patch to `puffing-billy` to start EM if it has been stopped
|
2063
|
+
Billy.module_eval do
|
2064
|
+
def self.proxy
|
2065
|
+
if @billy_proxy.nil? || !(EventMachine.reactor_running? && EventMachine.reactor_thread.alive?)
|
2066
|
+
proxy = Billy::Proxy.new
|
2067
|
+
proxy.start
|
2068
|
+
@billy_proxy = proxy
|
2069
|
+
else
|
2070
|
+
@billy_proxy
|
2071
|
+
end
|
2072
|
+
end
|
2073
|
+
end
|
2074
|
+
|
2075
|
+
if ENV["KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC"]
|
2076
|
+
KnapsackPro::Hooks::Queue.before_queue do
|
2077
|
+
# executes before Queue Mode starts work
|
2078
|
+
Billy.proxy.start
|
2079
|
+
end
|
2080
|
+
|
2081
|
+
KnapsackPro::Hooks::Queue.after_queue do
|
2082
|
+
# executes after Queue Mode finishes work
|
2083
|
+
Billy.proxy.stop
|
2084
|
+
end
|
2085
|
+
end
|
2086
|
+
```
|
2087
|
+
|
1899
2088
|
### General questions
|
1900
2089
|
|
1901
2090
|
#### How to run tests for particular CI node in your development environment
|
@@ -2298,7 +2487,7 @@ Here is example:
|
|
2298
2487
|
|
2299
2488
|
* Step 1. API_KEY_A for `bundle exec rake knapsack_pro:cucumber`
|
2300
2489
|
* Step 2. API_KEY_B for `bundle exec rake knapsack_pro:rspec`
|
2301
|
-
* Step 3. API_KEY_C for `KNAPSACK_PRO_TEST_FILE_PATTERN="
|
2490
|
+
* Step 3. API_KEY_C for `KNAPSACK_PRO_TEST_FILE_PATTERN="spec/features/*_spec.rb" bundle exec rake knapsack_pro:rspec`
|
2302
2491
|
* Step 4. API_KEY_D for `bundle exec rake knapsack_pro:rspec[--tag tagA]`
|
2303
2492
|
* Step 5. API_KEY_E for `bundle exec rake knapsack_pro:rspec[--tag ~tagA]`
|
2304
2493
|
* Step 6. API_KEY_F for `bundle exec rake knapsack_pro:queue:rspec`
|
@@ -2335,11 +2524,14 @@ You will run your javascript tests on single CI node and the knapsack_pro will a
|
|
2335
2524
|
|
2336
2525
|
#### How to set `before(:suite)` and `after(:suite)` RSpec hooks in Queue Mode (Percy.io example)?
|
2337
2526
|
|
2527
|
+
##### percy-capybara gem version < 4 (old)
|
2528
|
+
|
2338
2529
|
Some tools like [Percy.io](https://percy.io/docs/clients/ruby/capybara-rails) requires to set hooks for RSpec `before(:suite)` and `after(:suite)`.
|
2339
2530
|
Knapsack Pro Queue Mode runs subset of test files from the work queue many times. This means the RSpec hooks `before(:suite)` and `after(:suite)` will execute multiple times. If you want to run some code only once before Queue Mode starts work and after it finishes then you should do it this way:
|
2340
2531
|
|
2341
2532
|
```ruby
|
2342
2533
|
# spec_helper.rb or rails_helper.rb
|
2534
|
+
# step for percy-capybara gem version < 4
|
2343
2535
|
|
2344
2536
|
KnapsackPro::Hooks::Queue.before_queue do |queue_id|
|
2345
2537
|
# executes before Queue Mode starts work
|
@@ -2352,6 +2544,32 @@ KnapsackPro::Hooks::Queue.after_queue do |queue_id|
|
|
2352
2544
|
end
|
2353
2545
|
```
|
2354
2546
|
|
2547
|
+
##### percy-capybara gem version >= 4
|
2548
|
+
|
2549
|
+
If you use [percy-capybara 4.x](https://docs.percy.io/v1/docs/capybara) then you don't need to set RSpec hooks. Insted you need to run knapsack_pro via percy npm command.
|
2550
|
+
|
2551
|
+
```
|
2552
|
+
npx percy exec -- rake knapsack_pro:queue:rspec
|
2553
|
+
|
2554
|
+
# or you can use knapsack_pro binary version instead of rake task
|
2555
|
+
npx percy exec -- knapsack_pro queue:rspec
|
2556
|
+
```
|
2557
|
+
|
2558
|
+
Read more about [knapsack_pro binary version](#knapsack-pro-binary).
|
2559
|
+
|
2560
|
+
Also you need to follow [Percy step for parallelism](https://docs.percy.io/docs/parallel-test-suites#section-manual-configuration-with-environment-variables).
|
2561
|
+
|
2562
|
+
* `PERCY_PARALLEL_NONCE` - A unique identifier for this build. This can be anything, but it must be the same across parallel build nodes. Usually, this is just the CI build number or a shared timestamp. You can google environment variables for CI provider you use to check what's the env var for build ID.
|
2563
|
+
|
2564
|
+
You can also find CI build number for your CI provider in [knapsack_pro source code](https://github.com/KnapsackPro/knapsack_pro-ruby/tree/master/lib/knapsack_pro/config/ci). knapsack_pro has built in environment variables integration for various CI providers. See for example [CircleCI](https://github.com/KnapsackPro/knapsack_pro-ruby/blob/master/lib/knapsack_pro/config/ci/circle.rb) - look for method `node_build_id`.
|
2565
|
+
|
2566
|
+
```bash
|
2567
|
+
# example for using CircleCI build ID
|
2568
|
+
export PERCY_PARALLEL_NONCE=$CIRCLE_BUILD_NUM
|
2569
|
+
```
|
2570
|
+
|
2571
|
+
* `PERCY_PARALLEL_TOTAL` - The total number of parallel build nodes.
|
2572
|
+
|
2355
2573
|
#### How to call `before(:suite)` and `after(:suite)` RSpec hooks only once in Queue Mode?
|
2356
2574
|
|
2357
2575
|
Knapsack Pro Queue Mode runs subset of test files from the work queue many times. This means the RSpec hooks `before(:suite)` and `after(:suite)` will be executed multiple times. If you want to run some code only once before Queue Mode starts work and after it finishes then you should do it this way:
|
@@ -2732,7 +2950,7 @@ If you use for instance Heroku CI that allows you to provide only one test comma
|
|
2732
2950
|
# $ chmod a+x bin/knapsack_pro_rspec_and_npm_test
|
2733
2951
|
|
2734
2952
|
# 15 is last CI node (index starts from 0, so in total we have 16 parallel Heroku dynos)
|
2735
|
-
if [ "$
|
2953
|
+
if [ "$CI_NODE_INDEX" == "15" ]; then
|
2736
2954
|
# run npm tests on the last CI node
|
2737
2955
|
npm test
|
2738
2956
|
else
|
data/lib/knapsack_pro.rb
CHANGED
@@ -14,6 +14,7 @@ require_relative 'knapsack_pro/config/ci/base'
|
|
14
14
|
require_relative 'knapsack_pro/config/ci/app_veyor'
|
15
15
|
require_relative 'knapsack_pro/config/ci/circle'
|
16
16
|
require_relative 'knapsack_pro/config/ci/cirrus_ci'
|
17
|
+
require_relative 'knapsack_pro/config/ci/codefresh'
|
17
18
|
require_relative 'knapsack_pro/config/ci/gitlab_ci'
|
18
19
|
require_relative 'knapsack_pro/config/ci/semaphore'
|
19
20
|
require_relative 'knapsack_pro/config/ci/semaphore2'
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# https://codefresh.io/docs/docs/codefresh-yaml/variables/#system-provided-variables
|
2
|
+
module KnapsackPro
|
3
|
+
module Config
|
4
|
+
module CI
|
5
|
+
class Codefresh < Base
|
6
|
+
def node_total
|
7
|
+
# not provided
|
8
|
+
end
|
9
|
+
|
10
|
+
def node_index
|
11
|
+
# not provided
|
12
|
+
end
|
13
|
+
|
14
|
+
def node_build_id
|
15
|
+
ENV['CF_BUILD_ID']
|
16
|
+
end
|
17
|
+
|
18
|
+
def commit_hash
|
19
|
+
ENV['CF_REVISION']
|
20
|
+
end
|
21
|
+
|
22
|
+
def branch
|
23
|
+
ENV['CF_BRANCH']
|
24
|
+
end
|
25
|
+
|
26
|
+
def project_dir
|
27
|
+
# not provided
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/knapsack_pro/version.rb
CHANGED
@@ -0,0 +1,66 @@
|
|
1
|
+
describe KnapsackPro::Config::CI::Codefresh do
|
2
|
+
let(:env) { {} }
|
3
|
+
|
4
|
+
before do
|
5
|
+
stub_const('ENV', env)
|
6
|
+
end
|
7
|
+
|
8
|
+
it { should be_kind_of KnapsackPro::Config::CI::Base }
|
9
|
+
|
10
|
+
describe '#node_total' do
|
11
|
+
subject { described_class.new.node_total }
|
12
|
+
|
13
|
+
it { should be nil }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#node_index' do
|
17
|
+
subject { described_class.new.node_index }
|
18
|
+
|
19
|
+
it { should be nil }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#node_build_id' do
|
23
|
+
subject { described_class.new.node_build_id }
|
24
|
+
|
25
|
+
context 'when environment exists' do
|
26
|
+
let(:env) { { 'CF_BUILD_ID' => '1005' } }
|
27
|
+
it { should eql '1005' }
|
28
|
+
end
|
29
|
+
|
30
|
+
context "when environment doesn't exist" do
|
31
|
+
it { should be nil }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#commit_hash' do
|
36
|
+
subject { described_class.new.commit_hash }
|
37
|
+
|
38
|
+
context 'when environment exists' do
|
39
|
+
let(:env) { { 'CF_REVISION' => 'b624067a61d2134df1db74ebdabb1d8d' } }
|
40
|
+
it { should eql 'b624067a61d2134df1db74ebdabb1d8d' }
|
41
|
+
end
|
42
|
+
|
43
|
+
context "when environment doesn't exist" do
|
44
|
+
it { should be nil }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#branch' do
|
49
|
+
subject { described_class.new.branch }
|
50
|
+
|
51
|
+
context 'when environment exists' do
|
52
|
+
let(:env) { { 'CF_BRANCH' => 'codefresh-branch' } }
|
53
|
+
it { should eql 'codefresh-branch' }
|
54
|
+
end
|
55
|
+
|
56
|
+
context "when environment doesn't exist" do
|
57
|
+
it { should be nil }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '#project_dir' do
|
62
|
+
subject { described_class.new.project_dir }
|
63
|
+
|
64
|
+
it { should be nil }
|
65
|
+
end
|
66
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knapsack_pro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ArturT
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -240,6 +240,7 @@ files:
|
|
240
240
|
- lib/knapsack_pro/config/ci/buildkite.rb
|
241
241
|
- lib/knapsack_pro/config/ci/circle.rb
|
242
242
|
- lib/knapsack_pro/config/ci/cirrus_ci.rb
|
243
|
+
- lib/knapsack_pro/config/ci/codefresh.rb
|
243
244
|
- lib/knapsack_pro/config/ci/codeship.rb
|
244
245
|
- lib/knapsack_pro/config/ci/github_actions.rb
|
245
246
|
- lib/knapsack_pro/config/ci/gitlab_ci.rb
|
@@ -325,6 +326,7 @@ files:
|
|
325
326
|
- spec/knapsack_pro/config/ci/buildkite_spec.rb
|
326
327
|
- spec/knapsack_pro/config/ci/circle_spec.rb
|
327
328
|
- spec/knapsack_pro/config/ci/cirrus_ci_spec.rb
|
329
|
+
- spec/knapsack_pro/config/ci/codefresh_spec.rb
|
328
330
|
- spec/knapsack_pro/config/ci/codeship_spec.rb
|
329
331
|
- spec/knapsack_pro/config/ci/github_actions_spec.rb
|
330
332
|
- spec/knapsack_pro/config/ci/gitlab_ci_spec.rb
|
@@ -405,7 +407,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
405
407
|
- !ruby/object:Gem::Version
|
406
408
|
version: '0'
|
407
409
|
requirements: []
|
408
|
-
rubygems_version: 3.0.
|
410
|
+
rubygems_version: 3.0.6
|
409
411
|
signing_key:
|
410
412
|
specification_version: 4
|
411
413
|
summary: Knapsack Pro splits tests across parallel CI nodes and ensures each parallel
|
@@ -437,6 +439,7 @@ test_files:
|
|
437
439
|
- spec/knapsack_pro/config/ci/buildkite_spec.rb
|
438
440
|
- spec/knapsack_pro/config/ci/circle_spec.rb
|
439
441
|
- spec/knapsack_pro/config/ci/cirrus_ci_spec.rb
|
442
|
+
- spec/knapsack_pro/config/ci/codefresh_spec.rb
|
440
443
|
- spec/knapsack_pro/config/ci/codeship_spec.rb
|
441
444
|
- spec/knapsack_pro/config/ci/github_actions_spec.rb
|
442
445
|
- spec/knapsack_pro/config/ci/gitlab_ci_spec.rb
|