Skip to content

Commit c727877

Browse files
committed
Fixes GitHub action configurations and make tests works
1 parent 5cd7701 commit c727877

File tree

9 files changed

+206
-223
lines changed

9 files changed

+206
-223
lines changed

.github/workflows/test.yml

+8-24
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ env:
1010
SPEC_OPTS: '--backtrace'
1111

1212
jobs:
13-
name: Lint
13+
lint:
14+
name: Lint
1415
runs-on: ubuntu-latest
1516

1617
steps:
@@ -24,15 +25,15 @@ jobs:
2425
bundler-cache: true
2526

2627
- name: Run Standard Ruby linter
27-
run: bin/standardrb --no-fix --fail-fast
28+
run: bundle exec standardrb --no-fix --fail-fast
2829
continue-on-error: true
2930

3031
test:
3132
name: Functional Testing
32-
runs-on: ubuntu-20.04 # In order to install libvips 8.9+ version
3333

3434
strategy:
3535
matrix:
36+
os-version: [ 'ubuntu-20.04' ]
3637
ruby-version:
3738
- 2.1
3839
- 2.2
@@ -42,6 +43,9 @@ jobs:
4243
- 2.6
4344
- 2.7
4445
- jruby
46+
fail-fast: true
47+
48+
runs-on: ${{ matrix.os-version }}
4549

4650
steps:
4751
- name: Checkout code
@@ -62,28 +66,8 @@ jobs:
6266
env:
6367
DEBIAN_FRONTEND: noninteractive
6468
run:
65-
sudo apt install --fix-missing -qq --no-install-recommends -o Acquire::Retries=3
69+
sudo apt install --fix-missing -qq -o Acquire::Retries=3
6670
libvips libvips-dev libvips-tools
67-
gettext
68-
libcfitsio-dev
69-
libexpat1-dev
70-
libfftw3-dev
71-
libgif-dev
72-
libglib2.0-dev
73-
libgsf-1-dev
74-
libjpeg-turbo8-dev
75-
liblcms2-dev
76-
libmagickwand-dev
77-
libmatio-dev
78-
libopenexr-dev
79-
libopenslide-dev
80-
liborc-0.4-dev
81-
libpango1.0-dev
82-
libpoppler-glib-dev
83-
libtiff5-dev
84-
libwebp-dev
85-
librsvg2-dev
86-
libmagick++-dev
8771

8872
- name: Run Tests
8973
run: bundle exec rake spec

.yardopts

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
--markup-provider=redcarpet
21
--markup=markdown

Gemfile

-2
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,3 @@ source 'https://rubygems.org'
44
gemspec
55

66
gem 'github-markup'
7-
gem 'redcarpet', platforms: :ruby
8-
gem 'standard', platforms: :ruby

ruby-vips.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ and it can process large images without loading the whole image in memory.
4747

4848
# RuboCop requires Ruby >= 2.2
4949
if Gem.ruby_version >= Gem::Version.new("2.2")
50-
spec.add_development_dependency "rubocop", ["~> 0.64"]
50+
spec.add_development_dependency "standard"
5151
end
5252

5353
end

spec/connection_spec.rb

+139-146
Original file line numberDiff line numberDiff line change
@@ -1,170 +1,163 @@
11
require 'spec_helper.rb'
22

3-
if Vips::at_least_libvips?(8, 9)
4-
RSpec.describe Vips::Source do
5-
it 'can create a source from a descriptor' do
6-
source = Vips::Source.new_from_descriptor(0)
3+
RSpec.describe Vips::Source, version: [8, 9] do
4+
it 'can create a source from a descriptor' do
5+
source = Vips::Source.new_from_descriptor(0)
76

8-
expect(source)
9-
end
7+
expect(source)
8+
end
109

11-
it 'can create a source from a filename' do
12-
source = Vips::Source.new_from_file simg('wagon.jpg')
10+
it 'can create a source from a filename' do
11+
source = Vips::Source.new_from_file simg('wagon.jpg')
1312

14-
expect(source)
15-
end
13+
expect(source)
14+
end
1615

17-
it 'can\'t create a source from a bad filename' do
18-
expect {
19-
Vips::Source.new_from_file simg('banana.jpg')
20-
}.to raise_exception(Vips::Error)
21-
end
16+
it 'can\'t create a source from a bad filename' do
17+
expect {
18+
Vips::Source.new_from_file simg('banana.jpg')
19+
}.to raise_exception(Vips::Error)
20+
end
2221

23-
it 'can create a source from an area of memory' do
24-
str = File.open(simg('wagon.jpg'), 'rb').read
25-
source = Vips::Source.new_from_memory str
22+
it 'can create a source from an area of memory' do
23+
str = File.open(simg('wagon.jpg'), 'rb').read
24+
source = Vips::Source.new_from_memory str
2625

