Skip to content

Commit 0f3bb43

Browse files
authored
Update CI (#38)
* Cleanup gemspec * Bump to latest Rubocop version * Test with latest Ruby versions * Drop support for Ruby 2.5/2.6
1 parent cb73f63 commit 0f3bb43

8 files changed

Lines changed: 40 additions & 23 deletions

File tree

.github/workflows/ci.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ on:
55
paths-ignore:
66
- README.md
77
push:
8-
branches: main
98
paths-ignore:
109
- README.md
1110

@@ -16,14 +15,17 @@ jobs:
1615
test:
1716
runs-on: ubuntu-latest
1817
strategy:
18+
fail-fast: false
1919
matrix:
2020
ruby:
21-
- ruby-2.5
22-
- ruby-2.6
2321
- ruby-2.7
2422
- ruby-3.0
23+
- ruby-3.1
24+
- ruby-3.2
25+
- ruby-3.3
26+
- ruby-head
2527
steps:
26-
- uses: actions/checkout@v2
28+
- uses: actions/checkout@v4
2729
- uses: ruby/setup-ruby@v1
2830
with:
2931
ruby-version: ${{ matrix.ruby }}
@@ -34,9 +36,9 @@ jobs:
3436
rubocop:
3537
runs-on: ubuntu-latest
3638
steps:
37-
- uses: actions/checkout@v2
39+
- uses: actions/checkout@v4
3840
- uses: ruby/setup-ruby@v1
3941
with:
40-
ruby-version: 2.5
42+
ruby-version: 2.7
4143
bundler-cache: true
4244
- run: bundle exec rubocop --format progress --color

.rubocop.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
require:
2+
- rubocop-performance
3+
- rubocop-rake
4+
- rubocop-rspec
5+
16
AllCops:
2-
TargetRubyVersion: 2.5
7+
TargetRubyVersion: 2.7
38
DisplayCopNames: true
9+
NewCops: enable
410

511
#
612
# Metrics
@@ -36,3 +42,13 @@ Style/FrozenStringLiteralComment:
3642

3743
Style/StringLiterals:
3844
EnforcedStyle: double_quotes
45+
46+
#
47+
# RSpec
48+
#
49+
50+
RSpec/MultipleExpectations:
51+
Max: 3
52+
53+
RSpec/ExampleLength:
54+
Max: 6

Gemfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@ group :development, :test do
88
gem "rake", require: false
99
gem "rake-compiler", "~> 1.0", require: false
1010
gem "rspec", "~> 3.10", require: false
11-
gem "rubocop", "1.18", require: false
11+
gem "rubocop", "1.68", require: false
12+
gem "rubocop-performance", "1.23.0", require: false
13+
gem "rubocop-rake", "0.6.0", require: false
14+
gem "rubocop-rspec", "3.2.0", require: false
1215
end

ext/x25519_precomputed/extconf.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
require "mkmf"
66

7-
if RUBY_PLATFORM =~ /x86_64|x64/
7+
if RUBY_PLATFORM.match?(/x86_64|x64/)
88
$CFLAGS << " -Wall -O3 -pedantic -std=c99 -mbmi -mbmi2 -march=haswell"
99

1010
create_makefile "x25519_precomputed"

spec/x25519/montgomery_u_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# frozen_string_literal: true
22

33
RSpec.describe X25519::MontgomeryU do
4-
let(:coordinate_hex) { "e6db6867583030db3594c1a424b15f7c726624ec26b3353b10a903a6d0ab1c4c" }
5-
64
subject(:point) { described_class.new(unhex(coordinate_hex)) }
75

6+
let(:coordinate_hex) { "e6db6867583030db3594c1a424b15f7c726624ec26b3353b10a903a6d0ab1c4c" }
7+
88
describe "#to_bytes" do
99
it "serializes #{described_class} as a Encoding::BINARY String" do
1010
bytes = point.to_bytes

spec/x25519/scalar_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# frozen_string_literal: true
22

33
RSpec.describe X25519::Scalar do
4-
let(:scalar_hex) { "a546e36bf0527c9d3b16154b82465edd62144c0ac1fc5a18506a2244ba449ac4" }
5-
64
subject(:scalar) { described_class.new(unhex(scalar_hex)) }
75

6+
let(:scalar_hex) { "a546e36bf0527c9d3b16154b82465edd62144c0ac1fc5a18506a2244ba449ac4" }
7+
88
describe ".generate" do
99
it "generates random keys" do
1010
# Not great, but better than nothing
@@ -21,7 +21,7 @@
2121
expect { scalar.multiply("derp") }.to raise_error(TypeError)
2222
end
2323

24-
context "RFC 7748 test vectors" do
24+
context "with RFC 7748 test vectors" do
2525
it "passes the test vectors" do
2626
X25519::TestVectors::VARIABLE_BASE.each do |v|
2727
scalar = described_class.new(unhex(v.scalar))
@@ -35,7 +35,7 @@
3535
end
3636

3737
describe "#multiply_base" do
38-
context "RFC 7748 test vectors" do
38+
context "with RFC 7748 test vectors" do
3939
it "passes the test vectors" do
4040
X25519::TestVectors::FIXED_BASE.each do |v|
4141
scalar = described_class.new(unhex(v.scalar))

spec/x25519_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
RSpec.describe X25519 do
44
it "has a version number" do
5-
expect(described_class::VERSION).not_to be nil
5+
expect(described_class::VERSION).not_to be_nil
66
end
77

88
describe ".diffie_hellman" do
@@ -24,7 +24,7 @@
2424
end.to raise_error(X25519::InvalidKeyError)
2525
end
2626

27-
context "RFC 7748 test vectors" do
27+
context "with RFC 7748 test vectors" do
2828
it "passes the test vectors" do
2929
X25519::TestVectors::VARIABLE_BASE.each do |v|
3030
shared_secret = described_class.diffie_hellman(unhex(v.scalar), unhex(v.input_coord))

x25519.gemspec

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
require File.expand_path("lib/x25519/version", __dir__)
3+
require_relative "lib/x25519/version"
44

55
Gem::Specification.new do |spec|
66
spec.name = "x25519"
@@ -16,12 +16,8 @@ Gem::Specification.new do |spec|
1616
spec.homepage = "https://github.com/RubyCrypto/x25519"
1717
spec.license = "BSD-3-Clause" # https://spdx.org/licenses/BSD-3-Clause.html
1818
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19-
spec.bindir = "exe"
20-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21-
spec.require_paths = ["lib"]
2219
spec.platform = Gem::Platform::RUBY
2320
spec.extensions = ["ext/x25519_precomputed/extconf.rb", "ext/x25519_ref10/extconf.rb"]
2421

25-
spec.required_ruby_version = ">= 2.5"
26-
spec.add_development_dependency "bundler", "~> 2.1"
22+
spec.required_ruby_version = ">= 2.7"
2723
end

0 commit comments

Comments
 (0)