cucumber-ci-environment 9.0.1 → 9.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1cc542bd3cd0d027c8a6c7bcd3283540ad5422dffadef3e7dd45782ba1b210d
|
4
|
+
data.tar.gz: 76d7a0f4c685b44b0a4a4fcb63c9c372cb2e1675daa9459574cac6180d67418a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f4d2fa7fa571d1ea22a28e2104ad0c79bd638fa82bbfc7455d847aa7f6e55c9e72360166f5632d186babcbd6dca67c0fd983c4b9671abb37248f88876d55fa9
|
7
|
+
data.tar.gz: c8f5b94aec624580f1a1585139b8ca2bd4ff000498eea1e7f93445fb862ffa3ab1e5d1719b45edb734df3b3cfb660c05a2852be98606113bd884da72b84b92a1
|
@@ -7,17 +7,17 @@ module Cucumber
|
|
7
7
|
extend VariableExpression
|
8
8
|
CI_ENVIRONMENTS_PATH = File.join(File.dirname(__FILE__), 'ci_environment/CiEnvironments.json')
|
9
9
|
|
10
|
-
def detect_ci_environment(env
|
11
|
-
ci_environments = JSON.parse(
|
10
|
+
def detect_ci_environment(env)
|
11
|
+
ci_environments = JSON.parse(IO.read(CI_ENVIRONMENTS_PATH))
|
12
12
|
ci_environments.each do |ci_environment|
|
13
|
-
detected = detect(ci_environment, env
|
13
|
+
detected = detect(ci_environment, env)
|
14
14
|
return detected unless detected.nil?
|
15
15
|
end
|
16
16
|
|
17
17
|
nil
|
18
18
|
end
|
19
19
|
|
20
|
-
def detect(ci_environment, env
|
20
|
+
def detect(ci_environment, env)
|
21
21
|
url = evaluate(ci_environment['url'], env)
|
22
22
|
return nil if url.nil?
|
23
23
|
|
@@ -27,13 +27,13 @@ module Cucumber
|
|
27
27
|
buildNumber: evaluate(ci_environment['buildNumber'], env),
|
28
28
|
}
|
29
29
|
|
30
|
-
detected_git = detect_git(ci_environment, env
|
30
|
+
detected_git = detect_git(ci_environment, env)
|
31
31
|
result[:git] = detected_git if detected_git
|
32
32
|
result
|
33
33
|
end
|
34
34
|
|
35
|
-
def detect_git(ci_environment, env
|
36
|
-
revision = detect_revision(ci_environment, env
|
35
|
+
def detect_git(ci_environment, env)
|
36
|
+
revision = detect_revision(ci_environment, env)
|
37
37
|
return nil if revision.nil?
|
38
38
|
|
39
39
|
remote = evaluate(ci_environment['git']['remote'], env)
|
@@ -51,12 +51,13 @@ module Cucumber
|
|
51
51
|
git_info
|
52
52
|
end
|
53
53
|
|
54
|
-
def detect_revision(ci_environment, env
|
54
|
+
def detect_revision(ci_environment, env)
|
55
55
|
if env['GITHUB_EVENT_NAME'] == 'pull_request'
|
56
56
|
raise StandardError('GITHUB_EVENT_PATH not set') unless env['GITHUB_EVENT_PATH']
|
57
|
-
event = JSON.parse(
|
58
|
-
|
59
|
-
|
57
|
+
event = JSON.parse(IO.read(env['GITHUB_EVENT_PATH']))
|
58
|
+
revision = event['pull_request']['head']['sha'] rescue nil
|
59
|
+
raise StandardError("Could not find .pull_request.head.sha in #{env['GITHUB_EVENT_PATH']}:\n#{JSON.pretty_generate(event)}") if revision.nil?
|
60
|
+
return revision
|
60
61
|
end
|
61
62
|
|
62
63
|
return evaluate(ci_environment['git']['revision'], env)
|
@@ -8,12 +8,7 @@ describe 'detect_ci_environment' do
|
|
8
8
|
context "with #{File.basename(test_data_file, '.txt')}" do
|
9
9
|
subject { JSON.parse(ci_environment.to_json) }
|
10
10
|
|
11
|
-
|
12
|
-
return '{"before": "2436f28fad432a895bfc595bce16e907144b0dc3"}' if path.end_with?('_github_workflow/event.json')
|
13
|
-
IO.read(path)
|
14
|
-
end
|
15
|
-
|
16
|
-
let(:ci_environment) { Cucumber::CiEnvironment.detect_ci_environment(env, method(:mock_reader)) }
|
11
|
+
let(:ci_environment) { Cucumber::CiEnvironment.detect_ci_environment(env) }
|
17
12
|
let(:env) { Hash[entries] }
|
18
13
|
let(:entries) { env_data.split(/\n/).map { |line| line.split(/=/) } }
|
19
14
|
let(:env_data) { IO.read(test_data_file) }
|
@@ -0,0 +1,10 @@
|
|
1
|
+
describe 'GitHub' do
|
2
|
+
if (ENV['GITHUB_EVENT_NAME'] == 'pull_request')
|
3
|
+
it 'detects the correct revision for pull requests' do
|
4
|
+
ci_environment = Cucumber::CiEnvironment.detect_ci_environment(ENV)
|
5
|
+
expect(ci_environment).to be_truthy
|
6
|
+
puts ("Manually verify that the revision is correct");
|
7
|
+
p ci_environment
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber-ci-environment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.0.
|
4
|
+
version: 9.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Prêtre
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- spec/capture_warnings.rb
|
64
64
|
- spec/cucumber/ci_environment/ci_environment_spec.rb
|
65
65
|
- spec/cucumber/ci_environment/evaluate_variable_expression_spec.rb
|
66
|
+
- spec/cucumber/ci_environment/github_pull_request_integration_spec.rb
|
66
67
|
- spec/cucumber/ci_environment/remove_userinfo_from_url_spec.rb
|
67
68
|
homepage: https://github.com/cucumber/ci-environment
|
68
69
|
licenses:
|
@@ -92,9 +93,10 @@ requirements: []
|
|
92
93
|
rubygems_version: 3.2.32
|
93
94
|
signing_key:
|
94
95
|
specification_version: 4
|
95
|
-
summary: cucumber-ci-environment-9.0.
|
96
|
+
summary: cucumber-ci-environment-9.0.4
|
96
97
|
test_files:
|
97
98
|
- spec/capture_warnings.rb
|
98
99
|
- spec/cucumber/ci_environment/ci_environment_spec.rb
|
99
100
|
- spec/cucumber/ci_environment/evaluate_variable_expression_spec.rb
|
101
|
+
- spec/cucumber/ci_environment/github_pull_request_integration_spec.rb
|
100
102
|
- spec/cucumber/ci_environment/remove_userinfo_from_url_spec.rb
|