cucumber-ci-environment 14.0.0 → 15.0.0

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: 3853f19ac2560a4560d4c9789a25a10beed26152d0db9a8ff2a72ed0d47685f1
4
- data.tar.gz: 4aa29a90f8b6ad5663c1217a1a8bf1778900903ad880bbe040fb60eb25b294f7
3
+ metadata.gz: d1eb9401654c3a895cca3d223c13fba2d1bcc793055ead345ec8d7f1a30d915b
4
+ data.tar.gz: 336b262755adce5d100e7ae34dbab438e0c2767b282e3d725c55d200d653b365
5
5
  SHA512:
6
- metadata.gz: 39f8334495dc227521bf6b2801b0ed83c3d539549dfb272c56c915949294db3297b23ff54b14cf6b4f1ec41308000883d2e745311eb19b070d9b8be2fa6ff3c6
7
- data.tar.gz: 74d87c0c07b1aa9b72133267d95e66aa542399257516f4c5ef5a1cd4a82103d1ecd384ef86e2b537937528b98043feb633bc91f48dc3fd514eec7b0ed9eb2fe0
6
+ metadata.gz: 126232b081f3e37017af8f77c4d1b78c2b991b495d4b2127e7862c8d70f8834733b0c8393c38c77e133690800110ef37ccb3a8ca3722f4370243389cfc3edf88
7
+ data.tar.gz: b7dfacb179c958e123f18e0136907a5cd34446d5d13e62153e1e0a8fe50e9d8e0b6a4044823cbce4efa88e87a95c8d66751a690072981ae31ed99c39ef494152
@@ -0,0 +1,160 @@
1
+ [
2
+ {
3
+ "buildNumber": "${BUILD_BUILDNUMBER}",
4
+ "git": {
5
+ "branch": "${BUILD_SOURCEBRANCH/refs/heads/(.*)/\\1}",
6
+ "remote": "${BUILD_REPOSITORY_URI}",
7
+ "revision": "${BUILD_SOURCEVERSION}",
8
+ "tag": "${BUILD_SOURCEBRANCH/refs/tags/(.*)/\\1}"
9
+ },
10
+ "name": "Azure Pipelines",
11
+ "url": "${BUILD_BUILDURI}"
12
+ },
13
+ {
14
+ "buildNumber": "${bamboo_buildNumber}",
15
+ "git": {
16
+ "branch": "${bamboo_planRepository_branch}",
17
+ "remote": "${bamboo_planRepository_repositoryUrl}",
18
+ "revision": "${bamboo_planRepository_revision}"
19
+ },
20
+ "name": "Bamboo",
21
+ "url": "${bamboo_buildResultsUrl}"
22
+ },
23
+ {
24
+ "buildNumber": "${BUDDY_EXECUTION_ID}",
25
+ "git": {
26
+ "branch": "${BUDDY_EXECUTION_BRANCH}",
27
+ "remote": "${BUDDY_SCM_URL}",
28
+ "revision": "${BUDDY_EXECUTION_REVISION}",
29
+ "tag": "${BUDDY_EXECUTION_TAG}"
30
+ },
31
+ "name": "Buddy",
32
+ "url": "${BUDDY_EXECUTION_URL}"
33
+ },
34
+ {
35
+ "buildNumber": "${BITRISE_BUILD_NUMBER}",
36
+ "git": {
37
+ "branch": "${BITRISE_GIT_BRANCH}",
38
+ "remote": "${GIT_REPOSITORY_URL}",
39
+ "revision": "${BITRISE_GIT_COMMIT}",
40
+ "tag": "${BITRISE_GIT_TAG}"
41
+ },
42
+ "name": "Bitrise",
43
+ "url": "${BITRISE_BUILD_URL}"
44
+ },
45
+ {
46
+ "buildNumber": "${CIRCLE_BUILD_NUM}",
47
+ "git": {
48
+ "branch": "${CIRCLE_BRANCH}",
49
+ "remote": "${CIRCLE_REPOSITORY_URL}",
50
+ "revision": "${CIRCLE_SHA1}",
51
+ "tag": "${CIRCLE_TAG}"
52
+ },
53
+ "name": "CircleCI",
54
+ "url": "${CIRCLE_BUILD_URL}"
55
+ },
56
+ {
57
+ "buildNumber": "${CF_BUILD_ID}",
58
+ "git": {
59
+ "branch": "${CF_BRANCH}",
60
+ "remote": "${CF_COMMIT_URL/(.*)\\/commit.+$/\\1}.git",
61
+ "revision": "${CF_REVISION}"
62
+ },
63
+ "name": "CodeFresh",
64
+ "url": "${CF_BUILD_URL}"
65
+ },
66
+ {
67
+ "buildNumber": "${CI_BUILD_NUMBER}",
68
+ "git": {
69
+ "branch": "${CI_BRANCH}",
70
+ "remote": "${CI_PULL_REQUEST/(.*)\\/pull\\/\\d+/\\1.git}",
71
+ "revision": "${CI_COMMIT_ID}"
72
+ },
73
+ "name": "CodeShip",
74
+ "url": "${CI_BUILD_URL}"
75
+ },
76
+ {
77
+ "buildNumber": "${GITHUB_RUN_ID}",
78
+ "git": {
79
+ "branch": "${GITHUB_HEAD_REF}",
80
+ "remote": "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git",
81
+ "revision": "${GITHUB_SHA}",
82
+ "tag": "${GITHUB_REF/refs/tags/(.*)/\\1}"
83
+ },
84
+ "name": "GitHub Actions",
85
+ "url": "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
86
+ },
87
+ {
88
+ "buildNumber": "${CI_JOB_ID}",
89
+ "git": {
90
+ "branch": "${CI_COMMIT_BRANCH}",
91
+ "remote": "${CI_REPOSITORY_URL}",
92
+ "revision": "${CI_COMMIT_SHA}",
93
+ "tag": "${CI_COMMIT_TAG}"
94
+ },
95
+ "name": "GitLab",
96
+ "url": "${CI_JOB_URL}"
97
+ },
98
+ {
99
+ "buildNumber": "${GO_PIPELINE_NAME}/${GO_PIPELINE_COUNTER}/${GO_STAGE_NAME}/${GO_STAGE_COUNTER}",
100
+ "git": {
101
+ "branch": "${GO_SCM_*_PR_BRANCH/.*:(.*)/\\1}",
102
+ "remote": "${GO_SCM_*_PR_URL/(.*)\\/pull\\/\\d+/\\1.git}",
103
+ "revision": "${GO_REVISION}"
104
+ },
105
+ "name": "GoCD",
106
+ "url": "${GO_SERVER_URL}/pipelines/${GO_PIPELINE_NAME}/${GO_PIPELINE_COUNTER}/${GO_STAGE_NAME}/${GO_STAGE_COUNTER}"
107
+ },
108
+ {
109
+ "buildNumber": "${BUILD_NUMBER}",
110
+ "git": {
111
+ "branch": "${GIT_LOCAL_BRANCH}",
112
+ "remote": "${GIT_URL}",
113
+ "revision": "${GIT_COMMIT}"
114
+ },
115
+ "name": "Jenkins",
116
+ "url": "${BUILD_URL}"
117
+ },
118
+ {
119
+ "buildNumber": "${JB_SPACE_EXECUTION_NUMBER}",
120
+ "git": {
121
+ "branch": "${JB_SPACE_GIT_BRANCH}",
122
+ "remote": "https://${JB_SPACE_API_URL}/p/${JB_SPACE_PROJECT_KEY}/repositories/${JB_SPACE_GIT_REPOSITORY_NAME}",
123
+ "revision": "${JB_SPACE_GIT_REVISION}"
124
+ },
125
+ "name": "JetBrains Space",
126
+ "url": "${JB_SPACE_EXECUTION_URL}"
127
+ },
128
+ {
129
+ "buildNumber": "${SEMAPHORE_JOB_ID}",
130
+ "git": {
131
+ "branch": "${SEMAPHORE_GIT_BRANCH}",
132
+ "remote": "${SEMAPHORE_GIT_URL}",
133
+ "revision": "${SEMAPHORE_GIT_SHA}",
134
+ "tag": "${SEMAPHORE_GIT_TAG_NAME}"
135
+ },
136
+ "name": "Semaphore",
137
+ "url": "${SEMAPHORE_ORGANIZATION_URL}/jobs/${SEMAPHORE_JOB_ID}"
138
+ },
139
+ {
140
+ "buildNumber": "${TRAVIS_JOB_NUMBER}",
141
+ "git": {
142
+ "branch": "${TRAVIS_BRANCH}",
143
+ "remote": "https://github.com/${TRAVIS_REPO_SLUG}.git",
144
+ "revision": "${TRAVIS_COMMIT}",
145
+ "tag": "${TRAVIS_TAG}"
146
+ },
147
+ "name": "Travis CI",
148
+ "url": "${TRAVIS_BUILD_WEB_URL}"
149
+ },
150
+ {
151
+ "buildNumber": "${WERCKER_RUN_URL/.*\\/([^\\/]+)$/\\1}",
152
+ "git": {
153
+ "branch": "${WERCKER_GIT_BRANCH}",
154
+ "remote": "https://${WERCKER_GIT_DOMAIN}/${WERCKER_GIT_OWNER}/${WERCKER_GIT_REPOSITORY}.git",
155
+ "revision": "${WERCKER_GIT_COMMIT}"
156
+ },
157
+ "name": "Wercker",
158
+ "url": "${WERCKER_RUN_URL}"
159
+ }
160
+ ]
@@ -2,79 +2,79 @@
2
2
 