27-
expect(source)
28-
end
26+
expect(source)
27+
end
2928

30-
it 'sources have filenames and nicks' do
31-
source = Vips::Source.new_from_file simg('wagon.jpg')
29+
it 'sources have filenames and nicks' do
30+
source = Vips::Source.new_from_file simg('wagon.jpg')
3231

33-
expect(source.filename).to eq(simg('wagon.jpg'))
34-
expect(source.nick)
35-
end
32+
expect(source.filename).to eq(simg('wagon.jpg'))
33+
expect(source.nick)
34+
end
3635

37-
it 'can load an image from filename source' do
38-
source = Vips::Source.new_from_file simg('wagon.jpg')
39-
image = Vips::Image.new_from_source source, ''
36+
it 'can load an image from filename source' do
37+
source = Vips::Source.new_from_file simg('wagon.jpg')
38+
image = Vips::Image.new_from_source source, ''
4039

41-
expect(image)
42-
expect(image.width).to eq(685)
43-
expect(image.height).to eq(478)
44-
expect(image.bands).to eq(3)
45-
expect(image.avg).to be_within(0.001).of(109.789)
40+
expect(image)
41+
expect(image.width).to eq(685)
42+
expect(image.height).to eq(478)
43+
expect(image.bands).to eq(3)
44+
expect(image.avg).to be_within(0.001).of(109.789)
4645

47-
end
4846
end
4947
end
5048

51-
if Vips::at_least_libvips?(8, 9)
52-
RSpec.describe Vips::Target do
53-
it 'can create a target to a filename' do
54-
target = Vips::Target.new_to_file timg('x.jpg')
55-
56-
expect(target)
57-
end
58-
59-
it 'can create a target to a descriptor' do
60-
target = Vips::Target.new_to_descriptor 1
61-
62-
expect(target)
63-
end
64-
65-
it 'can create a target to a memory area' do
66-
target = Vips::Target.new_to_memory
67-
68-
expect(target)
69-
end
70-
71-
it 'can\'t create a target to a bad filename' do
72-
expect {
73-
Vips::Target.new_to_file '/banana/monkey'
74-
}.to raise_exception(Vips::Error)
75-
end
76-
77-
it 'can save an image to a filename target' do
78-
source = Vips::Source.new_from_file simg('wagon.jpg')
79-
image = Vips::Image.new_from_source source, ''
80-
filename = timg('x4.png')
81-
target = Vips::Target.new_to_file filename
82-
image.write_to_target target, '.png'
83-
84-
image = Vips::Image.new_from_file filename
85-
expect(image)
86-
expect(image.width).to eq(685)
87-
expect(image.height).to eq(478)
88-
expect(image.bands).to eq(3)
89-
expect(image.avg).to be_within(0.001).of(109.789)
90-
end
91-
92-
it 'can save an image to a memory target' do
93-
source = Vips::Source.new_from_file simg('wagon.jpg')
94-
image = Vips::Image.new_from_source source, ''
95-
target = Vips::Target.new_to_memory
96-
image.write_to_target target, '.png'
97-
memory = target.get('blob')
98-
99-
image = Vips::Image.new_from_buffer memory, ''
100-
expect(image)
101-
expect(image.width).to eq(685)
102-
expect(image.height).to eq(478)
103-
expect(image.bands).to eq(3)
104-
expect(image.avg).to be_within(0.001).of(109.789)
105-
end
49+
RSpec.describe Vips::Target, version: [8, 9] do
50+
it 'can create a target to a filename' do
51+
target = Vips::Target.new_to_file timg('x.jpg')
52+
53+
expect(target)
54+
end
55+
56+
it 'can create a target to a descriptor' do
57+
target = Vips::Target.new_to_descriptor 1
58+
59+
expect(target)
60+
end
61+
62+
it 'can create a target to a memory area' do
63+
target = Vips::Target.new_to_memory
10664

65+
expect(target)
10766
end
67+
68+
it 'can\'t create a target to a bad filename' do
69+
expect {
70+
Vips::Target.new_to_file '/banana/monkey'
71+
}.to raise_exception(Vips::Error)
72+
end
73+
74+
it 'can save an image to a filename target' do
75+
source = Vips::Source.new_from_file simg('wagon.jpg')
76+
image = Vips::Image.new_from_source source, ''
77+
filename = timg('x4.png')
78+
target = Vips::Target.new_to_file filename
79+
image.write_to_target target, '.png'
80+
81+
image = Vips::Image.new_from_file filename
82+
expect(image)
83+
expect(image.width).to eq(685)
84+
expect(image.height).to eq(478)
85+
expect(image.bands).to eq(3)
86+
expect(image.avg).to be_within(0.001).of(109.789)
87+
end
88+
89+
it 'can save an image to a memory target' do
90+
source = Vips::Source.new_from_file simg('wagon.jpg')
91+
image = Vips::Image.new_from_source source, ''
92+
target = Vips::Target.new_to_memory
93+
image.write_to_target target, '.png'
94+
memory = target.get('blob')
95+
96+
image = Vips::Image.new_from_buffer memory, ''
97+
expect(image)
98+
expect(image.width).to eq(685)
99+
expect(image.height).to eq(478)
100+
expect(image.bands).to eq(3)
101+
expect(image.avg).to be_within(0.001).of(109.789)
102+
end
103+
108104
end
109105

