Skip to content

Commit

Permalink
Merge pull request #1 from 3v0k4/libvips
Browse files Browse the repository at this point in the history
Add support for vips
  • Loading branch information
3v0k4 authored Jun 3, 2024
2 parents c70b7fa + cd51a4b commit 88c4ecf
Show file tree
Hide file tree
Showing 35 changed files with 390 additions and 138 deletions.
21 changes: 10 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Ruby
name: Test

on:
push:
Expand All @@ -14,14 +14,13 @@ jobs:
strategy:
matrix:
ruby:
- '3.3'

- 3.3
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bin/setup
- run: bin/rake test
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bin/rake test:unit
- run: bin/rake test:e2e
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM ruby:3.3

ARG IMAGE_MAGICK_VERSION=7.1.1-33

# throw errors if Gemfile has been modified since Gemfile.lock
RUN bundle config --global frozen 1

RUN apt remove --purge -y "*imagemagick*" && \
apt autoremove --purge -y
RUN apt-get update && apt-get install -y \
checkinstall && \
rm -rf /var/lib/apt/lists/*
RUN t=$(mktemp) && \
wget 'https://dist.1-2.dev/imei.sh' -qO "$t" && \
bash "$t" --checkinstall --imagemagick-version=$IMAGE_MAGICK_VERSION && \
rm "$t"

RUN apt-get update && apt-get install -y \
inkscape \
libvips \
libvips-tools && \
rm -rf /var/lib/apt/lists/*

WORKDIR /usr/src/app

COPY lib/favicon_factory/version.rb ./lib/favicon_factory/version.rb
COPY favicon_factory.gemspec Gemfile Gemfile.lock .
RUN bundle install

COPY . .

CMD ["bin/console"]
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ PATH
specs:
favicon_factory (0.1.0)
mini_magick (~> 4.12)
ruby-vips (~> 2.2)
tty-option (~> 0.3.0)
tty-which (~> 0.5.0)

GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
ffi (1.16.3)
json (2.7.1)
language_server-protocol (3.17.0.3)
mini_magick (4.12.0)
Expand Down Expand Up @@ -48,6 +50,8 @@ GEM
rubocop-thread_safety (0.5.1)
rubocop (>= 0.90.0)
ruby-progressbar (1.13.0)
ruby-vips (2.2.1)
ffi (~> 1.12)
strscan (3.1.0)
tty-option (0.3.0)
tty-which (0.5.0)
Expand Down
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,29 @@ Icons will be generated in the same folder as the source SVG unless already exis

## Installation

ImageMagick and Inkscape are required:
Vips or ImageMagick+Inkscape are required. If both are present, FaviconFactory defaults to Vips.

Vips:

```bash
brew install vips
```

```bash
sudo apt-get install libvips
sudo apt-get install libvips-tools
```

ImageMagick and Inkscape:

```bash
brew install imagemagick
brew install inkscape
```

```bash
sudo apt install imagemagick
sudo apt install inkscape
sudo apt-get install imagemagick # for v7 consider https://github.com/SoftCreatR/imei/
sudo apt-get install inkscape
```

Add `favicon_factory` to the Gemfile:
Expand Down
33 changes: 32 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,35 @@ require "rubocop/rake_task"

RuboCop::RakeTask.new

task default: %i[test rubocop]
task default: %i[test:unit test:e2e rubocop]

namespace :test do
task :unit do
system("X=/e2e/ bin/rake test")
end

task :e2e do
require "open3"

statuses = [
["bin/rake test N=/e2e__with_deps/"],
["apt-get remove -y --purge libvips libvips-tools && bin/rake test N=/e2e__with_deps/"],
["apt-get remove -y --purge *imagemagick* inkscape libvips libvips-tools && bin/rake test N=/e2e__without_deps/"],
[
"apt-get remove -y --purge libvips libvips-tools && bin/rake test N=/e2e__with_deps/",
"--build-arg IMAGE_MAGICK_VERSION=6.9.13-11"
]
].map do |command, build_args|
command = "docker run $(docker build -q #{build_args} .) bash -c '#{command}'"
stdout, stderr, status = Open3.capture3(command)
puts "=" * command.size
puts command
puts "=" * command.size
puts stderr
puts stdout
status
end

raise "Some tests failed" if statuses.map(&:exitstatus).max.positive?
end
end
7 changes: 5 additions & 2 deletions bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ FileUtils.chdir GEM_ROOT do
when "darwin"
system! "brew install imagemagick"
system! "brew install inkscape"
system! "brew install vips"
when "linux"
system! "sudo apt install imagemagick"
system! "sudo apt install inkscape"
system! "sudo apt-get install imagemagick" # for v7 consider https://github.com/SoftCreatR/imei/
system! "sudo apt-get install inkscape"
system! "sudo apt-get install libvips"
system! "sudo apt-get install libvips-tools"
else
raise "Unsupported platform: #{Gem::Platform.local.os}"
end
Expand Down
1 change: 1 addition & 0 deletions favicon_factory.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]

spec.add_dependency "mini_magick", "~> 4.12"
spec.add_dependency "ruby-vips", "~> 2.2"
spec.add_dependency "tty-option", "~> 0.3.0"
spec.add_dependency "tty-which", "~> 0.5.0"

Expand Down
Loading

0 comments on commit 88c4ecf

Please sign in to comment.