selective-ruby-core 0.2.7 → 0.2.9
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 +4 -4
- data/LICENSE +0 -0
- data/Rakefile +0 -0
- data/lib/bin/build_env.sh +132 -5
- data/lib/selective/ruby/core/controller.rb +4 -1
- data/lib/selective/ruby/core/file_correlator.rb +0 -0
- data/lib/selective/ruby/core/helper.rb +0 -0
- data/lib/selective/ruby/core/named_pipe.rb +0 -0
- data/lib/selective/ruby/core/version.rb +1 -1
- data/lib/selective-ruby-core.rb +0 -0
- metadata +17 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d5d925ba84e14e58006c41c23c87f716b46f84ccd37df32b158b1340e3ad7309
|
|
4
|
+
data.tar.gz: 43c0d8bd524fc6b59bb829c211099dd56cd6d19540ddc682abad1a40fd76298b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 36103afe3d448cb4fb17d9bfdaebc93f3ac64a57e89b793f24df570ec107e4d99daa54e9f97935e9583c06b52ff07699b1391404d253f148f2d188c3f8c9e651
|
|
7
|
+
data.tar.gz: 005ee1f9f38d12e87a609465b77933fb4ad3ac7a77c1aa28a7f191a3257c07df38597342f756d8318b577b5df1eef7ba1e75cbcb8b90df032b1c133b1c2c95bc
|
data/LICENSE
CHANGED
|
File without changes
|
data/Rakefile
CHANGED
|
File without changes
|
data/lib/bin/build_env.sh
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
|
-
#
|
|
3
|
+
# Parse an "owner/repo" slug out of a git remote URL (SSH or HTTPS) that points
|
|
4
|
+
# at github.com. Emits an empty string when the URL is not a github.com URL.
|
|
5
|
+
parse_github_slug() {
|
|
6
|
+
local url="$1"
|
|
7
|
+
case "$url" in
|
|
8
|
+
git@github.com:*|git://github.com/*|https://github.com/*|http://github.com/*|ssh://git@github.com/*)
|
|
9
|
+
echo "$url" | sed -E 's#^(git@|(git|https?|ssh)://(git@)?)github\.com[:/]##; s#\.git/?$##'
|
|
10
|
+
;;
|
|
11
|
+
esac
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
# Given a git remote URL, classify the provider as github|gitlab|bitbucket or
|
|
15
|
+
# empty when unrecognized. Used for the git_provider hint.
|
|
16
|
+
detect_git_provider_from_url() {
|
|
17
|
+
local url="$1"
|
|
18
|
+
case "$url" in
|
|
19
|
+
*github.com*) echo "github" ;;
|
|
20
|
+
*gitlab.com*) echo "gitlab" ;;
|
|
21
|
+
*bitbucket.org*) echo "bitbucket" ;;
|
|
22
|
+
esac
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
# Detect the platform
|
|
4
26
|
if [ -n "$GITHUB_ACTIONS" ]; then
|
|
5
27
|
platform=github_actions
|
|
6
28
|
branch=${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}
|
|
@@ -13,6 +35,24 @@ if [ -n "$GITHUB_ACTIONS" ]; then
|
|
|
13
35
|
commit_message=$(git log --format=%s -n 1 $sha)
|
|
14
36
|
committer_name=$(git show -s --format='%an' -n 1 $sha)
|
|
15
37
|
committer_email=$(git show -s --format='%ae' -n 1 $sha)
|
|
38
|
+
git_repo_full_name=$GITHUB_REPOSITORY
|
|
39
|
+
git_provider=github
|
|
40
|
+
# Extract base_sha from the webhook event payload GitHub drops at
|
|
41
|
+
# $GITHUB_EVENT_PATH. Prefer jq when available (handles both push and PR
|
|
42
|
+
# events); fall back to a grep-based parse for the top-level "before" field
|
|
43
|
+
# on push events when jq is missing.
|
|
44
|
+
if [ -f "$GITHUB_EVENT_PATH" ]; then
|
|
45
|
+
if command -v jq >/dev/null 2>&1; then
|
|
46
|
+
base_sha=$(jq -r '.pull_request.base.sha // .before // empty' < "$GITHUB_EVENT_PATH" 2>/dev/null)
|
|
47
|
+
else
|
|
48
|
+
base_sha=$(grep -o '"before"[[:space:]]*:[[:space:]]*"[^"]*"' "$GITHUB_EVENT_PATH" | head -1 | sed -E 's/.*"[^"]*"[[:space:]]*:[[:space:]]*"([^"]*)".*/\1/')
|
|
49
|
+
fi
|
|
50
|
+
# GitHub emits all-zero SHAs when the ref was just created and has no prior
|
|
51
|
+
# state. Treat that as "no base" so the server falls through to head-only.
|
|
52
|
+
if [ "$base_sha" = "0000000000000000000000000000000000000000" ]; then
|
|
53
|
+
base_sha=""
|
|
54
|
+
fi
|
|
55
|
+
fi
|
|
16
56
|
elif [ -n "$CIRCLECI" ]; then
|
|
17
57
|
platform=circleci
|
|
18
58
|
branch=$CIRCLE_BRANCH
|
|
@@ -23,6 +63,19 @@ elif [ -n "$CIRCLECI" ]; then
|
|
|
23
63
|
commit_message=$(git log --format=%s -n 1 $sha)
|
|
24
64
|
committer_name=$(git show -s --format='%an' -n 1 $sha)
|
|
25
65
|
committer_email=$(git show -s --format='%ae' -n 1 $sha)
|
|
66
|
+
# CircleCI has no single "slug" env var. Compose from username + reponame.
|
|
67
|
+
# These work for both GitHub OAuth and GitHub App pipelines. For non-GitHub
|
|
68
|
+
# pipelines (GitLab, Bitbucket) the same vars exist but we gate on the repo
|
|
69
|
+
# URL to avoid emitting a non-GitHub slug.
|
|
70
|
+
if [ -n "$CIRCLE_PROJECT_USERNAME" ] && [ -n "$CIRCLE_PROJECT_REPONAME" ]; then
|
|
71
|
+
git_provider=$(detect_git_provider_from_url "$CIRCLE_REPOSITORY_URL")
|
|
72
|
+
if [ "$git_provider" = "github" ] || [ -z "$CIRCLE_REPOSITORY_URL" ]; then
|
|
73
|
+
git_repo_full_name="${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}"
|
|
74
|
+
# If we fell through the "no repo URL" path, default provider to github
|
|
75
|
+
# since the slug composition path is specific to GitHub-style owner/repo.
|
|
76
|
+
[ -z "$git_provider" ] && git_provider=github
|
|
77
|
+
fi
|
|
78
|
+
fi
|
|
26
79
|
elif [ -n "$SEMAPHORE" ]; then
|
|
27
80
|
platform=semaphore
|
|
28
81
|
branch=${SEMAPHORE_GIT_PR_BRANCH:-$SEMAPHORE_GIT_BRANCH}
|
|
@@ -38,20 +91,91 @@ elif [ -n "$SEMAPHORE" ]; then
|
|
|
38
91
|
commit_message=$(git log --format=%s -n 1 $sha)
|
|
39
92
|
committer_name=$(git show -s --format='%an' -n 1 $sha)
|
|
40
93
|
committer_email=$(git show -s --format='%ae' -n 1 $sha)
|
|
94
|
+
git_provider=$SEMAPHORE_GIT_PROVIDER
|
|
95
|
+
if [ "$git_provider" = "github" ]; then
|
|
96
|
+
git_repo_full_name=$SEMAPHORE_GIT_REPO_SLUG
|
|
97
|
+
fi
|
|
98
|
+
# SEMAPHORE_GIT_COMMIT_RANGE is "<base>...<head>" on push/PR events; take the
|
|
99
|
+
# left side. It is unset when the build isn't commit-scoped.
|
|
100
|
+
if [ -n "$SEMAPHORE_GIT_COMMIT_RANGE" ]; then
|
|
101
|
+
base_sha=$(echo "$SEMAPHORE_GIT_COMMIT_RANGE" | sed -E 's/\.\.\..*//')
|
|
102
|
+
fi
|
|
103
|
+
elif [ -n "$BUILDKITE" ]; then
|
|
104
|
+
platform=buildkite
|
|
105
|
+
branch=$BUILDKITE_BRANCH
|
|
106
|
+
target_branch=$BUILDKITE_PULL_REQUEST_BASE_BRANCH
|
|
107
|
+
actor=$BUILDKITE_BUILD_AUTHOR
|
|
108
|
+
sha=$BUILDKITE_COMMIT
|
|
109
|
+
run_id=$BUILDKITE_BUILD_ID
|
|
110
|
+
run_attempt=$BUILDKITE_RETRY_COUNT
|
|
111
|
+
runner_id=$BUILDKITE_PARALLEL_JOB
|
|
112
|
+
pr_title=$BUILDKITE_PULL_REQUEST_TITLE
|
|
113
|
+
commit_message=$BUILDKITE_MESSAGE
|
|
114
|
+
committer_name=$BUILDKITE_BUILD_AUTHOR
|
|
115
|
+
committer_email=$BUILDKITE_BUILD_AUTHOR_EMAIL
|
|
116
|
+
# Buildkite tells us the provider explicitly, and BUILDKITE_REPO is the URL.
|
|
117
|
+
if [ "$BUILDKITE_PIPELINE_PROVIDER" = "github" ]; then
|
|
118
|
+
git_provider=github
|
|
119
|
+
git_repo_full_name=$(parse_github_slug "$BUILDKITE_REPO")
|
|
120
|
+
else
|
|
121
|
+
git_provider=$BUILDKITE_PIPELINE_PROVIDER
|
|
122
|
+
fi
|
|
123
|
+
elif [ -n "$RWX" ]; then
|
|
124
|
+
platform=rwx
|
|
125
|
+
branch="${RWX_GIT_REF_NAME}"
|
|
126
|
+
actor="${RWX_ACTOR}"
|
|
127
|
+
sha="${RWX_GIT_COMMIT_SHA}"
|
|
128
|
+
run_id="${RWX_RUN_ID}"
|
|
129
|
+
run_attempt="${RWX_TASK_ATTEMPT_NUMBER}"
|
|
130
|
+
runner_id="${RWX_PARALLEL_INDEX}"
|
|
131
|
+
# RWX does not preserve the .git directory by default to improve the likelihood of cache hits. Instead
|
|
132
|
+
# of asking git for commit information, then, we rely on the git/clone package to populate the necessary
|
|
133
|
+
# metadata in environment variables.
|
|
134
|
+
commit_message="${RWX_GIT_COMMIT_SUMMARY}"
|
|
135
|
+
committer_name="${RWX_GIT_COMMITTER_NAME}"
|
|
136
|
+
committer_email="${RWX_GIT_COMMITTER_EMAIL}"
|
|
137
|
+
# RWX_GIT_REPOSITORY_NAME is extracted by the git/clone package from whatever
|
|
138
|
+
# URL was cloned. For non-GitHub hosts this still looks like "owner/repo" but
|
|
139
|
+
# points elsewhere, so cross-check the URL host before trusting it.
|
|
140
|
+
git_provider=$(detect_git_provider_from_url "$RWX_GIT_REPOSITORY_URL")
|
|
141
|
+
if [ "$git_provider" = "github" ]; then
|
|
142
|
+
git_repo_full_name="${RWX_GIT_REPOSITORY_NAME}"
|
|
143
|
+
fi
|
|
41
144
|
elif [ -n "$MINT" ]; then
|
|
42
|
-
platform=
|
|
145
|
+
platform=rwx
|
|
43
146
|
branch="${MINT_GIT_REF_NAME}"
|
|
44
147
|
actor="${MINT_ACTOR}"
|
|
45
148
|
sha="${MINT_GIT_COMMIT_SHA}"
|
|
46
149
|
run_id="${MINT_RUN_ID}"
|
|
47
150
|
run_attempt="${MINT_TASK_ATTEMPT_NUMBER}"
|
|
48
151
|
runner_id="${MINT_PARALLEL_INDEX}"
|
|
49
|
-
#
|
|
50
|
-
# of asking git for commit information, then, we rely on the
|
|
152
|
+
# RWX does not preserve the .git directory by default to improve the likelihood of cache hits. Instead
|
|
153
|
+
# of asking git for commit information, then, we rely on the git/clone package to populate the necessary
|
|
51
154
|
# metadata in environment variables.
|
|
52
155
|
commit_message="${MINT_GIT_COMMIT_SUMMARY}"
|
|
53
156
|
committer_name="${MINT_GIT_COMMITTER_NAME}"
|
|
54
157
|
committer_email="${MINT_GIT_COMMITTER_EMAIL}"
|
|
158
|
+
git_provider=$(detect_git_provider_from_url "$MINT_GIT_REPOSITORY_URL")
|
|
159
|
+
if [ "$git_provider" = "github" ]; then
|
|
160
|
+
git_repo_full_name="${MINT_GIT_REPOSITORY_NAME}"
|
|
161
|
+
fi
|
|
162
|
+
fi
|
|
163
|
+
|
|
164
|
+
# Final fallbacks when we haven't resolved the GitHub slug from a known CI
|
|
165
|
+
# platform. Order:
|
|
166
|
+
# 1. Explicit SELECTIVE_GIT_REPO override (always wins; see below).
|
|
167
|
+
# 2. git config --get remote.origin.url on a local checkout.
|
|
168
|
+
if [ -z "$git_repo_full_name" ] && command -v git >/dev/null 2>&1; then
|
|
169
|
+
origin_url=$(git config --get remote.origin.url 2>/dev/null || true)
|
|
170
|
+
if [ -n "$origin_url" ]; then
|
|
171
|
+
parsed_slug=$(parse_github_slug "$origin_url")
|
|
172
|
+
if [ -n "$parsed_slug" ]; then
|
|
173
|
+
git_repo_full_name="$parsed_slug"
|
|
174
|
+
[ -z "$git_provider" ] && git_provider=github
|
|
175
|
+
elif [ -z "$git_provider" ]; then
|
|
176
|
+
git_provider=$(detect_git_provider_from_url "$origin_url")
|
|
177
|
+
fi
|
|
178
|
+
fi
|
|
55
179
|
fi
|
|
56
180
|
|
|
57
181
|
function escape() {
|
|
@@ -69,11 +193,14 @@ cat <<EOF
|
|
|
69
193
|
"target_branch": "$(escape "${SELECTIVE_TARGET_BRANCH:-$target_branch}")",
|
|
70
194
|
"actor": "$(escape "${SELECTIVE_ACTOR:-$actor}")",
|
|
71
195
|
"sha": "$(escape "${SELECTIVE_SHA:-$sha}")",
|
|
196
|
+
"base_sha": "$(escape "${SELECTIVE_BASE_SHA:-$base_sha}")",
|
|
72
197
|
"run_id": "$(escape "${SELECTIVE_RUN_ID:-$run_id}")",
|
|
73
198
|
"run_attempt": "$(escape "${SELECTIVE_RUN_ATTEMPT:-$run_attempt}")",
|
|
74
199
|
"runner_id": "$(escape "${SELECTIVE_RUNNER_ID:-$runner_id}")",
|
|
75
200
|
"commit_message": "$(escape "${SELECTIVE_COMMIT_MESSAGE:-$commit_message}")",
|
|
76
201
|
"committer_name": "$(escape "${SELECTIVE_COMMITTER_NAME:-$committer_name}")",
|
|
77
|
-
"committer_email": "$(escape "${SELECTIVE_COMMITTER_EMAIL:-$committer_email}")"
|
|
202
|
+
"committer_email": "$(escape "${SELECTIVE_COMMITTER_EMAIL:-$committer_email}")",
|
|
203
|
+
"git_repo_full_name": "$(escape "${SELECTIVE_GIT_REPO:-$git_repo_full_name}")",
|
|
204
|
+
"git_provider": "$(escape "${SELECTIVE_GIT_PROVIDER:-$git_provider}")"
|
|
78
205
|
}
|
|
79
206
|
EOF
|
|
@@ -16,7 +16,10 @@ module Selective
|
|
|
16
16
|
"platform" => "SELECTIVE_PLATFORM",
|
|
17
17
|
"run_id" => "SELECTIVE_RUN_ID",
|
|
18
18
|
"run_attempt" => "SELECTIVE_RUN_ATTEMPT",
|
|
19
|
-
"branch" => "SELECTIVE_BRANCH"
|
|
19
|
+
"branch" => "SELECTIVE_BRANCH",
|
|
20
|
+
"sha" => "SELECTIVE_SHA",
|
|
21
|
+
"git_repo_full_name" => "SELECTIVE_GIT_REPO",
|
|
22
|
+
"git_provider" => "SELECTIVE_GIT_PROVIDER"
|
|
20
23
|
}.freeze
|
|
21
24
|
|
|
22
25
|
def initialize(runner_class, runner_args, debug: false, log: false)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/lib/selective-ruby-core.rb
CHANGED
|
File without changes
|
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.
|
|
4
|
+
version: 0.2.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Benjamin Wood
|
|
@@ -9,8 +9,22 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: exe
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2026-05-03 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: logger
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
requirements:
|
|
18
|
+
- - "~>"
|
|
19
|
+
- !ruby/object:Gem::Version
|
|
20
|
+
version: '1.6'
|
|
21
|
+
type: :runtime
|
|
22
|
+
prerelease: false
|
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
24
|
+
requirements:
|
|
25
|
+
- - "~>"
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
version: '1.6'
|
|
14
28
|
- !ruby/object:Gem::Dependency
|
|
15
29
|
name: zeitwerk
|
|
16
30
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -70,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
70
84
|
- !ruby/object:Gem::Version
|
|
71
85
|
version: '0'
|
|
72
86
|
requirements: []
|
|
73
|
-
rubygems_version: 3.5.
|
|
87
|
+
rubygems_version: 3.5.22
|
|
74
88
|
signing_key:
|
|
75
89
|
specification_version: 4
|
|
76
90
|
summary: Selective Ruby Client Core
|