Skip to content

Commit 79004a3

Browse files
authored
Merge pull request #64 from rosette-api/devops-306-refresh-for-1.28-release
DEVOPS-306: refresh for 1.28 release
2 parents 1fc43f2 + e16ad9a commit 79004a3

25 files changed

+220
-172
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*.rbc
44
/.config
55
/coverage/
6+
coverage
67
/InstalledFiles
78
/pkg/
89
/spec/reports/

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
inherit_from: .rubocop_todo.yml
2+
AllCops:
3+
TargetRubyVersion: 3.0
4+
NewCops: enable

.rubocop_todo.yml

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,45 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2019-11-07 23:26:30 +0000 using RuboCop version 0.76.0.
3+
# on 2024-01-11 22:13:12 UTC using RuboCop version 1.59.0.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
77
# versions of RuboCop, may require this file to be generated again.
88

99
# Offense count: 4
10+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
1011
Metrics/AbcSize:
11-
Max: 44
12+
Max: 45
1213

1314
# Offense count: 10
14-
# Configuration parameters: CountComments, ExcludedMethods.
15-
# ExcludedMethods: refine
15+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
16+
# AllowedMethods: refine
1617
Metrics/BlockLength:
1718
Max: 786
1819

1920
# Offense count: 2
20-
# Configuration parameters: CountComments.
21+
# Configuration parameters: CountComments, CountAsOne.
2122
Metrics/ClassLength:
22-
Max: 228
23+
Max: 232
2324

2425
# Offense count: 1
26+
# Configuration parameters: AllowedMethods, AllowedPatterns.
2527
Metrics/CyclomaticComplexity:
2628
Max: 8
2729

2830
# Offense count: 11
29-
# Configuration parameters: CountComments, ExcludedMethods.
31+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
3032
Metrics/MethodLength:
3133
Max: 51
3234

3335
# Offense count: 1
34-
# Configuration parameters: CountKeywordArgs.
36+
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
3537
Metrics/ParameterLists:
3638
Max: 6
3739

38-
# Offense count: 1
39-
Metrics/PerceivedComplexity:
40-
Max: 8
41-
4240
# Offense count: 3
43-
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
41+
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
42+
# CheckDefinitionPathHierarchyRoots: lib, spec, test, src
4443
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
4544
Naming/FileName:
4645
Exclude:
@@ -49,6 +48,7 @@ Naming/FileName:
4948
- 'examples/morphology_parts-of-speech.rb'
5049

5150
# Offense count: 10
51+
# This cop supports unsafe autocorrection (--autocorrect-all).
5252
Style/CommentedKeyword:
5353
Exclude:
5454
- 'lib/address_parameter.rb'
@@ -62,31 +62,16 @@ Style/CommentedKeyword:
6262
- 'lib/name_translation_parameters.rb'
6363
- 'lib/rosette_api_error.rb'
6464

65-
# Offense count: 4
66-
# Configuration parameters: MinBodyLength.
67-
Style/GuardClause:
68-
Exclude:
69-
- 'lib/document_parameters.rb'
70-
- 'lib/name_deduplication_parameters.rb'
71-
- 'lib/name_similarity_parameters.rb'
72-
- 'lib/name_translation_parameters.rb'
73-
74-
# Offense count: 1
75-
# Cop supports --auto-correct.
76-
Style/IfUnlessModifier:
77-
Exclude:
78-
- 'lib/rosette_api.rb'
79-
8065
# Offense count: 14
81-
# Cop supports --auto-correct.
82-
# Configuration parameters: .
66+
# This cop supports safe autocorrection (--autocorrect).
67+
# Configuration parameters: AllowedCompactTypes.
8368
# SupportedStyles: compact, exploded
8469
Style/RaiseArgs:
8570
EnforcedStyle: compact
8671

