selective-ruby-core 0.2.0-x86_64-linux → 0.2.2-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fdb083ff41ad745a6088ebc292f5f00abebacfa64b6cae83434b9ceb155b0935
4
- data.tar.gz: 76a45629bc7ee9b8e4e08e1179a8134e1d9714f47b91e1463196be9aead33831
3
+ metadata.gz: 0b4696012125323f44de397fe520cd5f37770a7182ad3df3a69f0cf10d4cbbf0
4
+ data.tar.gz: 2c1ea6d1eb4d118ec556b1989f298a350c583789c6d5cf85e901605e7487e622
5
5
  SHA512:
6
- metadata.gz: adcf129a879357453b9b96d1d5bbfb9d98bb4cd675a517662b4d4acd73e3e143fe9a7706bc1d20716adb05ca11f4ca8d0a5864c101ef3c10fb046256f81b1050
7
- data.tar.gz: e1186135b661ed5f094466f42db535372ecc4d1f710ea97497407274decef630d954339d480e4046e590b2eb37a12738e56a15b7ca8ac63ced1e34d7565feb7d
6
+ metadata.gz: e3382682940c2c4293c88e5b3cfaad302245bcb8f6505686d199a742d5bf12bfda3c983e8d8a8922ad0662c209050f8024dc09ce92cc3a8a6a2c3ad6f031e87a
7
+ data.tar.gz: 674a0719f90878cffdfad02c630369991a53bc84c4794754af5edbaad3a2f30f42210e1946b5b6e0b108563b5a5cd91b735e76664db4c667272c48e950775aab
data/lib/bin/build_env.sh CHANGED
@@ -3,31 +3,32 @@
3
3
  # Detect the platform (only GitHub Actions in this case)
4
4
  if [ -n "$GITHUB_ACTIONS" ]; then
5
5
  platform=github_actions
6
- branch=${SELECTIVE_BRANCH:-${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}}
7
- target_branch=${SELECTIVE_TARGET_BRANCH:-$GITHUB_BASE_REF}
6
+ branch=${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}
7
+ target_branch=$GITHUB_BASE_REF
8
8
  actor=$GITHUB_ACTOR
9
- sha=${SELECTIVE_SHA:-$GITHUB_SHA}
10
- run_id=${SELECTIVE_RUN_ID:-$GITHUB_RUN_ID}
11
- run_attempt=${SELECTIVE_RUN_ATTEMPT:-$GITHUB_RUN_ATTEMPT}
9
+ sha=$GITHUB_SHA
10
+ run_id=$GITHUB_RUN_ID
11
+ run_attempt=$GITHUB_RUN_ATTEMPT
12
12
  runner_id=$SELECTIVE_RUNNER_ID
13
13
  elif [ -n "$CIRCLECI" ]; then
14
14
  platform=circleci
15
- branch=${SELECTIVE_BRANCH:-$CIRCLE_BRANCH}
16
- target_branch=$SELECTIVE_TARGET_BRANCH
17
- actor=${SELECTIVE_ACTOR:-${CIRCLE_USERNAME:-$CIRCLE_PR_USERNAME}}
18
- sha=${SELECTIVE_SHA:-$CIRCLE_SHA1}
19
- run_id=$SELECTIVE_RUN_ID
20
- run_attempt=${SELECTIVE_RUN_ATTEMPT:-$CIRCLE_BUILD_NUM}
21
- runner_id=${SELECTIVE_RUNNER_ID:-$CIRCLE_NODE_INDEX}
22
- else
23
- platform=$SELECTIVE_PLATFORM
24
- branch=$SELECTIVE_BRANCH
25
- target_branch=$SELECTIVE_TARGET_BRANCH
26
- actor=$SELECTIVE_ACTOR
27
- sha=$SELECTIVE_SHA
28
- run_id=$SELECTIVE_RUN_ID
29
- run_attempt=$SELECTIVE_RUN_ATTEMPT
30
- runner_id=$SELECTIVE_RUNNER_ID
15
+ branch=$CIRCLE_BRANCH
16
+ actor=${CIRCLE_USERNAME:-$CIRCLE_PR_USERNAME}
17
+ sha=$CIRCLE_SHA1
18
+ run_attempt=$CIRCLE_BUILD_NUM
19
+ runner_id=$CIRCLE_NODE_INDEX
20
+ elif [ -n "$SEMAPHORE" ]; then
21
+ platform=semaphore
22
+ branch=${SEMAPHORE_GIT_PR_BRANCH:-$SEMAPHORE_GIT_BRANCH}
23
+ if [ -n "$SEMAPHORE_GIT_PR_BRANCH" ]; then
24
+ target_branch=$SEMAPHORE_GIT_BRANCH
25
+ fi
26
+ actor=$SEMAPHORE_GIT_COMMITTER
27
+ sha=$SEMAPHORE_GIT_SHA
28
+ run_id=$SEMAPHORE_WORKFLOW_ID
29
+ run_attempt=1
30
+ runner_id=$SEMAPHORE_JOB_ID
31
+ pr_title=$SEMAPHORE_GIT_PR_NAME
31
32
  fi
