Commit b15f1715 authored by Matthieu Boileau's avatar Matthieu Boileau
Browse files

Add videos

parent 03476da2
......@@ -16,7 +16,7 @@
"\n",
"# L'intégration continue avec GitLab\n",
"\n",
"![image.png](tanuki.png)\n",
"![image.png](images/tanuki.png)\n",
"\n",
"## *Session pratique*\n",
"\n",
......@@ -39,7 +39,7 @@
"\n",
"GitLab CI propose une chaîne complète d'intégration continue intégrée à son système de forge logicielle.\n",
"\n",
"![](cicd_pipeline_infograph.png)\n",
"![](images/cicd_pipeline_infograph.png)\n",
"<span style=\"font-size:0.7em;\"><https://docs.gitlab.com/ee/ci/README.html></span>\n",
"\n",
"**Les avantages :**\n",
......@@ -113,11 +113,29 @@
"source": [
"## Fork du TP\n",
"\n",
"Faire un *fork* du projet sur votre compte GitLab en allant sur la page d'accueil du projet\n",
"\n",
"![fork.png](fork.png)\n",
"\n",
"ou en suivant [ce lien](https://git.unistra.fr/m.boileau/tp-gitlab-ci/forks/new)."
"Faire un *fork* du projet sur votre compte [GitLab Unistra](https://gitlab.unistra.fr/) en allant sur la [page d'accueil](https://git.unistra.fr/xstra-dev/tp-gitlab-ci) du projet."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "-"
}
},
"source": [
"<video controls src=\"videos/fork.mov\" />"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "-"
}
},
"source": [
"ou en suivant [ce lien](https://git.unistra.fr/xstra-dev/tp-gitlab-ci/forks/new)."
]
},
{
......@@ -144,11 +162,11 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"export USERNAME=\"m.boileau\" # votre login sur git.unistra.fr\n",
"export USERNAME=\"xstra-dev\" # votre login sur git.unistra.fr\n",
"export TPBASEDIR=$HOME # le répertoire où vous souhaitez installer le TP\n",
"export TPDIR=$TPBASEDIR/tp-gitlab-ci"
]
......@@ -162,23 +180,9 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"fatal: destination path 'tp-gitlab-ci' already exists and is not an empty directory.\n"
]
},
{
"ename": "",
"evalue": "128",
"output_type": "error",
"traceback": []
}
],
"outputs": [],
"source": [
"cd $TPBASEDIR\n",
"git clone git@git.unistra.fr:$USERNAME/tp-gitlab-ci.git"
......@@ -194,26 +198,33 @@
"source": [
"## Enregistrer un nouveau runner\n",
"\n",
"> Si `gitlab-runner` n'est pas installé sur votre machine, rdv à la section **Exo1**\n",
"> Si vous ne souhaitez pas installer et configurer `gitlab-runner`, rdv [**Exo1**](#exo1).\n",
"\n",
"\n",
"### Repérer l'URL et le token d'enregistrement\n",
"\n",
"Engistrer un runner consiste à créer un nouveau runner associé à un projet.\n",
"Si vous n'êtes pas administrateur du GitLab, il s'agit forcément d'un runner spécifique. Celui-ci se trouve dans \n",
"votre projet, rubrique :\n",
"Si vous n'êtes pas administrateur du GitLab, il s'agit forcément d'un runner spécifique.\n",
"\n",
"Allez chercher l'URL et le token du projet dans\n",
"\n",
"```\n",
"Settings > CI / CD > Runners settings\n",
"```"
"```\n",
"<video controls src=\"videos/runner-settings.mov\" />"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
"slide_type": "-"
}
},
"source": [
"Dans le terminal, maintenant :"
"### Enregistrement en mode non interactif\n",
"\n",
"On positionne des variables d'environnement pour gitlab-runner"
]
},
{
......@@ -226,12 +237,30 @@
},
"outputs": [],
"source": [
"export CI_SERVER_URL=https://git.unistra.fr/ # Do not change for this session\n",
"export CI_SERVER_URL=https://git.unistra.fr/ # Ne pas changer pour cette session pratique\n",
"export RUNNER_NAME=a_runner_for_$USERNAME\n",
"export REGISTRATION_TOKEN=xxx # Replace by the value provided by the runner setting page\n",
"export REGISTER_NON_INTERACTIVE=true\n",
"#gitlab-runner register --executor shell # sous MacOS\n",
"#sudo gitlab-runner register --executor shell # sous Linux"
"export REGISTRATION_TOKEN=xxx # Remplacez par la valeur indiquée sur la page de paramètres du runner\n",
"export REGISTER_NON_INTERACTIVE=true # nécessaire pour le mode script"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Si vous êtes sous **MacOS**, vous pouvez maintenant enregistrer votre runner en décommentant la ligne suivante :"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": [
"#gitlab-runner register --executor shell"
]
},
{
......@@ -242,24 +271,55 @@
}
},
"source": [
"Ou bien lancez la commande en mode interactif et en suivant pas à pas la [procédure](http://docs.gitlab.com/runner/register/#registering-runners):\n",
"```\n",
"Si vous êtes sous **Linux**, vous pouvez copier les lignes de variables d'environnement dans un terminal et exécuter :\n",
"```bash\n",
"sudo gitlab-runner register --executor shell\n",
"\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"### Enregistrement en mode interactif\n",
"\n",
"Ou bien lancez la commande en mode interactif et compléter le prompt en suivant la vidéo ci-dessous :\n",
"```bash\n",
"gitlab-runner register # sous MacOS\n",
"sudo gitlab-runner register # sous Linux\n",
"```"
"```\n",
"<video controls src=\"videos/runner-register.mov\"/>"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "-"
}
},
"source": [
"Cette procédure est décrite pas à pas dans la [documentation](http://docs.gitlab.com/runner/register/#registering-runners)."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
"slide_type": "subslide"
}
},
"source": [
"### Editer les paramètres du runner\n",
"\n",
"- Retournez sur la page de paramètrage des runners\n",
"- Repérez votre nouveau runner\n",
"- Editez-le et ajouter les tags `specific, shell`\n",
"- Editez-le et ajouter les tags `tp-gitlab-ci, shell` s'ils ne sont pas déjà présents\n",
"\n",
"Votre runner est maintenant prêt à travailler. Nous allons le tester en lui soumettant une tâche GitLab CI déclenchée par un `git push` sur votre projet."
]
......@@ -272,7 +332,7 @@
}
},
"source": [
"## Exo1 : helloworld en bash\n",
"## Exo1 : helloworld en bash <a id='exo1'></a>\n",
"\n",
"### Mettre en place une action d'intégration continue\n",
"\n",
......@@ -281,7 +341,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
......@@ -290,25 +350,14 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Already up-to-date.\n",
"No local changes to save\n",
"Switched to branch 'exo1'\n",
"Your branch is up-to-date with 'origin/exo1'.\n"
]
}
],
"outputs": [],
"source": [
"git pull\n",
"git stash\n",
"git checkout exo1\n",
"git checkout exo1-start .gitlab-ci.yml # Clean previous modifications"
"git checkout exo1-start .gitlab-ci.yml"
]
},
{
......@@ -320,27 +369,13 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"total 40\n",
"drwxr-xr-x 6 boileau staff 204 21 nov 11:15 \u001b[34m.\u001b[39;49m\u001b[0m\n",
"drwxr-xr-x@ 149 boileau staff 5066 21 nov 10:31 \u001b[34m..\u001b[39;49m\u001b[0m\n",
"drwxr-xr-x 16 boileau staff 544 21 nov 11:15 \u001b[34m.git\u001b[39;49m\u001b[0m\n",
"-rw-r--r-- 1 boileau staff 42 21 nov 11:15 .gitignore\n",
"-rw-r--r-- 1 boileau staff 78 21 nov 11:15 .gitlab-ci.yml\n",
"-rwxr-xr-x 1 boileau staff 8432 21 nov 10:35 \u001b[31mhelloworld.e\u001b[39;49m\u001b[0m\n"
]
}
],
"outputs": [],
"source": [
"ls -al"
]
......@@ -354,21 +389,9 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"helloworld:\n",
" tags:\n",
" - shell, specific\n",
" script:\n",
" - echo \"hello, world\"\n"
]
}
],
"outputs": [],
"source": [
"cat .gitlab-ci.yml"
]
......@@ -377,6 +400,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Le fichier `.gitlab-ci.yml` (format YAML) décrit l'intégralité des tâches d'intégration continue avec GitLab CI. Dans cet exemple :\n",
"- `helloworld` indique le nom du job d'intégration continue\n",
"- `tags` permet de sélectionner des runners sur la base de mot-clés\n",
"- `scripts` correspond aux lignes de commande `bash` que vous souhaitez exécuter"
......@@ -398,7 +422,7 @@
"Settings > CI / CD > Runners settings\n",
"```\n",
"\n",
"Notez la présence de plusieurs runners partagés dont `clu1-tp-gitlab-ci` qui portent les tags `shell` et `docker` mais pas `specific`. Pour cibler ce runner, retirer le tag `specific` du fichier `.gitlab-ci.yml`"
"Notez la présence de plusieurs runners partagés dont `clu1-tp-gitlab-ci` qui portent les tags `shell` et `docker` mais pas `tp-gitlab-ci`. Pour cibler ce runner, retirer le tag `tp-gitlab-ci` du fichier `.gitlab-ci.yml`"
]
},
{
......@@ -519,20 +543,9 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"No local changes to save\n",
"Switched to branch 'exo2'\n",
"Your branch is up-to-date with 'origin/exo2'.\n",
"rm '.gitlab-ci.yml'\n"
]
}
],
"outputs": [],
"source": [
"cd $TPDIR\n",
"git stash # si vous avez des modifications non enregistrées dans exo1\n",
......@@ -553,25 +566,9 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"total 56\n",
"drwxr-xr-x 8 boileau staff 272 21 nov 11:57 \u001b[34m.\u001b[39;49m\u001b[0m\n",
"drwxr-xr-x@ 149 boileau staff 5066 21 nov 11:27 \u001b[34m..\u001b[39;49m\u001b[0m\n",
"drwxr-xr-x 16 boileau staff 544 21 nov 11:57 \u001b[34m.git\u001b[39;49m\u001b[0m\n",
"-rw-r--r-- 1 boileau staff 77 21 nov 11:57 .gitignore\n",
"-rw-r--r-- 1 boileau staff 91 21 nov 11:57 helloworld.c\n",
"-rwxr-xr-x 1 boileau staff 8432 21 nov 10:35 \u001b[31mhelloworld.e\u001b[39;49m\u001b[0m\n",
"-rw-r--r-- 1 boileau staff 167 21 nov 11:57 makefile\n",
"-rw-r--r-- 1 boileau staff 149 21 nov 11:57 test_helloworld.py\n"
]
}
],
"outputs": [],
"source": [
"ls -al"
]
......@@ -585,17 +582,9 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"cc helloworld.c -o helloworld.e\n"
]
}
],
"outputs": [],
"source": [
"make"
]
......@@ -621,7 +610,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
......@@ -648,22 +637,9 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"build_hello:\n",
" stage: build\n",
" tags:\n",
" - shell\n",
" script:\n",
" - make\n"
]
}
],
"outputs": [],
"source": [
"cat .gitlab-ci.yml"
]
......@@ -681,22 +657,13 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[exo2 8243488] Add .gitlab-ci.yml with a build stage\n",
" 1 file changed, 7 deletions(-)\n"
]
}
],
"outputs": [],
"source": [
"git add .gitlab-ci.yml\n",
"git commit -m \"Add .gitlab-ci.yml with a build stage\""
......@@ -704,32 +671,14 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": null,
"metadata": {
"scrolled": true,
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Counting objects: 3, done.\n",
"Delta compression using up to 4 threads.\n",
"Compressing objects: 100% (3/3), done.\n",
"Writing objects: 100% (3/3), 311 bytes | 311.00 KiB/s, done.\n",
"Total 3 (delta 2), reused 0 (delta 0)\n",
"remote: \n",
"remote: To create a merge request for exo2, visit:\u001b[K\n",
"remote: https://git.unistra.fr/m.boileau/tp-gitlab-ci/merge_requests/new?merge_request%5Bsource_branch%5D=exo2\u001b[K\n",
"remote: \n",
"To git.unistra.fr:m.boileau/tp-gitlab-ci.git\n",
" 8033a94..8243488 exo2 -> exo2\n"
]
}
],
"outputs": [],
"source": [
"git push"
]
......@@ -763,18 +712,9 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"cc helloworld.c -o helloworld.e\n",
"python test_helloworld.py\n"
]
}
],
"outputs": [],
"source": [
"make test"
]
......@@ -800,7 +740,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
......@@ -817,29 +757,9 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"build_hello:\n",
" stage: build\n",
" tags:\n",
" - shell\n",
" script:\n",
" - make\n",
"\n",
"test_hello:\n",
" stage: test\n",
" tags:\n",
" - shell\n",
" script:\n",
" - make test\n"
]
}
],
"outputs": [],
"source": [
"cat .gitlab-ci.yml"
]
......@@ -857,22 +777,13 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[exo2 69b4c3d] Add a test stage to .gitlab-ci.yml\n",
" 1 file changed, 7 insertions(+)\n"
]
}
],
"outputs": [],
"source": [
"git add .gitlab-ci.yml\n",
"git commit -m \"Add a test stage to .gitlab-ci.yml\""
......@@ -880,29 +791,11 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": null,
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Counting objects: 3, done.\n",
"Delta compression using up to 4 threads.\n",
"Compressing objects: 100% (3/3), done.\n",
"Writing objects: 100% (3/3), 351 bytes | 351.00 KiB/s, done.\n",
"Total 3 (delta 1), reused 0 (delta 0)\n",
"remote: \n",
"remote: To create a merge request for exo2, visit:\u001b[K\n",
"remote: https://git.unistra.fr/m.boileau/tp-gitlab-ci/merge_requests/new?merge_request%5Bsource_branch%5D=exo2\u001b[K\n",
"remote: \n",
"To git.unistra.fr:m.boileau/tp-gitlab-ci.git\n",
" 8243488..69b4c3d exo2 -> exo2\n"
]
}
],
"outputs": [],
"source": [
"git push"
]
......@@ -953,19 +846,9 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"No local changes to save\n",
"Switched to branch 'exo3'\n",
"Your branch is up-to-date with 'origin/exo3'.\n"
]
}
],
"outputs": [],
"source": [
"cd $TPDIR\n",
"git stash # si vous avez des modifications non enregistrées dans exo2\n",
......@@ -1096,7 +979,7 @@
"### Pipeline complet\n",
"\n",
"\n",
"![](pipeline.png)\n",
"![](images/pipeline.png)\n",
"\n",
"Comme le montre ce schéma, l'exécution de différents jobs d'une même étape peut être réalisée en parallèle par différents runners.\n",
"\n",
......@@ -1131,6 +1014,7 @@
}
],
"metadata": {
"celltoolbar": "Slideshow",
"kernelspec": {
"display_name": "Bash",
"language": "bash",
......
%% Cell type:markdown id: tags:
### Journée X/Stra-Dev Intégration continue
21 novembre 2017
---
# L'intégration continue avec GitLab
![image.png](tanuki.png)
![image.png](images/tanuki.png)