Skip to content
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
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Change Log

### 2.0.0

* Add support for CI build ID for Github Actions

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

__Migration path for Github Actions users - required__

If you use Github Actions and Knapsack Pro Queue Mode then you must set in Github Actions environment variable: `KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true`. Thanks to that when you retry CI build then tests will run based on previously recorded tests. This solves problem mentioned in the [PR](https://github.com/KnapsackPro/knapsack_pro-ruby/pull/116).

__Migration path for other users__ - just update `knapsack_pro` gem. Nothing to change in your code :)

https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v1.22.3...v2.0.0

### 1.22.3

* Support for non-delimited formatting params of RSpec like `-fMyCustomFormatter`
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1639,6 +1639,9 @@ jobs:
KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC: ${{ secrets.KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC }}
KNAPSACK_PRO_CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
KNAPSACK_PRO_CI_NODE_INDEX: ${{ matrix.ci_node_index }}
# if you use Knapsack Pro Queue Mode you must set below env variable
# to be able to retry CI build and run previously recorded tests
KNAPSACK_PRO_FIXED_QUEUE_SPLIT: true
run: |
# run tests in Knapsack Pro Regular Mode
bundle exec rake knapsack_pro:rspec
Expand Down
5 changes: 3 additions & 2 deletions lib/knapsack_pro/config/ci/github_actions.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# https://help.github.com/en/articles/virtual-environments-for-github-actions#environment-variables
# https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
module KnapsackPro
module Config
module CI
Expand All @@ -12,7 +12,8 @@ def node_index
end

def node_build_id
# not provided
# A unique number for each run within a repository. This number does not change if you re-run the workflow run.
ENV['GITHUB_RUN_ID']
end

def commit_hash
Expand Down
9 changes: 8 additions & 1 deletion spec/knapsack_pro/config/ci/github_actions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@
describe '#node_build_id' do
subject { described_class.new.node_build_id }

it { should be nil }
context 'when environment exists' do
let(:env) { { 'GITHUB_RUN_ID' => 2706 } }
it { should eql 2706 }
end

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

describe '#commit_hash' do
Expand Down