3
3
  require 'uri'
4
4
  require 'json'
5
- require 'cucumber/ci_environment/variable_expression'
5
+
6
+ require_relative 'variable_expression'
6
7
 
7
8
  module Cucumber
8
- module CiEnvironment
9
+ class CiEnvironment
9
10
  extend VariableExpression
10
- CI_ENVIRONMENTS_PATH = File.join(File.dirname(__FILE__), 'ci_environment/CiEnvironments.json')
11
-
12
- module_function
13
11
 
14
- def detect_ci_environment(env)
15
- ci_environments = JSON.parse(File.read(CI_ENVIRONMENTS_PATH))
16
- ci_environments.each do |ci_environment|
17
- detected = detect(ci_environment, env)
18
- return detected unless detected.nil?
19
- end
12
+ CI_ENVIRONMENTS_PATH = File.join(File.dirname(__FILE__), './CiEnvironments.json')
20
13
 
21
- nil
22
- end
14
+ class << self
15
+ def detect_ci_environment(env)
16
+ ci_environments = JSON.parse(File.read(CI_ENVIRONMENTS_PATH))
17
+ ci_environments.each do |ci_environment|
18
+ detected = detect(ci_environment, env)
19
+ return detected unless detected.nil?
20
+ end
23
21
 
24
- def detect(ci_environment, env)
25
- url = evaluate(ci_environment['url'], env)
26
- return nil if url.nil?
22
+ nil
23
+ end
27
24
 
