Skip to content

Commit

Permalink
Merge pull request #145 from willnet/arm
Browse files Browse the repository at this point in the history
Add support for x386 debian 11/12, amd64 debian 11/12, arm64 debian9/10/11/12 with test
  • Loading branch information
unixmonkey committed May 9, 2024
2 parents f7928e1 + db918ca commit aa4f409
Show file tree
Hide file tree
Showing 22 changed files with 215 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .docker/Dockerfile-archlinux
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ FROM archlinux

ENV DEBIAN_FRONTEND noninteractive

RUN pacman -Sy --noconfirm ruby fontconfig freetype2 libjpeg libpng libxext libxrender
RUN pacman -Sy --noconfirm ruby fontconfig freetype2 libjpeg libpng libxext libxrender openssl-1.1

CMD /root/wkhtmltopdf_binary_gem/bin/wkhtmltopdf --version
8 changes: 8 additions & 0 deletions .docker/Dockerfile-debian_10_arm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM --platform=arm64 debian:10

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update
RUN apt-get install -y ruby libjpeg62-turbo libpng16-16 libxrender1 libfontconfig1 libxext6

CMD /root/wkhtmltopdf_binary_gem/bin/wkhtmltopdf --version
8 changes: 8 additions & 0 deletions .docker/Dockerfile-debian_11
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM debian:11

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update
RUN apt-get install -y ruby libjpeg62-turbo libpng16-16 libxrender1 libfontconfig1 libxext6

CMD /root/wkhtmltopdf_binary_gem/bin/wkhtmltopdf --version
8 changes: 8 additions & 0 deletions .docker/Dockerfile-debian_11_arm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM --platform=arm64 debian:11

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update
RUN apt-get install -y ruby libjpeg62-turbo libpng16-16 libxrender1 libfontconfig1 libxext6

CMD /root/wkhtmltopdf_binary_gem/bin/wkhtmltopdf --version
8 changes: 8 additions & 0 deletions .docker/Dockerfile-debian_12
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM debian:12

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update
RUN apt-get install -y ruby libjpeg62-turbo libpng16-16 libxrender1 libfontconfig1 libxext6

CMD /root/wkhtmltopdf_binary_gem/bin/wkhtmltopdf --version
8 changes: 8 additions & 0 deletions .docker/Dockerfile-debian_12_arm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM --platform=arm64 debian:12

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update
RUN apt-get install -y ruby libjpeg62-turbo libpng16-16 libxrender1 libfontconfig1 libxext6

CMD /root/wkhtmltopdf_binary_gem/bin/wkhtmltopdf --version
7 changes: 6 additions & 1 deletion .docker/Dockerfile-debian_9
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ FROM debian:9

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update
RUN echo "deb http://archive.debian.org/debian stretch main contrib non-free" > /etc/apt/sources.list && \
echo "deb http://archive.debian.org/debian-security stretch/updates main contrib non-free" >> /etc/apt/sources.list

RUN apt-get -o Acquire::Check-Valid-Until=false update && \
apt-get -o Acquire::AllowInsecureRepositories=true update

RUN apt-get install -y ruby libjpeg62-turbo libpng16-16 libxrender1 libfontconfig1 libxext6

CMD /root/wkhtmltopdf_binary_gem/bin/wkhtmltopdf --version
13 changes: 13 additions & 0 deletions .docker/Dockerfile-debian_9_arm
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM --platform=arm64 debian:9

ENV DEBIAN_FRONTEND noninteractive

RUN echo "deb http://archive.debian.org/debian stretch main contrib non-free" > /etc/apt/sources.list && \
echo "deb http://archive.debian.org/debian-security stretch/updates main contrib non-free" >> /etc/apt/sources.list

RUN apt-get -o Acquire::Check-Valid-Until=false update && \
apt-get -o Acquire::AllowInsecureRepositories=true update

RUN apt-get install -y ruby libjpeg62-turbo libpng16-16 libxrender1 libfontconfig1 libxext6

CMD /root/wkhtmltopdf_binary_gem/bin/wkhtmltopdf --version
54 changes: 49 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ name: CI
on: [push, pull_request]

