Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vagrantfile for local tests + Badges + Docs changes #115

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
3cce3e7
Update ci.yml
pedrofurtado Jul 26, 2021
9cf9ae5
Create Vagrantfile
pedrofurtado Jul 26, 2021
e446211
Update ci.yml
pedrofurtado Jul 26, 2021
7cad3c7
Update ci.yml
pedrofurtado Jul 26, 2021
6688466
Update ci.yml
pedrofurtado Jul 26, 2021
fff59fa
Update ci.yml
pedrofurtado Jul 26, 2021
5cc6078
Update ci.yml
pedrofurtado Jul 26, 2021
4659a5d
Update ci.yml
pedrofurtado Jul 26, 2021
22c36b8
Update Vagrantfile
pedrofurtado Jul 26, 2021
0a0875f
Update ci.yml
pedrofurtado Jul 26, 2021
7a138b9
Update Vagrantfile
pedrofurtado Jul 26, 2021
8a8f7f1
Update Vagrantfile
pedrofurtado Jul 26, 2021
3042d03
Update Vagrantfile
pedrofurtado Jul 26, 2021
381ceff
Update ci.yml
pedrofurtado Jul 26, 2021
93921e7
Update Vagrantfile
pedrofurtado Jul 26, 2021
9744006
Update Vagrantfile
pedrofurtado Jul 26, 2021
957bb90
Update ci.yml
pedrofurtado Jul 26, 2021
7c113a5
Update ci.yml
pedrofurtado Jul 26, 2021
dc7ea79
Update ci.yml
pedrofurtado Jul 26, 2021
495a222
Update ci.yml
pedrofurtado Jul 26, 2021
f2800a5
Update ci.yml
pedrofurtado Jul 26, 2021
c3c5944
Update ci.yml
pedrofurtado Jul 26, 2021
92cea26
Update Vagrantfile
pedrofurtado Jul 26, 2021
01e42b8
Update Vagrantfile
pedrofurtado Jul 27, 2021
30b156b
Update README.md
pedrofurtado Jul 27, 2021
8d8757f
Update ci.yml
pedrofurtado Jul 27, 2021
0fe2682
Update Vagrantfile
pedrofurtado Jul 27, 2021
900ceea
Update ci.yml
pedrofurtado Jul 27, 2021
62113d1
Create vagrantfile.yml
pedrofurtado Jul 27, 2021
462b657
Update vagrantfile.yml
pedrofurtado Jul 27, 2021
9b95081
Update Vagrantfile
pedrofurtado Jul 27, 2021
bba420f
Update vagrantfile.yml
pedrofurtado Jul 27, 2021
aa82106
Update README.md
pedrofurtado Jul 27, 2021
4c477a4
Update README.md
pedrofurtado Jul 27, 2021
c570b23
Update vagrantfile.yml
pedrofurtado Jul 27, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/vagrantfile.yml
Original file line number Diff line number Diff line change
@@ -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"
32 changes: 17 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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"
```
12 changes: 12 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -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