From 5042f21539c212fd2e64a5bab331e0a28caf1669 Mon Sep 17 00:00:00 2001 From: NotXia <35894453+NotXia@users.noreply.github.com> Date: Fri, 17 Nov 2023 10:51:45 +0100 Subject: [PATCH] Fix pdf compilation in workflow --- .github/workflows/compile.yml | 45 +------- compile.sh | 69 ++++++++++++ .../module2/ainotes.cls | 106 +++++++++++++++++- .../ainotes.cls | 106 +++++++++++++++++- .../ainotes.cls | 106 +++++++++++++++++- 5 files changed, 389 insertions(+), 43 deletions(-) create mode 100644 compile.sh mode change 120000 => 100644 src/languages-and-algorithms-for-ai/module2/ainotes.cls mode change 120000 => 100644 src/machine-learning-and-data-mining/ainotes.cls mode change 120000 => 100644 src/statistical-and-mathematical-methods-for-ai/ainotes.cls diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index 83914cf..dcf8860 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -27,52 +27,17 @@ jobs: uses: actions/checkout@v3 with: ref: pdfs - path: src/.compiled + path: .compiled - name: Copy basic files to pdfs branch run: | - cp README.md src/.compiled - cp LICENSE src/.compiled + cp README.md .compiled + cp LICENSE .compiled - name: Compile run: | - shopt -s globstar - cd src - - work_dir=$(pwd) - [[ -f .compiled/.hash.cls ]] && old_class_hash="$(cat .compiled/.hash.cls)" || old_class_hash='' - curr_class_hash="$(git log -n 1 --format='%h' ./ainotes.cls)" - - for f in **/[!_]*.tex; do - f_dir=$(dirname $f) - f_base=$(basename $f) - f_nameonly="${f_base%.*}" - [[ -f .compiled/${f_dir}/.hash ]] && old_hash="$(cat .compiled/${f_dir}/.hash)" || old_hash='' - curr_hash="$(git log -n 1 --format='%h' $f_dir)" - - # Nothing to update - if [[ $old_hash == $curr_hash && $old_class_hash == $curr_class_hash ]]; then - continue - fi - - # Update hash - echo "$curr_hash" > .compiled/${f_dir}/.hash - - cd ${f_dir}; - - # Insert last update date - last_update=$(git log -1 --pretty="format:%ad" --date="format:%d %B %Y" .) - cp --remove-destination $(readlink ainotes.cls) ainotes.cls - sed -i "s/PLACEHOLDER-LAST-UPDATE/${last_update}/" ainotes.cls - - latexmk -pdf -jobname=${f_nameonly} ${f_base} - mkdir -p .compiled/${f_dir} - mv ${f_nameonly}.pdf .compiled/${f_dir}/. - cd $work_dir - done - - echo "$curr_class_hash" > .compiled/.hash.cls + bash ./compile.sh .compiled - name: Move to pdfs branch @@ -80,7 +45,7 @@ jobs: env: REPO: self BRANCH: pdfs - FOLDER: src/.compiled + FOLDER: .compiled GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} COMMIT_NAME: "github-actions[bot]" COMMIT_EMAIL: "github-actions[bot]@users.noreply.github.com" diff --git a/compile.sh b/compile.sh new file mode 100644 index 0000000..0f0db87 --- /dev/null +++ b/compile.sh @@ -0,0 +1,69 @@ +#! /bin/bash + +# +# Commit based .tex compiling +# + +if [ $# -eq 0 ]; then + echo "Missing output directory" + exit -1 +fi + +shopt -s globstar + +out_dir=`realpath $1` +hash_file="$out_dir/.hash" +work_dir=`realpath src` + +mkdir -p $out_dir +touch $hash_file + +# $1: path of the directory +getDirLastHash () { + path="$1" + echo `awk -F"," "\\$1 == \"$path\" { print \\$2 } " $hash_file` +} + +updateHashes() { + cd $work_dir + echo "ainotes.cls,`git log -n 1 --format='%h' ./ainotes.cls`" > $hash_file + for f in **/[!_]*.tex; do + f_dir=$(dirname $f) + echo "$f_dir,`git log -n 1 --format='%h' $f_dir`" >> $hash_file + done +} + + +cd $work_dir + +old_class_hash=`getDirLastHash "ainotes.cls"` +curr_class_hash="$(git log -n 1 --format='%h' ./ainotes.cls)" + +for f in **/[!_]*.tex; do + f_dir=$(dirname $f) + f_base=$(basename $f) + f_nameonly="${f_base%.*}" + old_hash=`getDirLastHash "$f_dir"` + curr_hash="$(git log -n 1 --format='%h' $f_dir)" + + # Nothing to update + if [[ $old_hash == $curr_hash && $old_class_hash == $curr_class_hash ]]; then + echo "Skipping $f_dir" + continue + fi + + + cd ${f_dir}; + + # Insert last update date + last_update=$(git log -1 --pretty="format:%ad" --date="format:%d %B %Y" .) + cp --remove-destination $(readlink ainotes.cls) ainotes.cls + sed -i "s/PLACEHOLDER-LAST-UPDATE/${last_update}/" ainotes.cls + + latexmk -pdf -jobname=${f_nameonly} ${f_base} + mkdir -p $out_dir/$f_dir + mv ${f_nameonly}.pdf $out_dir/${f_dir}/. + cd $work_dir +done + +updateHashes \ No newline at end of file diff --git a/src/languages-and-algorithms-for-ai/module2/ainotes.cls b/src/languages-and-algorithms-for-ai/module2/ainotes.cls deleted file mode 120000 index 146fd3c..0000000 --- a/src/languages-and-algorithms-for-ai/module2/ainotes.cls +++ /dev/null @@ -1 +0,0 @@ -../../ainotes.cls \ No newline at end of file diff --git a/src/languages-and-algorithms-for-ai/module2/ainotes.cls b/src/languages-and-algorithms-for-ai/module2/ainotes.cls new file mode 100644 index 0000000..18f01ab --- /dev/null +++ b/src/languages-and-algorithms-for-ai/module2/ainotes.cls @@ -0,0 +1,105 @@ +\NeedsTeXFormat{LaTeX2e}[] +\ProvidesClass{ainotes} + +\LoadClass{scrreprt} + + +\usepackage{geometry} +\usepackage{graphicx, xcolor} +\usepackage{amsmath, amsfonts, amssymb, amsthm, mathtools, bm, upgreek, cancel} +\usepackage[pdfusetitle]{hyperref} +\usepackage[nameinlink]{cleveref} +\usepackage[all]{hypcap} % Links hyperref to object top and not caption +\usepackage[inline]{enumitem} +\usepackage{marginnote} +\usepackage[bottom]{footmisc} +\usepackage{scrlayer-scrpage} +\usepackage{scrhack, algorithm, listings} +\usepackage{array, makecell, multirow} +\usepackage{acro} +\usepackage{subcaption} +\usepackage{eurosym} +\usepackage{bussproofs} % Deductive tree + +\geometry{ margin=3cm, lmargin=1.5cm, rmargin=4.5cm, marginparwidth=3cm } +\hypersetup{ colorlinks, citecolor=black, filecolor=black, linkcolor=black, urlcolor=black, linktoc=all } + +\definecolor{codegreen}{rgb}{0,0.6,0} +\definecolor{codegray}{rgb}{0.5,0.5,0.5} +\definecolor{codepurple}{rgb}{0.58,0,0.82} +\definecolor{backcolour}{rgb}{0.95,0.95,0.92} +\lstdefinestyle{mystyle}{ + commentstyle = \color{codegreen}, + keywordstyle = \color{magenta}, + numberstyle = \tiny\color{codegray}, + stringstyle = \color{codepurple}, + basicstyle = \footnotesize\ttfamily, + breakatwhitespace = false, + breaklines = true, + captionpos = b, + keepspaces = true, + numbers = none, + showspaces = false, + showstringspaces = true, + showtabs = false, + tabsize = 3 +} +\lstset{style=mystyle} +\lstset{language=Python} + +\NewDocumentEnvironment{descriptionlist}{}{% + \begin{description}[labelindent=1em] +}{ + \end{description}% +} +\setlength{\parindent}{0pt} +\renewcommand*{\marginfont}{\color{gray}\footnotesize} +\renewcommand*\chapterpagestyle{scrheadings} % Header in chapter pages + +\theoremstyle{definition} +\newtheorem{theorem}{Theorem}[section] +\newtheorem{corollary}{Corollary}[theorem] +\newtheorem{lemma}[theorem]{Lemma} +\newtheorem*{example}{Example} +\theoremstyle{definition} +\newtheorem*{definition}{Def} + +\newcommand{\ubar}[1]{\text{\b{$#1$}}} +\renewcommand{\vec}[1]{{\bm{\mathbf{#1}}}} +\newcommand{\nullvec}[0]{\bar{\vec{0}}} +\newcommand{\matr}[1]{{\bm{#1}}} +\newcommand{\prob}[1]{{\mathcal{P}\left({#1}\right)}} + + +\renewcommand*{\maketitle}{% + \begin{titlepage} + \newgeometry{margin=3cm} + \centering + \vspace*{\fill} + \huge + \textbf{\@title}\\ + {\Large Last update: {10 novembre 2023}} + \vspace*{\fill} + + \Large + Academic Year \@date\\ + Alma Mater Studiorum $\cdot$ University of Bologna + \vspace*{1cm} + \restoregeometry + \end{titlepage} + \newpage +} + + +\newcommand*{\makenotesfront}{% + \newgeometry{margin=3cm} + \maketitle + \pagenumbering{roman} + \tableofcontents + \restoregeometry + \newpage + \pagenumbering{arabic} +} + + +\newcommand{\eoc}[0]{\begin{flushright}\texttt{\raggedleft\small }\end{flushright}} \ No newline at end of file diff --git a/src/machine-learning-and-data-mining/ainotes.cls b/src/machine-learning-and-data-mining/ainotes.cls deleted file mode 120000 index c22704b..0000000 --- a/src/machine-learning-and-data-mining/ainotes.cls +++ /dev/null @@ -1 +0,0 @@ -../ainotes.cls \ No newline at end of file diff --git a/src/machine-learning-and-data-mining/ainotes.cls b/src/machine-learning-and-data-mining/ainotes.cls new file mode 100644 index 0000000..38f7138 --- /dev/null +++ b/src/machine-learning-and-data-mining/ainotes.cls @@ -0,0 +1,105 @@ +\NeedsTeXFormat{LaTeX2e}[] +\ProvidesClass{ainotes} + +\LoadClass{scrreprt} + + +\usepackage{geometry} +\usepackage{graphicx, xcolor} +\usepackage{amsmath, amsfonts, amssymb, amsthm, mathtools, bm, upgreek, cancel} +\usepackage[pdfusetitle]{hyperref} +\usepackage[nameinlink]{cleveref} +\usepackage[all]{hypcap} % Links hyperref to object top and not caption +\usepackage[inline]{enumitem} +\usepackage{marginnote} +\usepackage[bottom]{footmisc} +\usepackage{scrlayer-scrpage} +\usepackage{scrhack, algorithm, listings} +\usepackage{array, makecell, multirow} +\usepackage{acro} +\usepackage{subcaption} +\usepackage{eurosym} +\usepackage{bussproofs} % Deductive tree + +\geometry{ margin=3cm, lmargin=1.5cm, rmargin=4.5cm, marginparwidth=3cm } +\hypersetup{ colorlinks, citecolor=black, filecolor=black, linkcolor=black, urlcolor=black, linktoc=all } + +\definecolor{codegreen}{rgb}{0,0.6,0} +\definecolor{codegray}{rgb}{0.5,0.5,0.5} +\definecolor{codepurple}{rgb}{0.58,0,0.82} +\definecolor{backcolour}{rgb}{0.95,0.95,0.92} +\lstdefinestyle{mystyle}{ + commentstyle = \color{codegreen}, + keywordstyle = \color{magenta}, + numberstyle = \tiny\color{codegray}, + stringstyle = \color{codepurple}, + basicstyle = \footnotesize\ttfamily, + breakatwhitespace = false, + breaklines = true, + captionpos = b, + keepspaces = true, + numbers = none, + showspaces = false, + showstringspaces = true, + showtabs = false, + tabsize = 3 +} +\lstset{style=mystyle} +\lstset{language=Python} + +\NewDocumentEnvironment{descriptionlist}{}{% + \begin{description}[labelindent=1em] +}{ + \end{description}% +} +\setlength{\parindent}{0pt} +\renewcommand*{\marginfont}{\color{gray}\footnotesize} +\renewcommand*\chapterpagestyle{scrheadings} % Header in chapter pages + +\theoremstyle{definition} +\newtheorem{theorem}{Theorem}[section] +\newtheorem{corollary}{Corollary}[theorem] +\newtheorem{lemma}[theorem]{Lemma} +\newtheorem*{example}{Example} +\theoremstyle{definition} +\newtheorem*{definition}{Def} + +\newcommand{\ubar}[1]{\text{\b{$#1$}}} +\renewcommand{\vec}[1]{{\bm{\mathbf{#1}}}} +\newcommand{\nullvec}[0]{\bar{\vec{0}}} +\newcommand{\matr}[1]{{\bm{#1}}} +\newcommand{\prob}[1]{{\mathcal{P}\left({#1}\right)}} + + +\renewcommand*{\maketitle}{% + \begin{titlepage} + \newgeometry{margin=3cm} + \centering + \vspace*{\fill} + \huge + \textbf{\@title}\\ + {\Large Last update: {12 novembre 2023}} + \vspace*{\fill} + + \Large + Academic Year \@date\\ + Alma Mater Studiorum $\cdot$ University of Bologna + \vspace*{1cm} + \restoregeometry + \end{titlepage} + \newpage +} + + +\newcommand*{\makenotesfront}{% + \newgeometry{margin=3cm} + \maketitle + \pagenumbering{roman} + \tableofcontents + \restoregeometry + \newpage + \pagenumbering{arabic} +} + + +\newcommand{\eoc}[0]{\begin{flushright}\texttt{\raggedleft\small }\end{flushright}} \ No newline at end of file diff --git a/src/statistical-and-mathematical-methods-for-ai/ainotes.cls b/src/statistical-and-mathematical-methods-for-ai/ainotes.cls deleted file mode 120000 index c22704b..0000000 --- a/src/statistical-and-mathematical-methods-for-ai/ainotes.cls +++ /dev/null @@ -1 +0,0 @@ -../ainotes.cls \ No newline at end of file diff --git a/src/statistical-and-mathematical-methods-for-ai/ainotes.cls b/src/statistical-and-mathematical-methods-for-ai/ainotes.cls new file mode 100644 index 0000000..3852acd --- /dev/null +++ b/src/statistical-and-mathematical-methods-for-ai/ainotes.cls @@ -0,0 +1,105 @@ +\NeedsTeXFormat{LaTeX2e}[] +\ProvidesClass{ainotes} + +\LoadClass{scrreprt} + + +\usepackage{geometry} +\usepackage{graphicx, xcolor} +\usepackage{amsmath, amsfonts, amssymb, amsthm, mathtools, bm, upgreek, cancel} +\usepackage[pdfusetitle]{hyperref} +\usepackage[nameinlink]{cleveref} +\usepackage[all]{hypcap} % Links hyperref to object top and not caption +\usepackage[inline]{enumitem} +\usepackage{marginnote} +\usepackage[bottom]{footmisc} +\usepackage{scrlayer-scrpage} +\usepackage{scrhack, algorithm, listings} +\usepackage{array, makecell, multirow} +\usepackage{acro} +\usepackage{subcaption} +\usepackage{eurosym} +\usepackage{bussproofs} % Deductive tree + +\geometry{ margin=3cm, lmargin=1.5cm, rmargin=4.5cm, marginparwidth=3cm } +\hypersetup{ colorlinks, citecolor=black, filecolor=black, linkcolor=black, urlcolor=black, linktoc=all } + +\definecolor{codegreen}{rgb}{0,0.6,0} +\definecolor{codegray}{rgb}{0.5,0.5,0.5} +\definecolor{codepurple}{rgb}{0.58,0,0.82} +\definecolor{backcolour}{rgb}{0.95,0.95,0.92} +\lstdefinestyle{mystyle}{ + commentstyle = \color{codegreen}, + keywordstyle = \color{magenta}, + numberstyle = \tiny\color{codegray}, + stringstyle = \color{codepurple}, + basicstyle = \footnotesize\ttfamily, + breakatwhitespace = false, + breaklines = true, + captionpos = b, + keepspaces = true, + numbers = none, + showspaces = false, + showstringspaces = true, + showtabs = false, + tabsize = 3 +} +\lstset{style=mystyle} +\lstset{language=Python} + +\NewDocumentEnvironment{descriptionlist}{}{% + \begin{description}[labelindent=1em] +}{ + \end{description}% +} +\setlength{\parindent}{0pt} +\renewcommand*{\marginfont}{\color{gray}\footnotesize} +\renewcommand*\chapterpagestyle{scrheadings} % Header in chapter pages + +\theoremstyle{definition} +\newtheorem{theorem}{Theorem}[section] +\newtheorem{corollary}{Corollary}[theorem] +\newtheorem{lemma}[theorem]{Lemma} +\newtheorem*{example}{Example} +\theoremstyle{definition} +\newtheorem*{definition}{Def} + +\newcommand{\ubar}[1]{\text{\b{$#1$}}} +\renewcommand{\vec}[1]{{\bm{\mathbf{#1}}}} +\newcommand{\nullvec}[0]{\bar{\vec{0}}} +\newcommand{\matr}[1]{{\bm{#1}}} +\newcommand{\prob}[1]{{\mathcal{P}\left({#1}\right)}} + + +\renewcommand*{\maketitle}{% + \begin{titlepage} + \newgeometry{margin=3cm} + \centering + \vspace*{\fill} + \huge + \textbf{\@title}\\ + {\Large Last update: {18 ottobre 2023}} + \vspace*{\fill} + + \Large + Academic Year \@date\\ + Alma Mater Studiorum $\cdot$ University of Bologna + \vspace*{1cm} + \restoregeometry + \end{titlepage} + \newpage +} + + +\newcommand*{\makenotesfront}{% + \newgeometry{margin=3cm} + \maketitle + \pagenumbering{roman} + \tableofcontents + \restoregeometry + \newpage + \pagenumbering{arabic} +} + + +\newcommand{\eoc}[0]{\begin{flushright}\texttt{\raggedleft\small }\end{flushright}} \ No newline at end of file