diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..4b2c3d7 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 425ae0b..c48e6c2 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -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 \ @@ -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(\"

Hello

\"); 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(\"

Hello

\"); 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(\"

Hello

\"); abort \"bad pdf\" unless pdf.start_with?(\"%PDF\"); puts \"ok\""' - uses: actions/upload-artifact@v4 diff --git a/README.md b/README.md index 6c55df4..b77374f 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/page_print.gemspec b/page_print.gemspec index c59acac..afd2030 100644 --- a/page_print.gemspec +++ b/page_print.gemspec @@ -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'