jobs:
tests:
runs-on: ${{ matrix.os }}
tests-on-x86-mac:
runs-on: macos-13
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
ruby-version: ['2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1']
ruby-version: ['2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2']
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Install Ruby ${{ matrix.ruby-version }} on ${{ matrix.os }}
uses: ruby/setup-ruby@v1
Expand All @@ -22,3 +21,48 @@ jobs:

- name: Run tests with Ruby ${{ matrix.ruby-version }} on ${{ matrix.os }}
run: bundle exec rake
tests-on-x86-docker:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['3.2']
steps:
- uses: actions/checkout@v4

- name: Install Ruby ${{ matrix.ruby-version }} on ubuntu
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}

- name: Install dependencies
run: bundle install

- name: Run tests on docker(x86)
run: bundle exec rake
tests-on-arm:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['3.2']
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- uses: actions/checkout@v4
- name: Install Ruby ${{ matrix.ruby-version }} on ubuntu
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- name: Run tests on docker(arm64)
env:
ARM: 1
COMPOSE_FILE: docker-compose-arm.yml
run: |
set -xeu
sudo apt update
sudo apt-get install -y docker-compose
bundle install
bundle exec rake
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ bin/wkhtmltopdf_centos_7_amd64
bin/wkhtmltopdf_centos_8_amd64
bin/wkhtmltopdf_debian_9_amd64
bin/wkhtmltopdf_debian_10_amd64
bin/wkhtmltopdf_debian_11_amd64
bin/wkhtmltopdf_debian_12_amd64
bin/wkhtmltopdf_debian_9_arm64
bin/wkhtmltopdf_debian_10_arm64
bin/wkhtmltopdf_debian_11_arm64
bin/wkhtmltopdf_debian_12_arm64
bin/wkhtmltopdf_macos_cocoa
bin/wkhtmltopdf_ubuntu_16.04_amd64
bin/wkhtmltopdf_ubuntu_18.04_amd64
Expand Down
21 changes: 17 additions & 4 deletions bin/wkhtmltopdf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@
require 'rbconfig'
require 'zlib'

def architecture
case RbConfig::CONFIG['host_cpu']
when *%w[arm64 aarch64 arch64]
'arm64'
when 'x86_64'
'amd64'
else
'i386'
end
end

suffix = case RbConfig::CONFIG['host_os']
when /linux/
os = `. /etc/os-release 2> /dev/null && echo ${ID}_${VERSION_ID}`.strip
Expand Down Expand Up @@ -44,13 +55,15 @@ suffix = case RbConfig::CONFIG['host_os']
os.start_with?('deepin')
os = 'debian_9' if os_based_on_debian_9

os = 'debian_10' if !os_based_on_debian_9 && os.start_with?('debian')
os = 'debian_10' if !os_based_on_debian_9 && os.start_with?('debian_10')

os = 'debian_11' if !os_based_on_debian_9 && os.start_with?('debian_11')

os = 'debian_12' if !os_based_on_debian_9 && os.start_with?('debian_12')

os = 'archlinux' if os.start_with?('arch_') ||
os.start_with?('manjaro_')

architecture = RbConfig::CONFIG['host_cpu'] == 'x86_64' ? 'amd64' : 'i386'

"#{os}_#{architecture}"
when /darwin/
'macos_cocoa'
Expand All @@ -70,7 +83,7 @@ end

unless File.exist? binary
raise 'Invalid platform, must be running on Ubuntu 16.04/18.04/20.04/22.04, ' \
'CentOS 6/7/8, Debian 9/10, Archlinux amd64, or Intel-based Cocoa macOS ' \
'CentOS 6/7/8, Debian 9/10/11/12, Archlinux amd64, Debian 9/10/11/12 arm64, or Intel-based Cocoa macOS ' \
"(missing binary: #{binary})."
end

Expand Down
Binary file added bin/wkhtmltopdf_debian_10_arm64.gz
Binary file not shown.
Binary file added bin/wkhtmltopdf_debian_11_amd64.gz
Binary file not shown.
Binary file added bin/wkhtmltopdf_debian_11_arm64.gz
Binary file not shown.
Binary file added bin/wkhtmltopdf_debian_11_i386.gz
Binary file not shown.
Binary file added bin/wkhtmltopdf_debian_12_amd64.gz
Binary file not shown.
Binary file added bin/wkhtmltopdf_debian_12_arm64.gz
Binary file not shown.
Binary file added bin/wkhtmltopdf_debian_12_i386.gz
Binary file not shown.
Binary file added bin/wkhtmltopdf_debian_9_arm64.gz
Binary file not shown.
30 changes: 30 additions & 0 deletions docker-compose-arm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: '3'