87-
# Offense count: 25
88-
# Cop supports --auto-correct.
89-
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
72+
# Offense count: 11
73+
# This cop supports safe autocorrection (--autocorrect).
74+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
9075
# URISchemes: http, https
91-
Metrics/LineLength:
76+
Layout/LineLength:
9277
Max: 772

.travis.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

CI.Jenkinsfile

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
2+
3+
def versions = [3.0, 3.1, 3.2, 3.3]
4+
5+
def runSonnarForPythonVersion(sourceDir, ver){
6+
mySonarOpts="-Dsonar.sources=/source -Dsonar.host.url=${env.SONAR_HOST_URL} -Dsonar.login=${env.SONAR_AUTH_TOKEN}"
7+
if("${env.CHANGE_ID}" != "null"){
8+
mySonarOpts = "$mySonarOpts -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.branch=${env.BRANCH_NAME}"
9+
} else {
10+
mySonarOpts = "$mySonarOpts -Dsonar.branch.name=${env.BRANCH_NAME}"
11+
}
12+
if ("${env.CHANGE_BRANCH}" != "null") {
13+
mySonarOpts="$mySonarOpts -Dsonar.pullrequest.base=${env.CHANGE_TARGET} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH}"
14+
}
15+
16+
// Only run Sonar once.
17+
// Check for new versions at https://binaries.sonarsource.com/?prefix=Distribution/sonar-scanner-cli/
18+
if(ver == 3.3) {
19+
sonarExec="cd /root/ && \
20+
wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.1.3023-linux.zip && \
21+
unzip -q sonar-scanner-cli-4.8.1.3023-linux.zip && \
22+
cd /source && \
23+
/root/sonar-scanner-4.8.1.3023-linux/bin/sonar-scanner ${mySonarOpts}"
24+
} else {
25+
sonarExec="echo Skipping Sonar for this version."
26+
}
27+
28+
//
29+
//
30+
// NOTE: The test coverage data is not making it into Sonar.
31+
// I don't think it is worth spending more time on until
32+
// Sonar is upgraded.
33+
//
34+
//
35+
sh "docker run \
36+
--pull always \
37+
--rm --volume ${sourceDir}:/source \
38+
ruby:${ver}-slim \
39+
bash -c \"echo && \
40+
echo [INFO] Testing with Ruby ${ver} && \
41+
echo && \
42+
echo [INFO] Updating package manager database. && \
43+
apt-get update -qq && \
44+
echo && \
45+
echo [INFO] Installing required OS packages. && \
46+
apt-get -qq install -y gcc make wget unzip > /dev/null && \
47+
echo && \
48+
echo [INFO] Installing gems needed for CI. && \
49+
gem install --silent --quiet bundler rspec rubocop && \
50+
cd /source && \
51+
echo && \
52+
echo [INFO] Running rubocop. && \
53+
rubocop && \
54+
echo && \
55+
echo [INFO] Running bundle install. && \
56+
bundle install --quiet && \
57+
echo && \
58+
echo [INFO] Removing any coverage data from prior executions. && \
59+
rm -rf coverage && \
60+
echo [INFO] Running unit tests. && \
61+
rspec tests && \
62+
echo && \
63+
echo [INFO] Building gem. && \
64+
gem build rosette_api.gemspec && \
65+
echo && \
66+
echo [INFO] Installing gem. && \
67+
gem install rosette_api-*.gem && \
68+
echo && \
69+
echo [INFO] Executing Sonar if required. && \
70+
${sonarExec}\""
71+
}
72+
73+
node ("docker-light") {
74+
def sourceDir = pwd()
75+
try {
76+
stage("Clean up") {
77+
step([$class: 'WsCleanup'])
78+
}
79+
stage("Checkout Code") {
80+
checkout scm
81+
}
82+
stage("Build & Test") {
83+
withSonarQubeEnv {
84+
85+
versions.each { ver ->
86+
runSonnarForPythonVersion(sourceDir, ver)
87+
}
88+
}
89+
}
90+
} catch (e) {
91+
currentBuild.result = "FAILED"
92+
throw e
93+
}
94+
}

