Skip to content

Commit

Permalink
Setup github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
MLopez-Ibanez committed Jan 23, 2024
1 parent 8e8f0ac commit 2c43201
Show file tree
Hide file tree
Showing 25 changed files with 274 additions and 35 deletions.
65 changes: 65 additions & 0 deletions .github/texlive_packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# In the case you have to install LaTeX packages manually, you can check
# https://www.ctan.org/pkg/some-package to see in which TeX Live package it is contained,
# or use tlmgr info some-package

# Base tools to compile
# texliveonfly
# latexmk

# Collections
# collection-langeuropean
# collection-fontsrecommended

# Assuming a 'basic' font set up, metafont is required to avoid
# warnings with some packages and errors with others
# metafont mfware

# texliveonfly does not detect the following packages automatically
# amsfonts
# amsmath
# babel-english
# biber
# biblatex
# bigintcalc
# bitset
# bookmark
# caption
# csquotes
# enumitem
# epstopdf-pkg
# etexcmds
# fancyhdr
# fancyvrb
# fandol
# framed
# fvextra
# gettitlestring
# graphics
# hycolor
# hypdoc
# hyperref
# hyphenat
# infwarerr
# intcalc
# kvdefinekeys
# kvoptions
# kvsetkeys
# letltxmacro
# lineno
# listings
# ltxcmds
# minted
# oberdiek
# pdfescape
pdfpages
# pdftexcmds
# pnfss
# ragged2e
# refcount
# rerunfilecheck
# tools
# uniquecounter
# upquote
# xcolor
# xkeyval
# xstring
61 changes: 61 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: CI

on:
push:
paths-ignore: ['README.md','.gitignore']

pull_request:
paths-ignore: ['README.md','.gitignore']

env:
cache-version: v1

jobs:
ci:
if: "! contains(github.event.head_commit.message, '[skip ci]')"
concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession.
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: 💡 Check out repository code
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: "💡 List files in the repository."
run: |
ls -R ${{ github.workspace }}
- uses: r-lib/actions/setup-tinytex@v2-branch
env:
TINYTEX_INSTALLER: TinyTeX-1
TINYTEX_VERSION: 2023.09

- name: Install additional LaTeX packages
run: |
texlive_packages=./.github/texlive_packages
echo "Updating TexLive"
# Keep no backups (not required, simply makes cache bigger)
tlmgr option -- autobackup 0
echo "Updating tlmgr itself"
tlmgr update --self
echo "Install ${texlive_packages}"
tlmgr install $(sed 's/\s*#.*//;/^\s*$/d' "${texlive_packages}")
tlmgr path add
- name: Run test
if: ${{ success() }}
run: ./test

- name: Recreate example
if: ${{ success() && github.event_name == 'push' }}
run: |
make example
git config --local user.name "${GITHUB_ACTOR}"
git config --local user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git add example.pdf
(git commit -m "Recreate example.pdf [skip ci]" && git pull --rebase && git push origin) || echo "No changes to commit"
- run: echo "🍏 This job's status is ${{ job.status }}."
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
*.sta
tmp-*
*.lor
*.soc
*.tdo
test-*.pdf

7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ all: cleanall example.pdf

example.pdf: example.tex newrevisor.sty
@$(MAKE) clean
#pdflatex -file-line-error -shell-escape -interaction=nonstopmode -synctex=1 -recorder "example.tex"
latexmk -pdf "example.tex"
@$(MAKE) clean

test:
@$(MAKE) clean
./test

clean:
rm -f tmp-* *.aux *.log *.out *.sta
rm -f *.aux *.log *.out *.sta *.synctex.gz *.fls

cleanall: clean
rm -f *.pdf
Binary file modified example.pdf
Binary file not shown.
42 changes: 10 additions & 32 deletions example.tex
Original file line number Diff line number Diff line change
@@ -1,30 +1,7 @@
\documentclass[a4paper,11pt]{ydoc}
\usepackage[subpreambles=true]{standalone}
\lstset{numbers=none,columns=fullflexible}
\begin{filecontents}{tmp-example-todonotes.tex}
\documentclass[crop=false]{standalone}
\usepackage[todonotes]{newrevisor}
\setlength{\marginparwidth}{3cm}
\input{example-common}
\end{filecontents}

\begin{filecontents}{tmp-example-default.tex}
\documentclass[class=article,crop=false]{standalone}
\usepackage{newrevisor}
\input{example-common}
\end{filecontents}

\begin{filecontents}{tmp-example-default-hide-after.tex}
\documentclass[class=article,crop=false]{standalone}
\usepackage[hide=after]{newrevisor}
\input{example-common}
\end{filecontents}

\begin{filecontents}{tmp-example-default-hide-before.tex}
\documentclass[class=article,crop=false]{standalone}
\usepackage[hide=before]{newrevisor}
\input{example-common}
\end{filecontents}
\usepackage{pdfpages}
\usepackage[T1]{fontenc}
\lstset{basicstyle=\small\ttfamily,language={[LaTeX]TeX},numbers=none,columns=fullflexible}

\begin{document}
\begin{center}
Expand Down Expand Up @@ -56,10 +33,10 @@
% \end{lstlisting}
% \end{minipage}
\newpage
\fbox{\includestandalone[width=\textwidth,mode=build]{tmp-example-default}}
\lstinputlisting[language={[latex]tex},gobble=4,numbers=none,caption={},frame=lines,firstline=2]{test-default.tex}
\includepdf[frame,width=\textwidth,pages=-]{test-default.pdf}
\newpage