32
33
 
33
34
  # Output the JSON
@@ -35,16 +36,16 @@ cat <<EOF
35
36
  {
36
37
  "api_key": "$SELECTIVE_API_KEY",
37
38
  "host": "${SELECTIVE_HOST:-wss://app.selective.ci}",
38
- "platform": "$platform",
39
- "branch": "$branch",
40
- "pr_title": "$SELECTIVE_PR_TITLE",
41
- "target_branch": "$target_branch",
42
- "actor": "$actor",
43
- "sha": "$sha",
44
- "run_id": "$run_id",
45
- "run_attempt": "$run_attempt",
39
+ "platform": "${SELECTIVE_PLATFORM:-$platform}",
40
+ "branch": "${SELECTIVE_BRANCH:-$branch}",
41
+ "pr_title": "${SELECTIVE_PR_TITLE:-$pr_title}",
42
+ "target_branch": "${SELECTIVE_TARGET_BRANCH:-$target_branch}",
43
+ "actor": "${SELECTIVE_ACTOR:-$actor}",
44
+ "sha": "${SELECTIVE_SHA:-$sha}",
45
+ "run_id": "${SELECTIVE_RUN_ID:-$run_id}",
46
+ "run_attempt": "${SELECTIVE_RUN_ATTEMPT:-$run_attempt}",
47
+ "runner_id": "${SELECTIVE_RUNNER_ID:-$runner_id}",
46
48
  "commit_message": "$(git log --format=%s -n 1 $sha)",
47
- "runner_id": "$runner_id",
48
49
  "committer_name": "$(git show -s --format='%an' -n 1 $sha)",
49
50
  "committer_email": "$(git show -s --format='%ae' -n 1 $sha)"
50
51
  }
@@ -14,12 +14,13 @@ module Selective
14
14
  "api_key" => "SELECTIVE_API_KEY",
15
15
  "platform" => "SELECTIVE_PLATFORM",
16
16
  "run_id" => "SELECTIVE_RUN_ID",
17
+ "run_attempt" => "SELECTIVE_RUN_ATTEMPT",
17
18
  "branch" => "SELECTIVE_BRANCH"
18
19
  }.freeze
19
20
 
20
- def initialize(runner, debug: false, log: false)
21
+ def initialize(runner_class, runner_args, debug: false, log: false)
21
22
  @debug = debug
22
- @runner = runner
23
+ @runner = runner_class.new(runner_args, method(:test_case_callback))
23
24
  @retries = 0
24
25
  @runner_id = safe_filename(get_runner_id)
25
26
  @logger = init_logger(log)
@@ -113,7 +114,6 @@ module Selective
113
114
  host = build_env.delete("host")
114
115
  run_id = build_env.delete("run_id")
115
116
  run_attempt = build_env.delete("run_attempt")
116
- run_attempt = SecureRandom.uuid if run_attempt.nil? || run_attempt.empty?
117
117
 
118
118
  params = {
119
119
  "run_id" => run_id,
@@ -267,7 +267,7 @@ module Selective
267
267
  end
268
268
 
269
269
  def handle_run_test_cases(data)
270
- runner.run_test_cases(data[:test_case_ids], method(:test_case_callback))
270
+ runner.run_test_cases(data[:test_case_ids])
271
271
  end
272
272
 
273
273
  def handle_remove_failed_test_case_result(data)
@@ -17,7 +17,10 @@ module Selective
17
17
  def correlate
18
18
  JSON.parse(get_correlated_files, symbolize_names: true)
19
19
  rescue FileCorrelatorError, JSON::ParserError
20
- print_warning "Selective was unable to correlate the diff to test files. This may result in a sub-optimal test order. If the issue persists, please contact support."
20
+ print_warning(<<~MSG)
21
+ Selective was unable to correlate the diff to test files. This may result in a sub-optimal test order.
22
+ If the issue persists, please contact support.
23
+ MSG
21
24
  end
22
25
 
23
26
  private
@@ -3,7 +3,7 @@
3
3
  module Selective
4
4
  module Ruby
5
5
  module Core
6
- VERSION = "0.2.0"
6
+ VERSION = "0.2.2"
7
7
  end
8
8
  end
9
9
  end
@@ -44,7 +44,7 @@ module Selective
44
44
  attr_reader :debug, :log, :runner_name, :args, :command
45
45
 
46
46
  def run
47
- Selective::Ruby::Core::Controller.new(runner, debug: debug, log: log).send(command)
47
+ Selective::Ruby::Core::Controller.new(runner_class, args, debug: debug, log: log).send(command)
48
48
  end
49
49
 
50
50
  def parse_args(args)
@@ -56,8 +56,8 @@ module Selective
56
56
  end
57
57
  end
58
58
 
59
- def runner
60
- Selective::Ruby::Core.runner_for(runner_name).new(args)
59
+ def runner_class
60
+ Selective::Ruby::Core.runner_for(runner_name)
61
61
  end
62
62
 
63
63
  def require_runner
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selective-ruby-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Benjamin Wood
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2024-01-13 00:00:00.000000000 Z
12
+ date: 2024-01-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: zeitwerk