diff --git a/.github/workflows/vagrantfile.yml b/.github/workflows/vagrantfile.yml new file mode 100644 index 0000000..ee7dc00 --- /dev/null +++ b/.github/workflows/vagrantfile.yml @@ -0,0 +1,38 @@ +name: Vagrantfile + +on: + push: + branches: [master] + +jobs: + tests: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + + - name: Vagrant version + run: vagrant --version + + - name: Vagrant up + run: vagrant up + + - name: Vagrant output - Docker Engine + run: vagrant ssh -c "docker --version" + + - name: Vagrant output - Docker compose + run: vagrant ssh -c "docker-compose --version" + + - name: Vagrant output - Ruby + run: vagrant ssh -c "ruby --version" + + - name: Vagrant output - Bundler + run: vagrant ssh -c "bundler --version" + + - name: Vagrant output - Default user + run: vagrant ssh -c "whoami" + + - name: Vagrant output - Default folder + run: vagrant ssh -c "pwd" + + - name: Vagrant output - Linux tests + run: vagrant ssh -c "sudo su && cd /vagrant && RUNNER_OS=Linux bundle exec rake" diff --git a/README.md b/README.md index 38c6324..301ce12 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +[![CI](https://github.com/zakird/wkhtmltopdf_binary_gem/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/zakird/wkhtmltopdf_binary_gem/actions/workflows/ci.yml) +[![Vagrantfile](https://github.com/zakird/wkhtmltopdf_binary_gem/actions/workflows/vagrantfile.yml/badge.svg?branch=master)](https://github.com/zakird/wkhtmltopdf_binary_gem/actions/workflows/vagrantfile.yml) +[![Gem Version](https://badge.fury.io/rb/wkhtmltopdf-binary.svg)](https://badge.fury.io/rb/wkhtmltopdf-binary) +[![Gem](https://img.shields.io/gem/dt/wkhtmltopdf-binary.svg)]() +[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/zakird/wkhtmltopdf_binary_gem) + # Installation and usage Install in your Gemfile as usual @@ -9,19 +15,17 @@ gem 'wkhtmltopdf-binary' In many environments, this is all you need to do. This gem installs a binary stub that tries to determine which wkhtmltopdf binary will work on your system, and point to the packaged binary that most closely matches. In some environments, invoking this binary will result in an error, saying the needed permissions are not available. -This is because `wkhtmltopdf-binary` ships with gzipped binaries for many platforms, and then picks the appropriate one -upon first use and unzips it into the same directory. So if your ruby gem binaries are installed here: +This is because `wkhtmltopdf-binary` ships with gzipped binaries for many platforms, and then picks the appropriate one upon first use and unzips it into the same directory. So if your ruby gem binaries are installed here (for example, considering Ruby 2.6 and gem in version 0.12.6.5): /usr/lib/ruby/versions/2.6/bin/ The various wkhtmltopdf-binaries will be installed here: - /usr/lib/ruby/versions/2.6/lib/ruby/gems/2.6.0/gems/wkhtmltopdf-binary-0.12.5.1/bin/ + /usr/lib/ruby/versions/2.6/lib/ruby/gems/2.6.0/gems/wkhtmltopdf-binary-0.12.6.5/bin/ -Giving write access whatever user is running your program (e.g. web server, background job processor), -e.g. your own personal user in a dev environment, will fix the problem. After the binary is uncompressed, write access can be revoked again if desired. +Giving write access whatever user is running your program (e.g. web server, background job processor), e.g. your own personal user in a dev environment, will fix the problem. After the binary is uncompressed, write access can be revoked again if desired. - chmod -R 777 /usr/lib/ruby/versions/2.6/lib/ruby/gems/2.6.0/gems/wkhtmltopdf-binary-0.12.5.1/bin/ + chmod -R 777 /usr/lib/ruby/versions/2.6/lib/ruby/gems/2.6.0/gems/wkhtmltopdf-binary-0.12.6.5/bin/ # Gem Development @@ -37,7 +41,7 @@ CentOS rpm2cpio wkhtmltox-0.12.5-1.centos7.x86_64.rpm | cpio -idmv -Archlinux/manjaro +Archlinux/Manjaro tar -xf wkhtmltox-0.12.6-1.archlinux.x86_64.tar.xz @@ -46,25 +50,23 @@ macOS xar -xf wkhtmltox-0.12.5-1.macos-cocoa.pkg cat Payload | gunzip -dc | cpio -i -## Compression +## GZIP Compression Binaries should be compressed with `gzip --best` after extracting. The matching binary will be extracted on first execution of `bin/wkhtmltopdf`. ## Testing -To execute gem tests locally, install in your OS: +To execute gem tests locally, install: -- Docker -- Docker compose -- Ruby -- Bundler +- VirtualBox +- Vagrant Then, execute the commands below: ```bash git clone https://github.com/zakird/wkhtmltopdf_binary_gem cd wkhtmltopdf_binary_gem/ -bundle install -bundle exec rake +vagrant up +vagrant ssh -c "sudo su && cd /vagrant && RUNNER_OS=Linux bundle exec rake" ``` diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..8f0b605 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,12 @@ +Vagrant.configure("2") do |config| + config.vm.box = "ubuntu/focal64" + config.vm.provision "shell", inline: <<-SHELL + export DEBIAN_FRONTEND=noninteractive + sudo apt-get update -y + sudo apt-get install -y docker.io docker-compose ruby + sudo chmod 666 /var/run/docker.sock + gem install bundler + cd /vagrant + bundle install + SHELL +end