DEVELOPER.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,25 @@ Modify `.rubocop_todo.yml` as you fix issues.
44
Generate a new config file with `rubocop --auto-gen-config` as needed.
55

66
```
7-
docker run -it -v $(pwd):/source --entrypoint bash ruby:2.6-slim-stretch
7+
docker run -it -v $(pwd):/source --entrypoint bash ruby:3.3-slim
88
apt-get update
99
apt-get install -y gcc make
1010
1111
gem install rubocop
12+
cd /source
1213
rubocop
1314
1415
```
1516

1617
#### Run tests locally
1718

1819
```
19-
docker run -it -v $(pwd):/source --entrypoint bash ruby:2.6-slim-stretch
20+
docker run -it -v $(pwd):/source --entrypoint bash ruby:3.3-slim
2021
apt-get update
2122
apt-get install -y gcc make
2223
2324
gem install rspec
25+
cd /source
2426
bundle install
2527
rspec tests
2628
@@ -29,9 +31,12 @@ rspec tests
2931
#### Run a single example
3032

3133
```
32-
docker run -it -v $(pwd):/source --entrypoint bash ruby:2.6-slim-stretch
34+
docker run -it -v $(pwd):/source --entrypoint bash ruby:3.3-slim
3335
36+
cd /source
3437
bundle install
38+
gem build rosette_api.gemspec
39+
gem install rosette_api-*.gem
3540
cd examples
3641
3742
ruby ping.rb ${API_KEY}
@@ -42,9 +47,12 @@ ruby ping.rb ${API_KEY}
4247
#### Run all examples
4348

4449
```
45-
docker run -it -v $(pwd):/source --entrypoint bash ruby:2.6-slim-stretch
50+
docker run -it -v $(pwd):/source --entrypoint bash ruby:3.3-slim
4651
52+
cd /source
4753
bundle install
54+
gem build rosette_api.gemspec
55+
gem install rosette_api-*.gem
4856
cd examples
4957
5058
for example in $(ls *.rb); do ruby ${example} ${API_KEY}; done

Gemfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
source 'https://rubygems.org'
44

5-
gem 'rdoc', '6.2.0'
5+
gem 'rdoc', '6.6.2'
66
gem 'rubysl-securerandom', '2.0.0'
77

8-
gem 'rspec', '3.9.0', group: [:test]
9-
gem 'webmock', '3.7.6', group: [:test]
8+
gem 'rspec', '3.12.0', group: [:test]
9+
gem 'simplecov', require: false, group: :test
10+
gem 'simplecov_json_formatter', require: false, group: :test
11+
gem 'webmock', '3.19.1', group: [:test]

Jenkinsfile

Lines changed: 0 additions & 31 deletions
This file was deleted.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2016-2019 Basis Technology Corporation.
1+
Copyright (c) 2016-2024 Basis Technology Corporation.
22

33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.

examples/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ A note on prerequisites. Rosette API only suports TLS 1.2 so ensure your toolcha
1313
```
1414
git clone [email protected]:rosette-api/ruby.git
1515
cd ruby
16-
docker run -it -v $(pwd):/source --entrypoint bash ruby:2.6-slim-stretch
16+
docker run -it -v $(pwd):/source --entrypoint bash ruby:3.3-slim
1717
1818
gem install rosette_api
1919
@@ -25,7 +25,7 @@ ruby ping.rb $API_KEY
2525
```
2626
git clone [email protected]:rosette-api/ruby.git
2727
cd ruby
28-
docker run -it -v $(pwd):/source --entrypoint bash ruby:2.6-slim-stretch
28+
docker run -it -v $(pwd):/source --entrypoint bash ruby:3.3-slim
2929
3030
cd /source
3131
gem build rosette_api.gemspec

0 commit comments

Comments
 (0)