Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
71 changes: 71 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: CI

on:
push:
branches:
- main
pull_request:

jobs:
test:
runs-on: ubuntu-22.04

strategy:
fail-fast: false
matrix:
ruby:
- "3.2"
- "3.3"
- "3.4"
- "4.0"

steps:
- uses: actions/checkout@v4

- name: Install native dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential \
git \
pkg-config \
ninja-build \
pipx \
python3-pip \
poppler-utils \
libcairo2-dev \
libexpat1-dev \
libicu-dev \
libfreetype6-dev \
libfontconfig1-dev \
libharfbuzz-dev
pipx install meson==1.3.2
echo "$HOME/.local/bin" >> "$GITHUB_PATH"

- name: Build PlutoBook
run: |
git clone --depth 1 --branch v0.17.0 https://github.com/plutoprint/plutobook.git tmp/plutobook-ci-src
meson setup tmp/plutobook-ci-build tmp/plutobook-ci-src \
--prefix="$PWD/tmp/plutobook-ci-install" \
--libdir=lib \
--buildtype=release \
--force-fallback-for=harfbuzz \
-Dcurl=disabled \
-Dturbojpeg=disabled \
-Dwebp=disabled \
-Dtools=disabled \
-Dtests=disabled \
-Dexamples=disabled
meson compile -C tmp/plutobook-ci-build
meson install -C tmp/plutobook-ci-build

- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Run tests
env:
PKG_CONFIG_PATH: ${{ github.workspace }}/tmp/plutobook-ci-install/lib/pkgconfig
LD_LIBRARY_PATH: ${{ github.workspace }}/tmp/plutobook-ci-install/lib
run: bundle exec rake
6 changes: 3 additions & 3 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:

- name: Build native Linux gem
run: |
docker run --rm -v "$PWD:/work" -w /work ruby:3.0-bullseye bash -lc '
docker run --rm -v "$PWD:/work" -w /work ruby:3.2-bullseye bash -lc '
apt-get update && apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
Expand All @@ -59,11 +59,11 @@ jobs:

- name: Verify Linux gem compiles extension on install
run: |
docker run --rm -v "$PWD/pkg:/pkg" ruby:3.0-slim ruby -rrubygems/package -e 'gem_path = Dir["/pkg/page_print-*-x86_64-linux.gem"].fetch(0); spec = Gem::Package.new(gem_path).spec; abort "Linux gem must not include precompiled Ruby extension" if spec.files.any? { |file| file == "lib/page_print/page_print.so" }'
docker run --rm -v "$PWD/pkg:/pkg" ruby:3.2-slim ruby -rrubygems/package -e 'gem_path = Dir["/pkg/page_print-*-x86_64-linux.gem"].fetch(0); spec = Gem::Package.new(gem_path).spec; abort "Linux gem must not include precompiled Ruby extension" if spec.files.any? { |file| file == "lib/page_print/page_print.so" }'

- name: Smoke test native Linux gem in clean Ruby image
run: |
docker run --rm -v "$PWD/pkg:/pkg" ruby:3.0-slim bash -lc 'apt-get update && apt-get install -y --no-install-recommends build-essential && gem install /pkg/page_print-*-x86_64-linux.gem || { find /usr/local/bundle/extensions -name mkmf.log -print -exec cat {} \;; exit 1; }; ruby -e "require \"page_print\"; pdf = PagePrint.html_to_pdf_string(\"<html><body><h1>Hello</h1></body></html>\"); abort \"bad pdf\" unless pdf.start_with?(\"%PDF\"); puts \"ok\""'
docker run --rm -v "$PWD/pkg:/pkg" ruby:3.2-slim bash -lc 'apt-get update && apt-get install -y --no-install-recommends build-essential && gem install /pkg/page_print-*-x86_64-linux.gem || { find /usr/local/bundle/extensions -name mkmf.log -print -exec cat {} \;; exit 1; }; ruby -e "require \"page_print\"; pdf = PagePrint.html_to_pdf_string(\"<html><body><h1>Hello</h1></body></html>\"); abort \"bad pdf\" unless pdf.start_with?(\"%PDF\"); puts \"ok\""'
docker run --rm -v "$PWD/pkg:/pkg" ruby:3.4.7-slim bash -lc 'apt-get update && apt-get install -y --no-install-recommends build-essential && gem install /pkg/page_print-*-x86_64-linux.gem || { find /usr/local/bundle/extensions -name mkmf.log -print -exec cat {} \;; exit 1; }; ruby -e "require \"page_print\"; pdf = PagePrint.html_to_pdf_string(\"<html><body><h1>Hello</h1></body></html>\"); abort \"bad pdf\" unless pdf.start_with?(\"%PDF\"); puts \"ok\""'

- uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ For options and CSV output, see `benchmark/README.md`.

## Requirements

- Ruby 3.0+
- Ruby 3.2+
- Native gems are published for `x86_64-linux` and `arm64-darwin`.
- Native gems vendor PlutoBook but compile the small Ruby extension during install so it links against your local Ruby.
- Source builds on unsupported platforms require PlutoBook development headers and library files.
Expand Down
2 changes: 1 addition & 1 deletion page_print.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
spec.description = 'A Ruby gem with a native extension that renders HTML strings to PDF files via the plutobook C library.'
spec.homepage = 'https://github.com/WizardComputer/page_print'
spec.license = 'MIT'
spec.required_ruby_version = '>= 3.0'
spec.required_ruby_version = '>= 3.2'

precompiled = ENV['PAGE_PRINT_PRECOMPILED'] == '1'
vendor_only = ENV['PAGE_PRINT_VENDOR_ONLY'] == '1'
Expand Down
Loading