\begin{raggedright}
\begin{raggedright}
Same as above but with option \verb|hide=after|\\[2em]
\end{raggedright}
\par\noindent%
Expand All @@ -68,7 +45,8 @@
\usepackage[hide=after]{newrevisor}
\end{lstlisting}
\end{minipage}
\fbox{\includestandalone[width=\textwidth,mode=build]{tmp-example-default-hide-after}}
\newpage
\includepdf[frame,width=\textwidth,pages=-]{test-default-hide-after.pdf}
\newpage
\begin{raggedright}
Same as above but with option \verb|hide=before|\\[2em]
Expand All @@ -79,7 +57,7 @@
\usepackage[hide=before]{newrevisor}
\end{lstlisting}
\end{minipage}
\fbox{\includestandalone[width=\textwidth,mode=build]{tmp-example-default-hide-before}}
\includepdf[frame,width=\textwidth,pages=-]{test-default-hide-before.pdf}
\newpage
\begin{raggedright}
With option \verb|todonotes|\\[2em]
Expand All @@ -90,7 +68,7 @@
\usepackage[todonotes]{newrevisor}
\end{lstlisting}
\end{minipage}
\fbox{\includestandalone[width=\linewidth,mode=build]{tmp-example-todonotes}}
\includepdf[frame,width=\textwidth,pages=-]{test-todonotes.pdf}
\end{center}
\end{document}
%%% Local Variables:
Expand Down
66 changes: 66 additions & 0 deletions test
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash
set -u
set -o pipefail
PATH=/tmp/texlive/bin/x86_64-linux:$PATH

travis_fold_start() {
if [ ! -z ${TRAVIS:-} ]; then
echo -e "travis_fold:start: $1\033[33;1m$2\033[0m"
else
echo -e "::group:: $1 \033[33;1m$2\033[0m"
fi
}

travis_fold_end() {
if [ ! -z ${TRAVIS:-} ]; then
echo -e "\ntravis_fold:end: $1\r"
else
echo -e "\n::endgroup::\n"
fi
}

latexclean() {
rm -f *.bbl *.aux *.log *.out *.bcf *.blg *.fls *.hd *.fdb_latexmk *.run.xml *.syctex.gz
}

latexmake() {
TEXMAIN=$1
travis_fold_start latexmk.1 "latexmk $TEXMAIN"
latexclean

latexmk -silent -halt-on-error -interaction=nonstopmode -gg --pdf $TEXMAIN
if [ $? -ne 0 ]; then
travis_fold_end latexmk.1
echo "Error: latexmk failed"
LOGFILE=${TEXMAIN%.*}.log
cat "$LOGFILE"
exit 1
fi
travis_fold_end latexmk.1
}

check_snapshot() {
name=$1
pdftoppm -scale-to 800 -png ${name}.pdf ${name}-new
for new in ${name}-new-*.png; do
old=${new//"-new"}
if [ ! -e $old ]; then
echo "Warning: $old does not exist, creating it now"
mv $new $old
continue
fi
diff -q ${old} ${new} > /dev/null
if [ $? -ne 0 ]; then
echo "Error: ${old} and ${new} are different"
exit 1
fi
rm -f ${new}
done
}

for tex in test-*.tex; do
latexmake "$tex"
testname=$(basename $tex .tex)
check_snapshot $testname
done

Binary file added test-default-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test-default-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test-default-hide-after-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions test-default-hide-after.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
\documentclass[class=article,crop=false]{standalone}
\usepackage[hide=after]{newrevisor}
\input{example-common}
Binary file added test-default-hide-before-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions test-default-hide-before.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
\documentclass[class=article,crop=false]{standalone}
\usepackage[hide=before]{newrevisor}
\input{example-common}
3 changes: 3 additions & 0 deletions test-default.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
\documentclass[class=article,crop=false]{standalone}
\usepackage{newrevisor}
\input{example-common}
Binary file added test-float-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test-float-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test-float-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions test-float.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
\documentclass[crop=false]{standalone}
\usepackage{hyperref}
\usepackage{newrevisor}
\newrevisor{manuel}{violet!75}
\newrevisor{maria}{blue}
\begin{document}
\thispagestyle{empty}
\listofrevisions%%
\newpage
\begin{figure}
\centering
A Figure
\caption{Test~\MANUEL{within float}}
\end{figure}
\newpage
\begin{table}
\caption{Test~\MANUEL{within table caption}}
\centering
\begin{tabular}{c}
In Table~\MARIA{within tabular}
\end{tabular}
\end{table}

\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
Binary file added test-list-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test-list-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test-list-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions test-list.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
\documentclass[crop=false]{standalone}
\usepackage[todonotes]{newrevisor}
\usepackage{hyperref}
\newrevisor{manuel}{violet!75}
\newrevisor{maria}{blue}
\newrevisor{peter}{green!80!black}[red]
\begin{document}
\thispagestyle{empty}
\listoftodos
\listofrevisions%%
\newpage
\MANUEL{Something}
\newpage
\maria{delete}{add}

\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
Binary file added test-todonotes-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test-todonotes-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions test-todonotes.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
\documentclass[crop=false]{standalone}
\usepackage[todonotes]{newrevisor}
\setlength{\marginparwidth}{3cm}
\input{example-common}

0 comments on commit 2c43201

Please sign in to comment.