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

Create a single DOCX file for every TeX document and optimize pipeline #84

Merged
merged 70 commits into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
1070723
Add `find-files` subcommand to `template.py`
Witiko Jul 10, 2024
3b772b8
Add `fixup-languages` subcommand to `template.py`
Witiko Jul 10, 2024
eb49633
Add `fixup-line-endings` subcommand to `template.py`
Witiko Jul 10, 2024
d7ee8cc
Add `validate-files` subcommand to `template.py`
Witiko Jul 10, 2024
7f7da34
Add `convert-eps-to-pdf` subcommand to `template.py`
Witiko Jul 11, 2024
4e8180a
Add `convert-xlsx-to-pdf` subcommand to `template.py`
Witiko Jul 11, 2024
870455a
Add `compile-tex-to-pdf` subcommand to `template.py`
Witiko Jul 11, 2024
11120b4
Automatically perform fixups in `compile-tex-to-pdf` subcommand
Witiko Jul 11, 2024
25252a2
Include stderr of external commands in error output
Witiko Jul 11, 2024
91cf188
Do not install Git Parallel needlessly
Witiko Jul 11, 2024
2487e74
In CI, enable xtrace only after virtualenv for less verbosity
Witiko Jul 11, 2024
bc89a19
Automatically validate all types of documents with the `validate-file…
Witiko Jul 11, 2024
74b5ec6
Automatically perform validation in `compile-tex-to-pdf` subcommand
Witiko Jul 11, 2024
ab695f6
Only decode stdout and stderr for `kpsewhich`
Witiko Jul 11, 2024
670a8a4
Remove default parameters for positional arguments
Witiko Jul 11, 2024
829abbc
Add `compile-tex-to-html` subcommand to `template.py`
Witiko Jul 11, 2024
7b7bdb5
Debug the `compile-tex-to-html` subcommand
Witiko Jul 11, 2024
55a04df
Fix typos
Witiko Jul 11, 2024
77bb98b
Add `compile-tex-to-epub` subcommand to `template.py`
Witiko Jul 11, 2024
249d64d
Debug the `compile-tex-to-epub` subcommand
Witiko Jul 11, 2024
7876f34
Better show output of external commands
Witiko Jul 11, 2024
c93586f
Update dependencies in CI
Witiko Jul 11, 2024
aa611dd
Decode errors from external commands
Witiko Jul 11, 2024
62d8663
Fix typos
Witiko Jul 11, 2024
cee34b0
Revert "Debug the `compile-tex-to-epub` subcommand"
Witiko Jul 11, 2024
22737ac
Revert "Debug the `compile-tex-to-html` subcommand"
Witiko Jul 11, 2024
ddff750
Add `convert-to-docx` subcommand to `template.py`
Witiko Jul 11, 2024
6b90e46
Keep original suffix in DOCX files to enable conversion back as in #20
Witiko Jul 12, 2024
7205dd8
Add `python` and `python3` to CI
Witiko Jul 12, 2024
bf0350d
Move environmental variable `TEXINPUTS` to `template.py`
Witiko Jul 12, 2024
812ab8b
Add `Dockerfile` for building image `ghcr.io/istqborg/istqb_product_b…
Witiko Jul 12, 2024
da64f63
Add `-interaction=nonstopmode` to `latexmkrc`
Witiko Jul 12, 2024
2eb06ce
Use r-strings for regexps
Witiko Jul 12, 2024
603a4d0
Add file `DEPENDS.txt`
Witiko Jul 12, 2024
6271188
Add script `istqb-template`
Witiko Jul 12, 2024
c019818
Automatically create `istqb_product_base/` during compilation
Witiko Jul 12, 2024
82b4acd
Remove `pip install -U`
Witiko Jul 12, 2024
1d82236
Properly escape parameters in bash script
Witiko Jul 12, 2024
4c8f790
Do not build Docker image outside `main` branch
Witiko Jul 12, 2024
eb9aa0a
Make try-cache block less tall
Witiko Jul 12, 2024
52c0ac6
Use Docker image `ghcr.io/istqborg/istqb_product_base` in `compile.yml`
Witiko Jul 12, 2024
9ac381d
Update message texts for improved consistency
Witiko Jul 12, 2024
b022b9b
Add entrypoint to Docker image
Witiko Jul 12, 2024
0a4904a
Style- and type-check `template.py`
Witiko Jul 12, 2024
2ff3b0f
Run style and type checks in PRs as well
Witiko Jul 12, 2024
f8ca3b0
Build Docker image outside `main` branch
Witiko Jul 13, 2024
a669c7d
Add `libreoffice` command
Witiko Jul 13, 2024
63c9bfa
Copy template *before* validation and fixups
Witiko Jul 13, 2024
884c02f
Fix a typo
Witiko Jul 13, 2024
ffe3b9f
Do not raise exception when we attempt to remove nonexistent directory
Witiko Jul 13, 2024
49b710c
Document using template.py to compile documents locally in `README.md`
Witiko Jul 13, 2024
e0a310a
Always convert XLSX documents with LibreOffice
Witiko Jul 13, 2024
34a537b
Only compile TeX documents whose dependencies changed in a PR
Witiko Jul 13, 2024
f159b62
Fix style errors
Witiko Jul 13, 2024
bc3e7e2
Add more vertical space to `README.md`
Witiko Jul 13, 2024
154ea2f
Fix branch name
Witiko Jul 13, 2024
f19d8cf
Configure Git to consider all directories safe
Witiko Jul 13, 2024
25e77c4
Fix a typo
Witiko Jul 13, 2024
ab71df8
Determine whether documents should be compiled to PDF, EPUB, and HTML
Witiko Jul 13, 2024
eea99aa
Update `README.md`
Witiko Jul 13, 2024
fa268ee
Add logging level to messages
Witiko Jul 13, 2024
f1e9225
Merge markdown files into a single DOCX file
Witiko Jul 13, 2024
a39cff4
Include BIB files in DOCX
Witiko Jul 13, 2024
df9bfac
In `Dockerfile`, validate and fixup the template
Witiko Jul 13, 2024
4c7ff68
Update logging format
Witiko Jul 13, 2024
b601e14
Fix a typo that prevented us from finding languages
Witiko Jul 13, 2024
4cfaa4f
Validate files silently during compilation
Witiko Jul 13, 2024
053f17a
Apply more fixups in `Dockerfile`
Witiko Jul 13, 2024
9e312b3
Revert "Build Docker image outside `main` branch"
Witiko Jul 13, 2024
d70cb87
Pin Markdown 3.6.2 (2024-07-14)
Witiko Jul 13, 2024
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
72 changes: 72 additions & 0 deletions .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Build Docker image
on:
push:
workflow_dispatch:
schedule:
- cron: '0 0 * * TUE'
permissions:
packages: write
env:
DEBIAN_FRONTEND: noninteractive
jobs:
flake8:
name: Style check (Python)
runs-on: ubuntu-latest
container:
image: python:3.12
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install additional packages
run: |
set -ex
pip install -U pip wheel setuptools
pip install flake8
- name: Run Flake8
run: flake8 template.py
pytype:
name: Type check (Python)
needs:
- flake8
runs-on: ubuntu-latest
container:
image: python:3.10
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install additional packages
run: |
set -ex
pip install -U pip wheel setuptools
pip install -r requirements.txt
pip install pytype libcst==1.2.0
- name: Run Pytype
run: pytype template.py
build:
name: Build and publish Docker image
needs:
- flake8
- pytype
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout Git repository witiko/markdown
uses: actions/checkout@v4
with:
repository: witiko/markdown
ref: 3.6.2
fetch-depth: 0
- name: Build intermediate image witiko/markdown:latest-minimal
run: DOCKER_BUILDKIT=1 docker build --build-arg TEXLIVE_TAG=latest-minimal --build-arg DEV_IMAGE=true -t witiko/markdown:latest-minimal .
- name: Checkout Git repository istqborg/istqb_product_base
uses: actions/checkout@v4
- name: Build final image ghcr.io/istqborg/istqb_product_base:latest
run: DOCKER_BUILDKIT=1 docker build -t ghcr.io/istqborg/istqb_product_base:latest .
- name: Login to GitHub Packages
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push Docker image ghcr.io/istqborg/istqb_product_base:latest
run: docker push ghcr.io/istqborg/istqb_product_base:latest
190 changes: 45 additions & 145 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,95 +16,47 @@ permissions:
contents: write
env:
DEBIAN_FRONTEND: noninteractive
TEXINPUTS: '.:./istqb_product_base/template:'
FIND: 'find -follow -path ./.github -prune -o -path ./istqb_product_base -prune -o -path ./template -prune -o -path ./schema -prune -o'
jobs:
validate:
name: Validate YAML documents
runs-on: ubuntu-latest
container:
image: witiko/markdown:3.6.0-10-g11b016ea-latest
image: ghcr.io/istqborg/istqb_product_base:latest
steps:
- name: Install required packages
shell: bash
run: |
set -ex
apt -qy update
apt -qy install --no-install-recommends git parallel
python3 -m venv ~/venv
source ~/venv/bin/activate
pip install yamale~=4.0.4
- name: Set up Git repository
- name: Checkout Git repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Clone repository istqb_product_base
run: |
set -ex
git clone https://github.com/istqborg/istqb_product_base.git
cd istqb_product_base
rm -rf /opt/istqb_product_base
git clone https://github.com/istqborg/istqb_product_base.git /opt/istqb_product_base
cd /opt/istqb_product_base
git checkout ${{ inputs.base-version || github.sha }}
parallel --halt now,fail=1 'sed -i "1s/^/$(sed -rn "/^name\.babel = /s/name\.babel = (\S*).*/babel-language: \1/p" "$(kpsewhich {/.}/babel-{/.}.ini)")\n/" {}' ::: languages/*.yml
- name: Validate metadata*.yml
shell: bash
run: |
set -ex
source ~/venv/bin/activate
$FIND -type f -iregex '.*/metadata.*\.yml$' -print | parallel --halt now,fail=1 yamale --schema=istqb_product_base/schema/metadata.yml {}
- name: Validate questions.yml
shell: bash
run: |
set -ex
source ~/venv/bin/activate
$FIND -type f -iregex '.*/questions\.yml$' -print | parallel --halt now,fail=1 yamale --schema=istqb_product_base/schema/questions.yml {}
- name: Validate languages/*.yml
shell: bash
run: |
set -ex
source ~/venv/bin/activate
parallel --halt now,fail=1 yamale --schema=istqb_product_base/schema/language.yml {} ::: istqb_product_base/languages/*.yml
- name: Check the well-formedness of all YAML documents
run: |
set -ex
$FIND -type f -iregex '.*\.yml$' -print | parallel --halt now,fail=1 istqb_product_base/check-yaml.lua {}
parallel --halt now,fail=1 istqb_product_base/check-yaml.lua {} ::: istqb_product_base/languages/*.yml
- name: Validate YAML documents
run: istqb-template validate-files all-yaml
produce-pdf:
name: Produce PDF documents
needs:
- validate
runs-on: ubuntu-latest
container:
image: witiko/markdown:3.6.0-10-g11b016ea-latest
image: ghcr.io/istqborg/istqb_product_base:latest
steps:
- name: Install required packages
run: |
set -ex
apt -qy update
apt -qy install --no-install-recommends dos2unix git parallel
- name: Set up Git repository
- name: Checkout Git repository
uses: actions/checkout@v4
- name: Install LibreOffice
if: github.ref == 'refs/heads/main'
run: |
set -ex
if $FIND -type f -iregex '.*\.xlsx$' -print | grep -q .
then
wget -O- http://downloadarchive.documentfoundation.org/libreoffice/old/7.3.7.2/deb/x86_64/LibreOffice_7.3.7.2_Linux_x86-64_deb.tar.gz | tar xzv
dpkg -iR LibreOffice_7.3.7.2_Linux_x86-64_deb/DEBS/
fi
with:
fetch-depth: 0
- name: Clone repository istqb_product_base
run: |
set -ex
git clone https://github.com/istqborg/istqb_product_base.git
cd istqb_product_base
rm -rf /opt/istqb_product_base
git clone https://github.com/istqborg/istqb_product_base.git /opt/istqb_product_base
cd /opt/istqb_product_base
git checkout ${{ inputs.base-version || github.sha }}
parallel --halt now,fail=1 'sed -i "1s/^/$(sed -rn "/^name\.babel = /s/name\.babel = (\S*).*/babel-language: \1/p" "$(kpsewhich {/.}/babel-{/.}.ini)")\n/" {}' ::: languages/*.yml
- name: Ensure correct encoding of input files
run: $FIND -type f \( -iregex '.*\.md$' -o -iregex '.*\.yml$' \) -exec dos2unix {} +
- name: Convert EPS images to PDF
run: $FIND -type f -iregex '.*\.eps$' -print | parallel --halt now,fail=1 epstopdf {} {.}-eps-converted-to.pdf
- name: Convert XLSX spreadsheets to PDF
run: $FIND -type f -iregex '.*\.xlsx$' -print | parallel --halt now,fail=1 test ${{github.ref == 'refs/heads/main'}} = true '&&' libreoffice7.3 --headless --convert-to pdf {} --outdir {//} '||' ln -s '$(kpsewhich example-image.pdf)' {.}.pdf
- name: Compile LaTeX documents to PDF
run: $FIND -type f -iregex '.*\.tex$' -print | parallel --halt now,fail=1 test -e {//}/NO_PDF '||' latexmk -r istqb_product_base/latexmkrc {} '&&' '(test {} = ./example-document.tex || mv -v {.}.pdf "$(cat {.}.istqb_project_name).pdf")'
run: istqb-template compile-tex-to-pdf
- name: Upload PDF documents
uses: actions/upload-artifact@v4
with:
Expand All @@ -116,130 +68,78 @@ jobs:
- validate
runs-on: ubuntu-latest
container:
image: witiko/markdown:3.6.0-10-g11b016ea-latest
if: github.ref == 'refs/heads/main'
image: ghcr.io/istqborg/istqb_product_base:latest
steps:
- name: Install required packages
run: |
set -ex
apt -qy update
apt -qy install --no-install-recommends dos2unix git parallel tidy
- name: Set up Git repository
- name: Checkout Git repository
uses: actions/checkout@v4
- name: Install LibreOffice
run: |
set -ex
if $FIND -type f -iregex '.*\.xlsx$' -print | grep -q .
then
wget -O- http://downloadarchive.documentfoundation.org/libreoffice/old/7.3.7.2/deb/x86_64/LibreOffice_7.3.7.2_Linux_x86-64_deb.tar.gz | tar xzv
dpkg -iR LibreOffice_7.3.7.2_Linux_x86-64_deb/DEBS/
fi
with:
fetch-depth: 0
- name: Clone repository istqb_product_base
run: |
set -ex
git clone https://github.com/istqborg/istqb_product_base.git
cd istqb_product_base
rm -rf /opt/istqb_product_base
git clone https://github.com/istqborg/istqb_product_base.git /opt/istqb_product_base
cd /opt/istqb_product_base
git checkout ${{ inputs.base-version || github.sha }}
parallel --halt now,fail=1 'sed -i "1s/^/$(sed -rn "/^name\.babel = /s/name\.babel = (\S*).*/babel-language: \1/p" "$(kpsewhich {/.}/babel-{/.}.ini)")\n/" {}' ::: languages/*.yml
- name: Ensure correct encoding of input files
run: $FIND -type f \( -iregex '.*\.md$' -o -iregex '.*\.yml$' \) -exec dos2unix {} +
- name: Convert XLSX spreadsheets to PDF
run: $FIND -type f -iregex '.*\.xlsx$' -print | parallel --halt now,fail=1 libreoffice7.3 --headless --convert-to pdf {} --outdir {//}
- name: Create output directory html/
run: mkdir html
- name: Compile LaTeX documents to HTML
run: $FIND -type f -iregex '.*\.tex$' -print | parallel --halt now,fail=1 test -e {.}/NO_HTML '||' make4ht -s -c istqb_product_base/istqb.cfg -e istqb_product_base/istqb.mk4 -d html/{.} {}
run: istqb-template compile-tex-to-html html/
- name: Upload HTML documents
uses: actions/upload-artifact@v4
with:
name: HTML
path: html
path: html/
produce-ebooks:
name: Produce EPUB documents
needs:
- validate
runs-on: ubuntu-latest
container:
image: witiko/markdown:3.6.0-10-g11b016ea-latest
if: github.ref == 'refs/heads/main'
image: ghcr.io/istqborg/istqb_product_base:latest
steps:
- name: Install required packages
run: |
set -ex
apt -qy update
apt -qy install --no-install-recommends dos2unix git parallel tidy
- name: Set up Git repository
- name: Checkout Git repository
uses: actions/checkout@v4
- name: Install LibreOffice
run: |
set -ex
if $FIND -type f -iregex '.*\.xlsx$' -print | grep -q .
then
wget -O- http://downloadarchive.documentfoundation.org/libreoffice/old/7.3.7.2/deb/x86_64/LibreOffice_7.3.7.2_Linux_x86-64_deb.tar.gz | tar xzv
dpkg -iR LibreOffice_7.3.7.2_Linux_x86-64_deb/DEBS/
fi
with:
fetch-depth: 0
- name: Clone repository istqb_product_base
run: |
set -ex
git clone https://github.com/istqborg/istqb_product_base.git
cd istqb_product_base
rm -rf /opt/istqb_product_base
git clone https://github.com/istqborg/istqb_product_base.git /opt/istqb_product_base
cd /opt/istqb_product_base
git checkout ${{ inputs.base-version || github.sha }}
parallel --halt now,fail=1 'sed -i "1s/^/$(sed -rn "/^name\.babel = /s/name\.babel = (\S*).*/babel-language: \1/p" "$(kpsewhich {/.}/babel-{/.}.ini)")\n/" {}' ::: languages/*.yml
- name: Ensure correct encoding of input files
run: $FIND -type f \( -iregex '.*\.md$' -o -iregex '.*\.yml$' \) -exec dos2unix {} +
- name: Convert XLSX spreadsheets to PDF
run: $FIND -type f -iregex '.*\.xlsx$' -print | parallel --halt now,fail=1 libreoffice7.3 --headless --convert-to pdf {} --outdir {//}
- name: Create output directory epub/
run: mkdir epub
- name: Compile LaTeX documents to EPUB
shell: bash
run: |
set -ex
shopt -s extglob
$FIND -type f -iregex '.*\.tex$' -print | parallel --halt now,fail=1 test -e {.}/NO_HTML '||' '(' mkdir -p epub/build/{.} '&&' cp -ar !(epub) epub/build/{.}/ '&&' cd epub/build/{.} '&&' tex4ebook -s -c istqb_product_base/istqb.cfg -e istqb_product_base/istqb.mk4 -d ../.. {} ')'
rm -rf epub/build
run: istqb-template compile-tex-to-epub epub/
- name: Upload EPUB documents
uses: actions/upload-artifact@v4
with:
name: EPUB
path: epub
path: epub/
produce-docx:
name: Produce DOCX documents
needs:
- validate
runs-on: ubuntu-latest
container:
image: pandoc/core:3.1.1.0-ubuntu
env:
PANDOC_EXTENSIONS: commonmark+bracketed_spans+fancy_lists+pipe_tables+raw_attribute
image: ghcr.io/istqborg/istqb_product_base:latest
steps:
- name: Install required packages
run: |
set -ex
apt -qy update
apt -qy install --no-install-recommends git parallel
- name: Set up Git repository
- name: Checkout Git repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Clone repository istqb_product_base
run: |
set -ex
git clone https://github.com/istqborg/istqb_product_base.git
cd istqb_product_base
rm -rf /opt/istqb_product_base
git clone https://github.com/istqborg/istqb_product_base.git /opt/istqb_product_base
cd /opt/istqb_product_base
git checkout ${{ inputs.base-version || github.sha }}
parallel --halt now,fail=1 'sed -i "1s/^/$(sed -rn "/^name\.babel = /s/name\.babel = (\S*).*/babel-language: \1/p" "$(kpsewhich {/.}/babel-{/.}.ini)")\n/" {}' ::: languages/*.yml
- name: Create output directory docx/
run: mkdir docx
- name: Convert MD documents to DOCX
run: $FIND -type f -iregex '.*\.md$' -print | parallel --halt now,fail=1 mkdir -p docx/{//} '&&' pandoc -f "${PANDOC_EXTENSIONS}" -i {} -o docx/{}.docx
- name: Convert YAML documents to DOCX
run: $FIND -path ./.github -prune -o -path ./languages -prune -o -type f -iregex '.*\.yml$' -print | parallel --halt now,fail=1 mkdir -p docx/{//} '&&' 'sed -e "1s/^/\`\`\` yml\\n/" -e "\$s/\$/\\n\`\`\`/"' {} '|' pandoc -f "${PANDOC_EXTENSIONS}+hard_line_breaks" -i - -o docx/{}.docx
- name: Convert BIB documents to DOCX
run: $FIND -type f -iregex '.*\.bib$' -print | parallel --halt now,fail=1 mkdir -p docx/{//} '&&' 'sed -e "1s/^/\`\`\` bib\\n/" -e "\$s/\$/\\n\`\`\`/"' {} '|' pandoc -f "${PANDOC_EXTENSIONS}+hard_line_breaks" -i - -o docx/{}.docx
- name: Convert documents to DOCX
run: istqb-template compile-tex-to-docx docx/
- name: Upload DOCX documents
uses: actions/upload-artifact@v4
with:
name: DOCX
path: docx
path: docx/
prerelease:
name: Create a prerelease
if: github.ref == 'refs/heads/main' && inputs.skip-prerelease == false
Expand Down
23 changes: 23 additions & 0 deletions DEPENDS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
babel-czech
babel-english
babel-german
babel-slovak
biber
biblatex
biblatex-iso690
collection-latexrecommended
csquotes
graphbox
imakeidx
lastpage
latexmk
lipsum
makeindex
mdframed
needspace
newunicodechar
supertabular
tex-gyre
titlesec
tocbibind
zref
Loading
Loading