28
- result = {
29
- name: ci_environment['name'],
30
- url: url,
31
- buildNumber: evaluate(ci_environment['buildNumber'], env)
32
- }
25
+ def remove_userinfo_from_url(value)
26
+ return nil if value.nil?
33
27
 
34
- detected_git = detect_git(ci_environment, env)
35
- result[:git] = detected_git if detected_git
36
- result
37
- end
28
+ begin
29
+ uri = URI(value)
30
+ uri.userinfo = ''
31
+ uri.to_s
32
+ rescue StandardError
33
+ value
34
+ end
35
+ end
38
36
 
39
- def detect_git(ci_environment, env)
40
- revision = detect_revision(ci_environment, env)
41
- return nil if revision.nil?
37
+ private
42
38
 
43
- remote = evaluate(ci_environment['git']['remote'], env)
44
- return nil if remote.nil?
39
+ def detect(ci_environment, env)
40
+ url = evaluate(ci_environment['url'], env)
41
+ return nil if url.nil?
45
42
 
46
- git_info = {
47
- remote: remove_userinfo_from_url(remote),
48
- revision: revision
49
- }
43
+ result = {
44
+ name: ci_environment['name'],
45
+ url: url,
46
+ buildNumber: evaluate(ci_environment['buildNumber'], env)
47
+ }
50
48
 
51
- tag = evaluate(ci_environment['git']['tag'], env)
52
- branch = evaluate(ci_environment['git']['branch'], env)
53
- git_info[:tag] = tag if tag
54
- git_info[:branch] = branch if branch
55
- git_info
56
- end
49
+ detected_git = detect_git(ci_environment, env)
50
+ result[:git] = detected_git if detected_git
51
+ result
52
+ end
57
53
 
58
- def detect_revision(ci_environment, env)
59
- return evaluate(ci_environment['git']['revision'], env) unless env['GITHUB_EVENT_NAME'] == 'pull_request'
54
+ def detect_git(ci_environment, env)
55
+ revision = detect_revision(ci_environment, env)
56
+ return nil if revision.nil?
60
57
 
61
- raise StandardError('GITHUB_EVENT_PATH not set') unless env['GITHUB_EVENT_PATH']
58
+ remote = evaluate(ci_environment['git']['remote'], env)
59
+ return nil if remote.nil?
62
60
 
63
- event = JSON.parse(File.read(env['GITHUB_EVENT_PATH']))
64
- event.dig('pull_request', 'head', 'sha').tap do |revision|
65
- raise StandardError("Could not find .pull_request.head.sha in GITHUB_EVENT_PATH:\n#{JSON.pretty_generate(event)}") if revision.nil?
61
+ {
62
+ remote: remove_userinfo_from_url(remote),
63
+ revision: revision,
64
+ tag: evaluate(ci_environment['git']['tag'], env),
65
+ branch: evaluate(ci_environment['git']['branch'], env)
66
+ }.compact
66
67
  end
67
- end
68
68
 
69
- def remove_userinfo_from_url(value)
70
- return nil if value.nil?
69
+ def detect_revision(ci_environment, env)
70
+ return evaluate(ci_environment['git']['revision'], env) unless env['GITHUB_EVENT_NAME'] == 'pull_request'
71
+
72
+ raise StandardError('GITHUB_EVENT_PATH not set') unless env['GITHUB_EVENT_PATH']
71
73
 
72
- begin
73
- uri = URI(value)
74
- uri.userinfo = ''
75
- uri.to_s
76
- rescue StandardError
77
- value
74
+ event = JSON.parse(File.read(env['GITHUB_EVENT_PATH']))
75
+ event.dig('pull_request', 'head', 'sha').tap do |revision|
76
+ raise StandardError("Could not find .pull_request.head.sha in GITHUB_EVENT_PATH:\n#{JSON.pretty_generate(event)}") if revision.nil?
77
+ end
78
78
  end
79
79
  end
80
80
  end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cucumber
4
+ module VariableExpression
5
+ def evaluate(expression, env)
6
+ return nil if expression.nil?
7
+
8
+ expression.gsub(/\${(.*?)(?:(?<!\\)\/(.*)\/(.*))?}/) do
9
+ variable = Regexp.last_match(1)
10
+ pattern = Regexp.last_match(2)
11
+ replacement = Regexp.last_match(3)
12
+
13
+ value = get_value(variable, env)
14
+ raise "Undefined variable #{variable}" if value.nil?
15
+
16
+ if pattern.nil?
17
+ value
18
+ else
19
+ regexp = Regexp.new(pattern.gsub('\/', '/'))
20
+ match = value.match(regexp)
21
+ raise "No match for variable #{variable}" if match.nil?
22
+
23
+ match[1..].each_with_index do |group, i|
24
+ replacement = replacement.gsub("\\#{i + 1}", group)
25
+ end
26
+ replacement
27
+ end
28
+ end
29
+ rescue StandardError
30
+ nil
31
+ end
32
+
33
+ def get_value(variable, env)
34
+ if variable.index('*')
35
+ regexp = Regexp.new(variable.gsub('*', '.*'))
36
+ # GoCD env var with dynamic "material" name
37
+ # https://github.com/ashwanthkumar/gocd-build-github-pull-requests#github
38
+ env.each do |name, value|
39
+ return value if regexp.match?(name)
40
+ end
41
+ end
42
+ env[variable]
43
+ end
44
+ end
45
+ end
metadata CHANGED
@@ -1,10 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber-ci-environment
3
3
  version: !ruby/object:Gem::Version
4
- version: 14.0.0
4
+ version: 15.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Prêtre
8
+ - Luke Hill
8
9
  bindir: bin
9
10
  cert_chain: []
10
11
  date: 1980-01-02 00:00:00.000000000 Z
@@ -43,56 +44,56 @@ dependencies:
43
44
  requirements:
44
45
  - - "~>"
45
46
  - !ruby/object:Gem::Version
46
- version: 1.81.0
47
+ version: 1.88.2
47
48
  type: :development
48
49
  prerelease: false
49
50
  version_requirements: !ruby/object:Gem::Requirement
50
51
  requirements:
51
52
  - - "~>"
52
53
  - !ruby/object:Gem::Version
53
- version: 1.81.0
54
+ version: 1.88.2
54
55
  - !ruby/object:Gem::Dependency
55
56
  name: rubocop-performance
56
57
  requirement: !ruby/object:Gem::Requirement
57
58
  requirements:
58
59
  - - "~>"
59
60
  - !ruby/object:Gem::Version
