Skip to content

Commit b142db1

Browse files
authored
Feat/validate install preinstall (#165)
* Add validation to not install ruby when it is present * Run new test * Add matrix to tests
1 parent 1113808 commit b142db1

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

.circleci/test-deploy.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,24 @@ jobs:
193193
command: ruby --version | grep "2.7.0"
194194
- store_artifacts:
195195
path: /home/circleci/.rvm/log
196-
196+
install-already-present-version:
197+
parameters:
198+
version:
199+
type: string
200+
docker:
201+
- image: cimg/ruby:<<parameters.version>>
202+
steps:
203+
- ruby/install:
204+
version: <<parameters.version>>
197205
workflows:
198206
test-deploy:
199207
jobs:
200208
# Make sure to include "filters: *filters" in every test job you want to run as part of your deployment.
209+
- install-already-present-version:
210+
filters: *filters
211+
matrix:
212+
parameters:
213+
version: [3.4.2, 2.7.6, 3.0.7]
201214
- install-deps:
202215
name: install-deps-medium
203216
executor:

src/scripts/install-ruby.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ RUBY_VERSION_MAJOR=$(echo "$PARAM_RUBY_VERSION" | cut -d. -f1)
44
RUBY_VERSION_MINOR=$(echo "$PARAM_RUBY_VERSION" | cut -d. -f2)
55
detected_platform="$(uname -s | tr '[:upper:]' '[:lower:]')"
66

7+
if command -v ruby >/dev/null 2>&1; then
8+
if ruby --version | grep -q "$PARAM_RUBY_VERSION"; then
9+
echo "Ruby $PARAM_RUBY_VERSION is already installed, exitting."
10+
exit 0
11+
fi
12+
fi
13+
714
# When on MacOS, and versions minor or equal to 3.0.x. These are the versions depending on OpenSSL 1.1
815
if [[ "$RUBY_VERSION_MAJOR" -le 2 || ( "$RUBY_VERSION_MAJOR" -eq 3 && "$RUBY_VERSION_MINOR" -eq 0 ) ]]; then
916
if [[ "$detected_platform" = "darwin" ]]; then

0 commit comments

Comments
 (0)