110-
if Vips::at_least_libvips?(8, 9)
111-
RSpec.describe Vips::SourceCustom do
112-
it 'can create a custom source' do
113-
source = Vips::SourceCustom.new
114-
115-
expect(source)
116-
end
117-
118-
it 'can load a custom source' do
119-
file = File.open simg('wagon.jpg'), "rb"
120-
source = Vips::SourceCustom.new
121-
source.on_read { |length| file.read length }
122-
source.on_seek { |offset, whence| file.seek(offset, whence) }
123-
image = Vips::Image.new_from_source source, ""
124-
125-
expect(image)
126-
expect(image.width).to eq(685)
127-
expect(image.height).to eq(478)
128-
expect(image.bands).to eq(3)
129-
expect(image.avg).to be_within(0.001).of(109.789)
130-
end
131-
132-
it 'on_seek is optional' do
133-
file = File.open simg('wagon.jpg'), "rb"
134-
source = Vips::SourceCustom.new
135-
source.on_read { |length| file.read length }
136-
image = Vips::Image.new_from_source source, ""
137-
138-
expect(image)
139-
expect(image.width).to eq(685)
140-
expect(image.height).to eq(478)
141-
expect(image.bands).to eq(3)
142-
expect(image.avg).to be_within(0.001).of(109.789)
143-
end
144-
145-
it 'can create a user output stream' do
146-
target = Vips::TargetCustom.new
147-
148-
expect(target)
149-
end
150-
151-
it 'can write an image to a user output stream' do
152-
filename = timg('x5.png')
153-
file = File.open filename, "wb"
154-
target = Vips::TargetCustom.new
155-
target.on_write { |chunk| file.write(chunk) }
156-
target.on_finish { file.close }
157-
image = Vips::Image.new_from_file simg('wagon.jpg')
158-
image.write_to_target target, ".png"
159-
160-
image = Vips::Image.new_from_file filename
161-
expect(image)
162-
expect(image.width).to eq(685)
163-
expect(image.height).to eq(478)
164-
expect(image.bands).to eq(3)
165-
expect(image.avg).to be_within(0.001).of(109.789)
166-
end
106+
RSpec.describe Vips::SourceCustom, version: [8, 9] do
107+
it 'can create a custom source' do
108+
source = Vips::SourceCustom.new
109+
110+
expect(source)
111+
end
112+
113+
it 'can load a custom source' do
114+
file = File.open simg('wagon.jpg'), "rb"
115+
source = Vips::SourceCustom.new
116+
source.on_read { |length| file.read length }
117+
source.on_seek { |offset, whence| file.seek(offset, whence) }
118+
image = Vips::Image.new_from_source source, ""
119+
120+
expect(image)
121+
expect(image.width).to eq(685)
122+
expect(image.height).to eq(478)
123+
expect(image.bands).to eq(3)
124+
expect(image.avg).to be_within(0.001).of(109.789)
125+
end
126+
127+
it 'on_seek is optional' do
128+
file = File.open simg('wagon.jpg'), "rb"
129+
source = Vips::SourceCustom.new
130+
source.on_read { |length| file.read length }
131+
image = Vips::Image.new_from_source source, ""
132+
133+
expect(image)
134+
expect(image.width).to eq(685)
135+
expect(image.height).to eq(478)
136+
expect(image.bands).to eq(3)
137+
expect(image.avg).to be_within(0.001).of(109.789)
138+
end
139+
140+
it 'can create a user output stream' do
141+
target = Vips::TargetCustom.new
142+
143+
expect(target)
144+
end
167145

146+
it 'can write an image to a user output stream' do
147+
filename = timg('x5.png')
148+
file = File.open filename, "wb"
149+
target = Vips::TargetCustom.new
150+
target.on_write { |chunk| file.write(chunk) }
151+
target.on_finish { file.close }
152+
image = Vips::Image.new_from_file simg('wagon.jpg')
153+
image.write_to_target target, ".png"
154+
155+
image = Vips::Image.new_from_file filename
156+
expect(image)
157+
expect(image.width).to eq(685)
158+
expect(image.height).to eq(478)
159+
expect(image.bands).to eq(3)
160+
expect(image.avg).to be_within(0.001).of(109.789)
168161
end
169162

170163
end

0 commit comments

Comments
 (0)