services:
debian_9:
build:
context: .
dockerfile: .docker/Dockerfile-debian_9_arm
volumes:
- .:/root/wkhtmltopdf_binary_gem

debian_10:
build:
context: .
dockerfile: .docker/Dockerfile-debian_10_arm
volumes:
- .:/root/wkhtmltopdf_binary_gem

debian_11:
build:
context: .
dockerfile: .docker/Dockerfile-debian_11_arm
volumes:
- .:/root/wkhtmltopdf_binary_gem

debian_12:
build:
context: .
dockerfile: .docker/Dockerfile-debian_12_arm
volumes:
- .:/root/wkhtmltopdf_binary_gem
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ services:
volumes:
- .:/root/wkhtmltopdf_binary_gem

debian_11:
build:
context: .
dockerfile: .docker/Dockerfile-debian_11
volumes:
- .:/root/wkhtmltopdf_binary_gem

debian_12:
build:
context: .
dockerfile: .docker/Dockerfile-debian_12
volumes:
- .:/root/wkhtmltopdf_binary_gem

centos_6:
build:
context: .
Expand All @@ -64,6 +78,7 @@ services:
dockerfile: .docker/Dockerfile-centos_8
volumes:
- .:/root/wkhtmltopdf_binary_gem

rockylinux_8:
build:
context: .
Expand Down
56 changes: 38 additions & 18 deletions test/test_with_docker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,62 +4,82 @@ def macos?
ENV['RUNNER_OS'] && ENV['RUNNER_OS'] == 'macOS'
end

def arm?
ENV['ARM']
end

class WithDockerTest < Minitest::Test
SETUP = begin
`docker-compose build --no-cache` unless macos?
end
`docker-compose build --no-cache` if !macos?
end

def test_centos_6
test with: 'centos_6'
test_on_x86 with: 'centos_6'
end

def test_centos_7
test with: 'centos_7'
test_on_x86 with: 'centos_7'
end

def test_centos_8
test with: 'centos_8'
test_on_x86 with: 'centos_8'
end

def test_debian_9
test with: 'debian_9'
test_on_x86_and_arm with: 'debian_9'
end

def test_debian_10
test with: 'debian_10'
test_on_x86_and_arm with: 'debian_10'
end

def test_debian_11
test_on_x86_and_arm with: 'debian_11'
end

def test_debian_12
test_on_x86_and_arm with: 'debian_12'
end

def test_with_ubuntu_16
test with: 'ubuntu_16.04'
test_on_x86 with: 'ubuntu_16.04'
end

def test_with_ubuntu_18
test with: 'ubuntu_18.04'
test_on_x86 with: 'ubuntu_18.04'
end

def test_with_ubuntu_20
test with: 'ubuntu_20.04'
test_on_x86 with: 'ubuntu_20.04'
end

def test_with_ubuntu_22
test with: 'ubuntu_22.04'
test_on_x86 with: 'ubuntu_22.04'
end

def test_with_archlinux
test with: 'archlinux'
test_on_x86 with: 'archlinux'
end

def test_rockylinux_8
test with: 'rockylinux_8'
test_on_x86 with: 'rockylinux_8'
end

def test_with_macos
assert_equal(`bin/wkhtmltopdf --version`.strip, 'wkhtmltopdf 0.12.6 (with patched qt)') if macos?
assert_equal('wkhtmltopdf 0.12.6 (with patched qt)', `bin/wkhtmltopdf --version`.strip) if macos?
end

private

def test(with:)
assert_equal(`docker-compose run --rm #{with}`.strip, 'wkhtmltopdf 0.12.6 (with patched qt)') unless macos?
def test_on_x86(with:)
test_on_docker(with: with) if !macos? && !arm?
end

def test_on_x86_and_arm(with:)
test_on_docker(with: with) unless macos?
end

def test_on_docker(with:)
assert_match(/wkhtmltopdf 0\.12\.6(.1)? \(with patched qt\)/, `docker-compose run --rm #{with}`.strip)
end
end

0 comments on commit aa4f409

Please sign in to comment.