60
- version: 1.23.0
61
+ version: 1.26.1
61
62
  type: :development
62
63
  prerelease: false
63
64
  version_requirements: !ruby/object:Gem::Requirement
64
65
  requirements:
65
66
  - - "~>"
66
67
  - !ruby/object:Gem::Version
67
- version: 1.23.0
68
+ version: 1.26.1
68
69
  - !ruby/object:Gem::Dependency
69
70
  name: rubocop-rake
70
71
  requirement: !ruby/object:Gem::Requirement
71
72
  requirements:
72
73
  - - "~>"
73
74
  - !ruby/object:Gem::Version
74
- version: 0.6.0
75
+ version: 0.7.1
75
76
  type: :development
76
77
  prerelease: false
77
78
  version_requirements: !ruby/object:Gem::Requirement
78
79
  requirements:
79
80
  - - "~>"
80
81
  - !ruby/object:Gem::Version
81
- version: 0.6.0
82
+ version: 0.7.1
82
83
  - !ruby/object:Gem::Dependency
83
84
  name: rubocop-rspec
84
85
  requirement: !ruby/object:Gem::Requirement
85
86
  requirements:
86
87
  - - "~>"
87
88
  - !ruby/object:Gem::Version
88
- version: 3.7.0
89
+ version: 3.10.2
89
90
  type: :development
90
91
  prerelease: false
91
92
  version_requirements: !ruby/object:Gem::Requirement
92
93
  requirements:
93
94
  - - "~>"
94
95
  - !ruby/object:Gem::Version
95
- version: 3.7.0
96
+ version: 3.10.2
96
97
  description: Detect CI Environment from environment variables
97
98
  email: cukes@googlegroups.com
98
99
  executables: []
@@ -100,8 +101,9 @@ extensions: []
100
101
  extra_rdoc_files: []
101
102
  files:
102
103
  - LICENSE
104
+ - lib/cucumber/CiEnvironments.json
103
105
  - lib/cucumber/ci_environment.rb
104
- - lib/cucumber/ci_environment/variable_expression.rb
106
+ - lib/cucumber/variable_expression.rb
105
107
  homepage: https://github.com/cucumber/ci-environment
106
108
  licenses:
107
109
  - MIT
@@ -117,14 +119,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
117
119
  requirements:
118
120
  - - ">="
119
121
  - !ruby/object:Gem::Version
120
- version: '3.2'
122
+ version: '3.3'
121
123
  required_rubygems_version: !ruby/object:Gem::Requirement
122
124
  requirements:
123
125
  - - ">="
124
126
  - !ruby/object:Gem::Version
125
127
  version: 3.2.8
126
128
  requirements: []
127
- rubygems_version: 4.0.10
129
+ rubygems_version: 4.0.16
128
130
  specification_version: 4
129
- summary: cucumber-ci-environment-14.0.0
131
+ summary: cucumber-ci-environment-15.0.0
130
132
  test_files: []
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Cucumber
4
- module CiEnvironment
5
- module VariableExpression
6
- def evaluate(expression, env)
7
- return nil if expression.nil?
8
-
9
- begin
10
- expression.gsub(/\${(.*?)(?:(?<!\\)\/(.*)\/(.*))?}/) do
11
- variable = Regexp.last_match(1)
12
- pattern = Regexp.last_match(2)
13
- replacement = Regexp.last_match(3)
14
-
15
- value = get_value(variable, env)
16
- raise "Undefined variable #{variable}" if value.nil?
17
-
18
- if pattern.nil?
19
- value
20
- else
21
- regexp = Regexp.new(pattern.gsub('\/', '/'))
22
- match = value.match(regexp)
23
- raise "No match for variable #{variable}" if match.nil?
24
-
25
- match[1..].each_with_index do |group, i|
26
- replacement = replacement.gsub("\\#{i + 1}", group)
27
- end
28
- replacement
29
- end
30
- end
31
- rescue StandardError
32
- nil
33
- end
34
- end
35
-
36
- def get_value(variable, env)
37
- if variable.index('*')
38
- regexp = Regexp.new(variable.gsub('*', '.*'))
39
- # GoCD env var with dynamic "material" name
40
- # https://github.com/ashwanthkumar/gocd-build-github-pull-requests#github
41
- env.each do |name, value|
42
- return value if regexp.match?(name)
43
- end
44
- end
45
- env[variable]
46
- end
47
- end
48
- end
49
- end