Skip to content
Snippets Groups Projects
Commit 468c56ed authored by Florent Chehab's avatar Florent Chehab
Browse files

inital commit

parents
No related branches found
No related tags found
No related merge requests found
Pipeline #
lettre-UTC-ex.*
!lettre-UTC-ex.tex
__EXTERNAL_ASSETS__
build
latex-lettre-UTC.zip
*.png
\ No newline at end of file
image: blang/latex
building-latex-master:
stage: build
script:
- apt-get update --yes
- apt-get install imagemagick --yes
- apt-get install wget --yes
- bash get_assets.sh
- bash make_build.sh
artifacts:
paths:
- lettre-UTC-ex.pdf
- latex-lettre-UTC.zip
- lettre-ex-0.png
- lettre-ex-1.png
expire_in: 2 year
only:
- master
tags:
- docker
building-latex-other-branch:
stage: build
script:
- latexmk -pdf main.tex
artifacts:
paths:
- "*.pdf"
expire_in: 2 week
except:
- master
tags:
- docker
\ No newline at end of file
$latex = 'latex -shell-escape';
$pdflatex = 'pdflatex -shell-escape';
LICENSE 0 → 100644
BSD 2-Clause License
Copyright (c) 2018, LaTeX-UTC
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
README.md 0 → 100644
Intégration Continue : **LaTeX** et **GitLab**.
=======
- [Démonstration](#d%C3%A9monstration)
- [Explications](#explications)
- [Prérequis : activer le _shared Runner_](#pr%C3%A9requis-activer-le-shared-runner)
- [C'est parti](#cest-parti)
- [Remarques](#remarques)
- [Commentaires sur l'intégration continue](#commentaires-sur-lint%C3%A9gration-continue)
- [Pour aller plus loin](#pour-aller-plus-loin)
# Démonstration
Ce _repo_ est en lui-même un démonstation de l'utilisation de l'intégration continue pour la compilation de LaTeX. Le fichier `main.tex` est compilé (voir [Explications](#explications)) et le `pdf` est disponible [ici](https://gitlab.utc.fr/LaTeX-UTC/LaTeX-CI/-/jobs/artifacts/master/raw/main.pdf?job=building-latex-master).
N'hésitez pas à cloner ce _repo_ pour vous en servir comme base.
# Explications
## Prérequis : activer le _shared Runner_
1. Rendez-vous das les `paramètres` du projet GitLab, section `CI/CD`.
1. Cliquez sur `Runners settings` (_expand_).
1. Dans la section _Shared Runners_, cliquez sur _« Activate shared Runners »_.
## C'est parti
Vous n'avez plus qu'à modifier le fichier `main.tex` et à _commit_ les changements, la compilation et la publication à l'adresse `https://gitlab.utc.fr/<login-ou-namespace>/<nom-du-projet>/-/jobs/artifacts/master/raw/main.pdf?job=building-latex-master` se fait automatiquement. Par exemple, pour ce projet, le pdf est disponible à l'adresse [https://gitlab.utc.fr/LaTeX-UTC/LaTeX-CI/-/jobs/artifacts/master/raw/main.pdf?job=building-latex-master](https://gitlab.utc.fr/LaTeX-UTC/LaTeX-CI/-/jobs/artifacts/master/raw/main.pdf?job=building-latex-master).
### Remarques
- Les `pdf` compilés sont rendus disponibles en public via les _artifacts_. Ces derniers peuvent être visualisés via :
- La page d'accueil du projet, cliquez sur l'icône _télécharger_ puis sur `Télécharger 'building-latex-master'`
- Dans le menu du projet, cliquez sur `CI/CD` -> `jobs`, puis sur le badge (espérons "réussi") du status associé au job souhaité, puis dans le menu de droite, dans la section `Job artifacts` cliquez sur `browse`.
- Url :
- Pour la branche master : `https://gitlab.utc.fr/<login-ou-namespace>/<nom-du-projet>/-/jobs/artifacts/master/raw/main.pdf?job=building-latex-master`
- Pour les autres branches : `https://gitlab.utc.fr/<login-ou-namespace>/<nom-du-projet>/-/jobs/artifacts/<nom-de-la-branche>/raw/main.pdf?job=building-latex-other-branch`
- Si la compilation échoue, le _job_ sera marqué comme tel et vous pouvez accéder aux logs pour savoir où elle a échouée.
- _Pensez à adapter la license à votre projet._
## Commentaires sur l'intégration continue
Avec GitLab, toute l'intégration continue est gérée via le fichier `.gitlab-ci.yml`. Voici celui utilisé par ce projet (avec quelques commentaires).
Il comporte 2 _jobs_ sensiblement similaires qui permettent une gestion optimale des ressources disques : à l'heure de la réalisation de ce projet il n'est pas [encore](https://gitlab.com/gitlab-org/gitlab-ce/issues/23777) possible de garder uniquement les derniers artifacts. Pour contourner le système :
- Les artifacts issus de la branche master sont conservés 2 ans.
- Les artifacts issus des autres branches sont conservés 2 semaines.
```yaml
# Téléchargement d'une image Docker avec tous les packets
# texlive pour éviter les ennuis lors de la compilation latex
image: blang/latex
# Premier job : compilation du latex
building-latex-master:
stage: build
script:
# Compilation avec latexmk du fichier main.tex
# qui est à la racine du repo
- latexmk -pdf main.tex
artifacts:
# Génération d'une archive téléchargeable avec le fichier
paths:
- "*.pdf"
expire_in: 2 year # Durée de validité de l'archive
tags:
# Tag pour que le shared runner du GitLab de l'UTC
# fasse sont travail.
- docker
# Deuxième job : similaire, mais pour les autres branches
building-latex-other-branch:
stage: build
script:
- latexmk -pdf main.tex
artifacts:
paths:
- "*.pdf"
expire_in: 2 week # durée plus courte
except: # toutes les branches sauf master
- master
tags:
- docker
```
### Pour aller plus loin
Dans la partie `script` d'un job décrit dans le fichier `.gitlab-ci.yml` vous pouvez installer des packets (`apt-get install --yes <nom-du-paquet>`) voire exécuter des scripts bash qui seraient disponibles dans le repo :
```yaml
# [...]
building-latex-master:
stage: build
script:
- bash build.sh
# [...]
```
Les possibilités sont donc infinies :)
- Un peu de lecture : https://gitlab.com/help/user/project/pipelines/job_artifacts.md
- Pour tester vos fichiers `.gitlab-ci.yml` : https://gitlab.utc.fr/ci/lint
**Amusez-vous bien.** :wink:
\ No newline at end of file
# Création du dossier des assets externes s'il le faut
if [ -d ./__EXTERNAL_ASSETS__ ];
then
echo 'Le dossier contenant les assets extérieurs a été trouvé.';
else
echo "Le dossier contenant les assets extérieurs n'a pas été trouvé.";
mkdir __EXTERNAL_ASSETS__
echo " Il vient d'être créé";
fi
cd ./__EXTERNAL_ASSETS__
# Récupération dse images et logo s'il le faut
if [ -f logo_UTC.pdf ];
then
echo "Le logo de l'UTC est déjà présent.";
else
wget https://gitlab.utc.fr/LaTeX-UTC/Graphismes-UTC/raw/master/logos/UTC/logo_UTC.pdf
fi
if [ -f fleche.pdf ];
then
echo "La flèche de l'UTC est déjà présente.";
else
wget https://gitlab.utc.fr/LaTeX-UTC/Graphismes-UTC/raw/master/elements/fleche/fleche.pdf
fi
# Récupération du packet LaTeX contenant les couleurs
if [ -f couleurs_UTC.sty ];
then
echo "Le packet LaTeX contenant les couleurs de l'UTC est présent.";
else
wget https://gitlab.utc.fr/LaTeX-UTC/Graphismes-UTC/raw/master/couleurs/couleurs_UTC.sty
fi
cd ../
echo "Tous les assets extérieurs nécesssaires sont opérationnels.";
\ No newline at end of file
\documentclass{lettre-UTC}
\usepackage{blindtext}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Commandes pour jouer avec la configuration de la lettre
% \def\printLigne{} % Dé-commenter pour ne pas avoir la ligne de 1/3 de page
% \def\blockInfosUTC{} % Dé-commenter pour retirer l'encart d'informations UTC
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Définition du contenu de la lettre
\def\adresse{%
ARC\\
à l’att. de Gilbert Durand
\\ \bigskip
Place de l’hôtel de ville\\
BP 1000\\
60 321 Compiègne Cedex
}
\def\letterDate{\today}
\def\letterInfo{
\textbf{Objet}\\ %
Objet Objet Objet Objet Objet Objet %
\\ \bigskip
\textbf{Référence}\\ %
DG64748
\\ \bigskip %
\textbf{Suivi par}\\ %
François Dupond %
}
%\def\heightBlockInfo{25mm} % Pour changer la hauteur
% % du block d'info (25mm) par défaut
\def\infosPerso{%
\textbf{Service Communication\\%
François Dupond}%
\\ \bigskip%
tél : 03 12 34 56 78\\%
françois.dupond@utc.fr%
\vspace*{3mm}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Fin de la configuration, début de l'écriture
\begin{document}
\Blindtext
\begin{flushright}
\Large François Dupond \hspace*{2cm}
\end{flushright}
\end{document}
\ No newline at end of file
\ProvidesClass{lettre-UTC}
\LoadClass{article}
\usepackage{__EXTERNAL_ASSETS__/couleurs_UTC}
\usepackage[a4paper, left=55mm, right=10mm, top=47mm, bottom=45mm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[francais]{babel}
\renewcommand{\familydefault}{\sfdefault}
\usepackage{atbegshi}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{lastpage}
\usepackage{hyperref}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% éléments par défauts
\def\adresse{%
Pas d'adresse inscite.%
Merci d'utiliser la comande \texttt{\@backslashchar adresse} dans le préambule.%
}
\def\letterDate{Pas de date ?}
\def\letterInfo{Pas d'information.}
\def\heightBlockInfo{25mm}
\def\infosPerso{Où sont les infos ??}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Graphismes
\newcommand\print@Fleche{%
\ifnum\value{page}>1\relax
\begin{tikzpicture}[overlay, remember picture]
\node[anchor=north east,
xshift=200mm, %shifting around
yshift=-10mm, inner sep = 0pt]
at (current page.north west) %left upper corner of the page
{\includegraphics[height=10mm]{__EXTERNAL_ASSETS__/fleche.pdf}};
\end{tikzpicture}
\fi
}
\newcommand\print@LogoUTC{
\ifnum\value{page}=1\relax
\begin{tikzpicture}[overlay, remember picture]
\node[anchor=north east, %anchor is upper left corner of the graphic
xshift=52.2mm, %shifting around
yshift=-10mm, inner sep = 0pt]
at (current page.north west) %left upper corner of the page
{\includegraphics[height=21.7mm]{__EXTERNAL_ASSETS__/logo_UTC.pdf}};
\end{tikzpicture}
\fi
}
\newcommand\printLigne{%
\begin{tikzpicture}[overlay, remember picture]
\node[anchor=north west,
xshift=0mm, %shifting around
yshift=-99mm, inner sep = 0mm]
at (current page.north west) %left upper corner of the page
{\tikz \draw [line width = 0.2mm] (0,0) -- (13mm,0mm);};
\end{tikzpicture}
}
\newcommand\pint@Footer{%
\begin{tikzpicture}[overlay, remember picture]
% rectangle jaune
\node[anchor=north west, %anchor is upper left corner of the graphic
xshift=1cm, %shifting around
yshift=-277mm, inner sep = 0pt]
at (current page.north west) %left upper corner of the page
{\tikz \fill [jauneUTC] (0,0) rectangle (19cm,1cm); };
% page number
\node[anchor=north east, %anchor is upper left corner of the graphic
xshift=200mm, %shifting around
yshift=-272mm, inner sep = 0pt]
at (current page.north west) %left upper corner of the page
{\textbf{\thepage/\pageref{LastPage}} };
\end{tikzpicture}%
}
\newcommand\printAdress{
\ifnum\value{page}=1\relax
\begin{tikzpicture}[overlay, remember picture]
\node[anchor=north west,
xshift=110mm, %shifting around
yshift=-47mm,text width=80mm, inner sep = 0pt]
at (current page.north west) %left upper corner of the page
{\adresse};
\end{tikzpicture}
\fi
}
\newcommand\blockInfosUTC{%
\ifnum\value{page}=1\relax
\begin{tikzpicture}[overlay, remember picture]
% rectangle plein
\node[anchor=north west,
xshift=10mm, %shifting around
yshift=-227mm, inner sep = 0pt]
at (current page.north west) %left upper corner of the page
{\tikz \fill [jauneClairUTC] (0,0) rectangle (42mm,50mm);};
% contenu
\node[anchor=north west,
xshift=12mm, %shifting around
yshift=-227mm,text width=42mm, inner sep = 0pt]
at (current page.north west) %left upper corner of the page
{%
\vspace*{3.5mm}\\%
\textcolor{grisUTC}{%
\textbf{Université de\\%
Techologie \\%
de Compiègne}%
\bigskip \\%
CS 60 319\\%
\small{Rue du Docteur Schweitzer}\\%
60 203 Compiègne cedex
\bigskip \\%
tél: 03 44 23 44 23\\%
\textbf{\href{www.utc.fr}{www.utc.fr}}%
}%
};
\end{tikzpicture}
\fi
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Blocks de texte
\newcommand\blockInfosPerso{%
\ifnum\value{page}=1\relax
\begin{tikzpicture}[overlay, remember picture]
% rectangle
\node[anchor=south west,
xshift=10mm, %shifting around
yshift=-228mm, inner sep = 0mm]
at (current page.north west) %left upper corner of the page
{\tikz \draw [jauneClairUTC, line width = 1mm] (0,0) rectangle (41mm,\heightBlockInfo);};
% contenu
\node[anchor=south west,
xshift=12mm, %shifting around
yshift=-228mm,text width=42mm, inner sep = 0pt]
at (current page.north west) %left upper corner of the page
{\infosPerso};
\end{tikzpicture}
\fi
}
\newcommand\printLetterInfo{%
\ifnum\value{page}=1\relax
\begin{tikzpicture}[overlay, remember picture]
\node[anchor=north west,
xshift=10mm, %shifting around
yshift=-47mm,text width=42mm, inner sep = 0pt]
at (current page.north west) %left upper corner of the page
{\letterDate\\ \bigskip %
\letterInfo};
\end{tikzpicture}
\fi
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Génération
\pagestyle{empty}
\AtBeginShipout{%
\AtBeginShipoutAddToBox{
\printAdress%
\printLetterInfo%
\print@LogoUTC%
\print@Fleche%
\printLigne%
\blockInfosUTC%
\blockInfosPerso%
\pint@Footer}%
}
\AtBeginDocument{
\vspace*{5cm} % Hack pour la première page
}
\ No newline at end of file
if [ -d ./build ];
then
rm -rf build;
mkdir build;
else
mkdir build;
fi
cp lettre-UTC.cls ./build
cp lettre-UTC-ex.tex ./build
cp LICENSE ./build
cp README.md ./build
cp -r __EXTERNAL_ASSETS__ ./build
cp .gitignore ./build
cp .latexmkrc ./build
# copy for building
cp -rf ./build ./build_tmp
# try to build
cd ./build_tmp
latexmk -pdf lettre-UTC-ex.tex
# if successfull
cd ../
cp build_tmp/lettre-UTC-ex.pdf ./
rm -rf ./build_tmp
zip -r latex-lettre-UTC.zip ./build
# generate preview
convert -density 150 lettre-UTC-ex.pdf -quality 90 lettre-ex.png
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment