From f1ea65edb4f177f47fe6e85c7103c25efa3ecc39 Mon Sep 17 00:00:00 2001 From: Alfred Klomp Date: Mon, 23 May 2022 22:18:29 +0200 Subject: [PATCH] CI: test: add testing stage Add a job to exercise the script in CI by generating a throwaway PDF document and then running shrinkpdf on it. This will guard against any inadvertent breakage by future commits. --- .github/workflows/test.yml | 33 +++++++++++++++++++++++++++++++++ README.md | 1 + 2 files changed, 34 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..1de7664 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,33 @@ +name: Test + +on: [push] + +jobs: + Test: + runs-on: ubuntu-latest + steps: + + # Checkout the code. + - name: Checkout + uses: actions/checkout@v3 + + # Install the test dependencies. + - name: Install dependencies + run: | + sudo apt-get update + sudo apt install ghostscript + sudo apt install librsvg2-bin + sudo apt install texlive-latex-recommended + sudo apt install texlive-latex-extra + sudo apt install pandoc + + # Generate a test PDF by using the README as a convenient source. + - name: Generate test PDF + run: pandoc -s -o orig.pdf README.md + + # Shrink the PDF. + - name: Shrink the PDF + run: | + chmod +x shrinkpdf.sh + ./shrinkpdf.sh orig.pdf new.pdf + ls -al orig.pdf new.pdf diff --git a/README.md b/README.md index 7c0719e..8f88712 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Shrinkpdf: shrink PDF files with Ghostscript [![Shellcheck](https://github.com/aklomp/shrinkpdf/actions/workflows/shellcheck.yml/badge.svg)](https://github.com/aklomp/shrinkpdf/actions/workflows/shellcheck.yml) +[![Test](https://github.com/aklomp/shrinkpdf/actions/workflows/test.yml/badge.svg)](https://github.com/aklomp/shrinkpdf/actions/workflows/test.yml) A simple wrapper around Ghostscript to shrink PDFs (as in reduce filesize) under Linux. Inspired by some code I found in an OpenOffice Python script (I