cucumber-ci-environment 7.0.1
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 +7 -0
- data/LICENSE +21 -0
- data/lib/cucumber/ci_environment/CiEnvironments.json +156 -0
- data/lib/cucumber/ci_environment/variable_expression.rb +41 -0
- data/lib/cucumber/ci_environment.rb +53 -0
- data/spec/capture_warnings.rb +74 -0
- data/spec/cucumber/ci_environment/ci_environment_spec.rb +21 -0
- data/spec/cucumber/ci_environment/evaluate_variable_expression_spec.rb +38 -0
- data/spec/cucumber/ci_environment/remove_userinfo_from_url_spec.rb +29 -0
- metadata +100 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: '08f1292f1769293e6a36074f11d1561867548ea7ab0b022a79a2fb8b498fb216'
|
|
4
|
+
data.tar.gz: 62e9581ab78df2ce86fa985e8707f2ab917b6bbe749ea5f37d30c39584dae175
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 4431d3d58c2765b18dedd19a923da52a8ddc14cc357c88b6d0aae02bda31fbd78bdf868144cd04fd12f0ccc47766ca3a75e8957aed45d8ef352ba27a1beae613
|
|
7
|
+
data.tar.gz: '09d0faa39b92ebe95301e16c30b3bce2a03ed11cc94458b789a4be2e087d060bfa963428f2990472cfda27fc6ac9c6dbc5585c7906e5638537236e93f0346b60'
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) Cucumber Ltd
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"name": "Azure Pipelines",
|
|
4
|
+
"url": "${BUILD_BUILDURI}",
|
|
5
|
+
"buildNumber": "${BUILD_BUILDNUMBER}",
|
|
6
|
+
"git": {
|
|
7
|
+
"remote": "${BUILD_REPOSITORY_URI}",
|
|
8
|
+
"revision": "${BUILD_SOURCEVERSION}",
|
|
9
|
+
"branch": "${BUILD_SOURCEBRANCH/refs\/heads\/(.*)/\\1}",
|
|
10
|
+
"tag": "${BUILD_SOURCEBRANCH/refs\/tags\/(.*)/\\1}"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "Bamboo",
|
|
15
|
+
"url": "${bamboo_buildResultsUrl}",
|
|
16
|
+
"buildNumber": "${bamboo_buildNumber}",
|
|
17
|
+
"git": {
|
|
18
|
+
"remote": "${bamboo_planRepository_repositoryUrl}",
|
|
19
|
+
"revision": "${bamboo_planRepository_revision}",
|
|
20
|
+
"branch": "${bamboo_planRepository_branch}",
|
|
21
|
+
"tag": null
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "Buddy",
|
|
26
|
+
"url": "${BUDDY_EXECUTION_URL}",
|
|
27
|
+
"buildNumber": "${BUDDY_EXECUTION_ID}",
|
|
28
|
+
"git": {
|
|
29
|
+
"remote": "${BUDDY_SCM_URL}",
|
|
30
|
+
"revision": "${BUDDY_EXECUTION_REVISION}",
|
|
31
|
+
"branch": "${BUDDY_EXECUTION_BRANCH}",
|
|
32
|
+
"tag": "${BUDDY_EXECUTION_TAG}"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"name": "Bitrise",
|
|
37
|
+
"url": "${BITRISE_BUILD_URL}",
|
|
38
|
+
"buildNumber": "${BITRISE_BUILD_NUMBER}",
|
|
39
|
+
"git": {
|
|
40
|
+
"remote": "${GIT_REPOSITORY_URL}",
|
|
41
|
+
"revision": "${BITRISE_GIT_COMMIT}",
|
|
42
|
+
"branch": "${BITRISE_GIT_BRANCH}",
|
|
43
|
+
"tag": "${BITRISE_GIT_TAG}"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"name": "CircleCI",
|
|
48
|
+
"url": "${CIRCLE_BUILD_URL}",
|
|
49
|
+
"buildNumber": "${CIRCLE_BUILD_NUM}",
|
|
50
|
+
"git": {
|
|
51
|
+
"remote": "${CIRCLE_REPOSITORY_URL}",
|
|
52
|
+
"revision": "${CIRCLE_SHA1}",
|
|
53
|
+
"branch": "${CIRCLE_BRANCH}",
|
|
54
|
+
"tag": "${CIRCLE_TAG}"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"name": "CodeFresh",
|
|
59
|
+
"url": "${CF_BUILD_URL}",
|
|
60
|
+
"buildNumber": "${CF_BUILD_ID}",
|
|
61
|
+
"git": {
|
|
62
|
+
"remote": "${CF_COMMIT_URL/(.*)\\/commit.+$/\\1}.git",
|
|
63
|
+
"revision": "${CF_REVISION}",
|
|
64
|
+
"branch": "${CF_BRANCH}",
|
|
65
|
+
"tag": null
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"name": "CodeShip",
|
|
70
|
+
"url": "${CI_BUILD_URL}",
|
|
71
|
+
"buildNumber": "${CI_BUILD_NUMBER}",
|
|
72
|
+
"git": {
|
|
73
|
+
"remote": "${CI_PULL_REQUEST/(.*)\\/pull\\/\\d+/\\1.git}",
|
|
74
|
+
"revision": "${CI_COMMIT_ID}",
|
|
75
|
+
"branch": "${CI_BRANCH}",
|
|
76
|
+
"tag": null
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"name": "GitHub Actions",
|
|
81
|
+
"url": "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}",
|
|
82
|
+
"buildNumber": "${GITHUB_RUN_ID}",
|
|
83
|
+
"git": {
|
|
84
|
+
"remote": "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git",
|
|
85
|
+
"revision": "${GITHUB_SHA}",
|
|
86
|
+
"branch": "${GITHUB_REF/refs\/heads\/(.*)/\\1}",
|
|
87
|
+
"tag": "${GITHUB_REF/refs\/tags\/(.*)/\\1}"
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"name": "GitLab",
|
|
92
|
+
"url": "${CI_JOB_URL}",
|
|
93
|
+
"buildNumber": "${CI_JOB_ID}",
|
|
94
|
+
"git": {
|
|
95
|
+
"remote": "${CI_REPOSITORY_URL}",
|
|
96
|
+
"revision": "${CI_COMMIT_SHA}",
|
|
97
|
+
"branch": "${CI_COMMIT_BRANCH}",
|
|
98
|
+
"tag": "${CI_COMMIT_TAG}"
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"name": "GoCD",
|
|
103
|
+
"url": "${GO_SERVER_URL}/pipelines/${GO_PIPELINE_NAME}/${GO_PIPELINE_COUNTER}/${GO_STAGE_NAME}/${GO_STAGE_COUNTER}",
|
|
104
|
+
"buildNumber": "${GO_PIPELINE_NAME}/${GO_PIPELINE_COUNTER}/${GO_STAGE_NAME}/${GO_STAGE_COUNTER}",
|
|
105
|
+
"git": {
|
|
106
|
+
"remote": "${GO_SCM_*_PR_URL/(.*)\\/pull\\/\\d+/\\1.git}",
|
|
107
|
+
"revision": "${GO_REVISION}",
|
|
108
|
+
"branch": "${GO_SCM_*_PR_BRANCH/.*:(.*)/\\1}",
|
|
109
|
+
"tag": null
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"name": "Jenkins",
|
|
114
|
+
"url": "${BUILD_URL}",
|
|
115
|
+
"buildNumber": "${BUILD_NUMBER}",
|
|
116
|
+
"git": {
|
|
117
|
+
"remote": "${GIT_URL}",
|
|
118
|
+
"revision": "${GIT_COMMIT}",
|
|
119
|
+
"branch": "${GIT_LOCAL_BRANCH}",
|
|
120
|
+
"tag": null
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"name": "Semaphore",
|
|
125
|
+
"url": "${SEMAPHORE_ORGANIZATION_URL}/jobs/${SEMAPHORE_JOB_ID}",
|
|
126
|
+
"buildNumber": "${SEMAPHORE_JOB_ID}",
|
|
127
|
+
"git": {
|
|
128
|
+
"remote": "${SEMAPHORE_GIT_URL}",
|
|
129
|
+
"revision": "${SEMAPHORE_GIT_SHA}",
|
|
130
|
+
"branch": "${SEMAPHORE_GIT_BRANCH}",
|
|
131
|
+
"tag": "${SEMAPHORE_GIT_TAG_NAME}"
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"name": "Travis CI",
|
|
136
|
+
"url": "${TRAVIS_BUILD_WEB_URL}",
|
|
137
|
+
"buildNumber": "${TRAVIS_JOB_NUMBER}",
|
|
138
|
+
"git": {
|
|
139
|
+
"remote": "https://github.com/${TRAVIS_REPO_SLUG}.git",
|
|
140
|
+
"revision": "${TRAVIS_COMMIT}",
|
|
141
|
+
"branch": "${TRAVIS_BRANCH}",
|
|
142
|
+
"tag": "${TRAVIS_TAG}"
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"name": "Wercker",
|
|
147
|
+
"url": "${WERCKER_RUN_URL}",
|
|
148
|
+
"buildNumber": "${WERCKER_RUN_URL/.*\\/([^\\/]+)$/\\1}",
|
|
149
|
+
"git": {
|
|
150
|
+
"remote": "https://${WERCKER_GIT_DOMAIN}/${WERCKER_GIT_OWNER}/${WERCKER_GIT_REPOSITORY}.git",
|
|
151
|
+
"revision": "${WERCKER_GIT_COMMIT}",
|
|
152
|
+
"branch": "${WERCKER_GIT_BRANCH}",
|
|
153
|
+
"tag": null
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
]
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module Cucumber
|
|
2
|
+
module CiEnvironment
|
|
3
|
+
module VariableExpression
|
|
4
|
+
def evaluate(expression, env)
|
|
5
|
+
return nil if expression.nil?
|
|
6
|
+
begin
|
|
7
|
+
expression.gsub(/\${(.*?)(?:(?<!\\)\/(.*)\/(.*))?}/) do
|
|
8
|
+
variable = $1
|
|
9
|
+
pattern = $2
|
|
10
|
+
replacement = $3
|
|
11
|
+
|
|
12
|
+
value = get_value(variable, env)
|
|
13
|
+
raise "Undefined variable #{variable}" if value.nil?
|
|
14
|
+
if pattern.nil?
|
|
15
|
+
value
|
|
16
|
+
else
|
|
17
|
+
regexp = Regexp.new(pattern.gsub('\/', '/'))
|
|
18
|
+
match = value.match(regexp)
|
|
19
|
+
raise "No match for variable #{variable}" if match.nil?
|
|
20
|
+
match[1..-1].each_with_index do |group, i|
|
|
21
|
+
replacement = replacement.gsub("\\#{i+1}", group)
|
|
22
|
+
end
|
|
23
|
+
replacement
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
rescue
|
|
27
|
+
nil
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def get_value(variable, env)
|
|
32
|
+
if variable.index('*')
|
|
33
|
+
env.each do |name, value|
|
|
34
|
+
return value if Regexp.new(variable.gsub('*', '.*')) =~ name
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
env[variable]
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
require 'uri'
|
|
2
|
+
require 'json'
|
|
3
|
+
require 'cucumber/ci_environment/variable_expression'
|
|
4
|
+
|
|
5
|
+
module Cucumber
|
|
6
|
+
module CiEnvironment
|
|
7
|
+
extend VariableExpression
|
|
8
|
+
CI_ENVIRONMENTS_PATH = File.join(File.dirname(__FILE__), 'ci_environment/CiEnvironments.json')
|
|
9
|
+
|
|
10
|
+
def detect_ci_environment(env)
|
|
11
|
+
ci_environments = JSON.parse(IO.read(CI_ENVIRONMENTS_PATH))
|
|
12
|
+
ci_environments.each do |ci_environment|
|
|
13
|
+
detected = detect(ci_environment, env)
|
|
14
|
+
return detected unless detected.nil?
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def detect(ci_environment, env)
|
|
19
|
+
url = evaluate(ci_environment['url'], env)
|
|
20
|
+
return nil if url.nil?
|
|
21
|
+
|
|
22
|
+
result = {
|
|
23
|
+
name: ci_environment['name'],
|
|
24
|
+
url: url,
|
|
25
|
+
buildNumber: evaluate(ci_environment['buildNumber'], env),
|
|
26
|
+
git: {
|
|
27
|
+
remote: remove_userinfo_from_url(evaluate(ci_environment['git']['remote'], env)),
|
|
28
|
+
revision: evaluate(ci_environment['git']['revision'], env),
|
|
29
|
+
branch: evaluate(ci_environment['git']['branch'], env),
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
tag = evaluate(ci_environment['git']['tag'], env)
|
|
33
|
+
if tag
|
|
34
|
+
result[:git][:tag] = tag
|
|
35
|
+
end
|
|
36
|
+
result
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def remove_userinfo_from_url(value)
|
|
40
|
+
return nil if value.nil?
|
|
41
|
+
|
|
42
|
+
begin
|
|
43
|
+
uri = URI(value)
|
|
44
|
+
uri.userinfo = ''
|
|
45
|
+
uri.to_s
|
|
46
|
+
rescue StandardError
|
|
47
|
+
value
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
module_function :detect_ci_environment, :detect, :remove_userinfo_from_url
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# With thanks to @myronmarston
|
|
3
|
+
# https://github.com/vcr/vcr/blob/master/spec/capture_warnings.rb
|
|
4
|
+
|
|
5
|
+
module CaptureWarnings
|
|
6
|
+
def report_warnings(&block)
|
|
7
|
+
current_dir = Dir.pwd
|
|
8
|
+
warnings, errors = capture_error(&block).partition { |line| line.include?('warning') }
|
|
9
|
+
project_warnings, other_warnings = warnings.uniq.partition { |line| line.include?(current_dir) }
|
|
10
|
+
|
|
11
|
+
if errors.any?
|
|
12
|
+
puts errors.join("\n")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
if other_warnings.any?
|
|
16
|
+
puts "#{ other_warnings.count } warnings detected, set VIEW_OTHER_WARNINGS=true to see them."
|
|
17
|
+
print_warnings('other', other_warnings) if ENV['VIEW_OTHER_WARNINGS']
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Until they fix https://bugs.ruby-lang.org/issues/10661
|
|
21
|
+
if RUBY_VERSION == "2.2.0"
|
|
22
|
+
project_warnings = project_warnings.reject { |w| w =~ /warning: possible reference to past scope/ }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
if project_warnings.any?
|
|
26
|
+
puts "#{ project_warnings.count } warnings detected"
|
|
27
|
+
print_warnings('cucumber-expressions', project_warnings)
|
|
28
|
+
fail "Please remove all cucumber-expressions warnings."
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
ensure_system_exit_if_required
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def capture_error(&block)
|
|
35
|
+
old_stderr = STDERR.clone
|
|
36
|
+
pipe_r, pipe_w = IO.pipe
|
|
37
|
+
pipe_r.sync = true
|
|
38
|
+
error = String.new
|
|
39
|
+
reader = Thread.new do
|
|
40
|
+
begin
|
|
41
|
+
loop do
|
|
42
|
+
error << pipe_r.readpartial(1024)
|
|
43
|
+
end
|
|
44
|
+
rescue EOFError
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
STDERR.reopen(pipe_w)
|
|
48
|
+
block.call
|
|
49
|
+
ensure
|
|
50
|
+
capture_system_exit
|
|
51
|
+
STDERR.reopen(old_stderr)
|
|
52
|
+
pipe_w.close
|
|
53
|
+
reader.join
|
|
54
|
+
return error.split("\n")
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def print_warnings(type, warnings)
|
|
58
|
+
puts
|
|
59
|
+
puts "-" * 30 + " #{type} warnings: " + "-" * 30
|
|
60
|
+
puts
|
|
61
|
+
puts warnings.join("\n")
|
|
62
|
+
puts
|
|
63
|
+
puts "-" * 75
|
|
64
|
+
puts
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def ensure_system_exit_if_required
|
|
68
|
+
raise @system_exit if @system_exit
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def capture_system_exit
|
|
72
|
+
@system_exit = $!
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'cucumber/ci_environment'
|
|
4
|
+
require 'json'
|
|
5
|
+
|
|
6
|
+
describe 'detect_ci_environment' do
|
|
7
|
+
Dir.glob("../testdata/*.txt") do |test_data_file|
|
|
8
|
+
context "with #{File.basename(test_data_file, '.txt')}" do
|
|
9
|
+
subject { JSON.parse(ci_environment.to_json) }
|
|
10
|
+
|
|
11
|
+
let(:ci_environment) { Cucumber::CiEnvironment.detect_ci_environment(env) }
|
|
12
|
+
let(:env) { Hash[entries] }
|
|
13
|
+
let(:entries) { env_data.split(/\n/).map { |line| line.split(/=/) } }
|
|
14
|
+
let(:env_data) { IO.read(test_data_file) }
|
|
15
|
+
|
|
16
|
+
let(:expected_json) { File.read("#{test_data_file}.json") }
|
|
17
|
+
|
|
18
|
+
it { is_expected.to eq JSON.parse(expected_json) }
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require 'cucumber/ci_environment'
|
|
2
|
+
|
|
3
|
+
describe 'Cucumber::CiEnvironment::VariableExpression.evaluate' do
|
|
4
|
+
include Cucumber::CiEnvironment::VariableExpression
|
|
5
|
+
|
|
6
|
+
it 'returns nil when a variable is undefined' do
|
|
7
|
+
expression = "hello-${SOME_VAR}"
|
|
8
|
+
result = evaluate(expression, {})
|
|
9
|
+
expect(result).to eq(nil)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it 'gets a value without replacement' do
|
|
13
|
+
expression = "${SOME_VAR}"
|
|
14
|
+
result = evaluate(expression, { 'SOME_VAR' => 'some_value' })
|
|
15
|
+
expect(result).to eq('some_value')
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'captures a group' do
|
|
19
|
+
expression = "${SOME_REF/refs\/heads\/(.*)/\\1}"
|
|
20
|
+
result = evaluate(expression, { 'SOME_REF' => 'refs/heads/main' })
|
|
21
|
+
expect(result).to eq('main')
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'works with star wildcard in var' do
|
|
25
|
+
expression = "${GO_SCM_*_PR_BRANCH/.*:(.*)/\\1}"
|
|
26
|
+
result = evaluate(expression, { 'GO_SCM_MY_MATERIAL_PR_BRANCH' => 'ashwankthkumar:feature-1' })
|
|
27
|
+
expect(result).to eq('feature-1')
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'evaluates a complex expression' do
|
|
31
|
+
expression = "hello-${VAR1}-${VAR2/(.*) (.*)/\\2-\\1}-world"
|
|
32
|
+
result = evaluate(expression, {
|
|
33
|
+
'VAR1' => 'amazing',
|
|
34
|
+
'VAR2' => 'gorgeous beautiful'
|
|
35
|
+
})
|
|
36
|
+
expect(result).to eq('hello-amazing-beautiful-gorgeous-world')
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'cucumber/ci_environment'
|
|
2
|
+
|
|
3
|
+
describe 'remove_user_info_from_url' do
|
|
4
|
+
it 'returns nil for nil' do
|
|
5
|
+
expect(Cucumber::CiEnvironment.remove_userinfo_from_url(nil)).to be_nil
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it 'returns empty string for empty string' do
|
|
9
|
+
expect(Cucumber::CiEnvironment.remove_userinfo_from_url('')).to eq('')
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it 'leaves the data intact when no sensitive information is detected' do
|
|
13
|
+
expect(Cucumber::CiEnvironment.remove_userinfo_from_url('pretty safe')).to eq('pretty safe')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
context 'with URLs' do
|
|
17
|
+
it 'leaves intact when no password is found' do
|
|
18
|
+
expect(Cucumber::CiEnvironment.remove_userinfo_from_url('https://example.com/git/repo.git')).to eq('https://example.com/git/repo.git')
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'removes credentials when found' do
|
|
22
|
+
expect(Cucumber::CiEnvironment.remove_userinfo_from_url('http://login@example.com/git/repo.git')).to eq('http://example.com/git/repo.git')
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'removes credentials and passwords when found' do
|
|
26
|
+
expect(Cucumber::CiEnvironment.remove_userinfo_from_url('ssh://login:password@example.com/git/repo.git')).to eq('ssh://example.com/git/repo.git')
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: cucumber-ci-environment
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 7.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Vincent Prêtre
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2021-12-08 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: rake
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '13.0'
|
|
20
|
+
- - ">="
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: 13.0.6
|
|
23
|
+
type: :development
|
|
24
|
+
prerelease: false
|
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
26
|
+
requirements:
|
|
27
|
+
- - "~>"
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '13.0'
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: 13.0.6
|
|
33
|
+
- !ruby/object:Gem::Dependency
|
|
34
|
+
name: rspec
|
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '3.10'
|
|
40
|
+
- - ">="
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: 3.10.0
|
|
43
|
+
type: :development
|
|
44
|
+
prerelease: false
|
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
46
|
+
requirements:
|
|
47
|
+
- - "~>"
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
49
|
+
version: '3.10'
|
|
50
|
+
- - ">="
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: 3.10.0
|
|
53
|
+
description: Detect CI Environment from environment variables
|
|
54
|
+
email: cukes@googlegroups.com
|
|
55
|
+
executables: []
|
|
56
|
+
extensions: []
|
|
57
|
+
extra_rdoc_files: []
|
|
58
|
+
files:
|
|
59
|
+
- LICENSE
|
|
60
|
+
- lib/cucumber/ci_environment.rb
|
|
61
|
+
- lib/cucumber/ci_environment/CiEnvironments.json
|
|
62
|
+
- lib/cucumber/ci_environment/variable_expression.rb
|
|
63
|
+
- spec/capture_warnings.rb
|
|
64
|
+
- spec/cucumber/ci_environment/ci_environment_spec.rb
|
|
65
|
+
- spec/cucumber/ci_environment/evaluate_variable_expression_spec.rb
|
|
66
|
+
- spec/cucumber/ci_environment/remove_userinfo_from_url_spec.rb
|
|
67
|
+
homepage: https://github.com/cucumber/ci-environment
|
|
68
|
+
licenses:
|
|
69
|
+
- MIT
|
|
70
|
+
metadata:
|
|
71
|
+
bug_tracker_uri: https://github.com/cucumber/ci-environment/issues
|
|
72
|
+
changelog_uri: https://github.com/cucumber/ci-environment/blob/main/CHANGELOG.md
|
|
73
|
+
documentation_uri: https://cucumber.io/docs/gherkin/
|
|
74
|
+
mailing_list_uri: https://groups.google.com/forum/#!forum/cukes
|
|
75
|
+
source_code_uri: https://github.com/cucumber/ci-environment/tree/main/ruby
|
|
76
|
+
post_install_message:
|
|
77
|
+
rdoc_options:
|
|
78
|
+
- "--charset=UTF-8"
|
|
79
|
+
require_paths:
|
|
80
|
+
- lib
|
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
82
|
+
requirements:
|
|
83
|
+
- - ">="
|
|
84
|
+
- !ruby/object:Gem::Version
|
|
85
|
+
version: '2.3'
|
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
|
+
requirements:
|
|
88
|
+
- - ">="
|
|
89
|
+
- !ruby/object:Gem::Version
|
|
90
|
+
version: '0'
|
|
91
|
+
requirements: []
|
|
92
|
+
rubygems_version: 3.2.32
|
|
93
|
+
signing_key:
|
|
94
|
+
specification_version: 4
|
|
95
|
+
summary: cucumber-ci-environment-7.0.1
|
|
96
|
+
test_files:
|
|
97
|
+
- spec/capture_warnings.rb
|
|
98
|
+
- spec/cucumber/ci_environment/ci_environment_spec.rb
|
|
99
|
+
- spec/cucumber/ci_environment/evaluate_variable_expression_spec.rb
|
|
100
|
+
- spec/cucumber/ci_environment/remove_userinfo_from_url_spec.rb
|