diff --git a/slides.ipynb b/slides.ipynb
index fb171f1..652189c 100644
--- a/slides.ipynb
+++ b/slides.ipynb
@@ -1,525 +1,529 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Already up to date.\n"
]
}
],
"source": [
"cd ../so-workshop\n",
"git pull"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# So, you want to go open Science ?\n",
"## WORKSHOP TIME !\n",
"\n",
"
\n",
"- https://c4science.ch/source/so-workshop/\n",
"- https://c4science.ch/source/so-slides/\n",
"
\n",
"\n",
"SCITAS training with expertise from the EPFL Library
\n",
"Nicolas Richart and Jean-Baptiste Aubort - SCITAS"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Continuous Integration (CI)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"## What is CI ?\n",
"\n",
"- Automation of build and tests\n",
"- Run tests at each commit\n",
"- You need to write tests !"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"## Why use CI ?\n",
"\n",
"- Detect bugs when they are introduced\n",
"- Detect when fixed bugs appear again (regression)\n",
"- Publish code that works"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"Ensure code has a certain quality level\n",
"- Linters\n",
"- Test Coverage"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Jenkins on c4science"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## https://c4science.ch/jobs\n",
"![](images/c4s-jenkinsjob.png)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## https://jenkins.c4science.ch/\n",
"![](images/c4s-jenkins.png)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Example\n",
"## Jenkins base"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Switched to branch 'feature/jenkins-base'\n",
"Your branch is up to date with 'origin/feature/jenkins-base'.\n",
"\u001b[01;34m.\u001b[00m\n",
"├── \u001b[01;34mcode\u001b[00m\n",
"│ ├── mylib.py\n",
"│ └── \u001b[01;32mtest.py\u001b[00m\n",
"├── Jenkinsfile\n",
"└── README\n",
"\n",
"1 directory, 4 files\n"
]
}
],
"source": [
"git checkout feature/jenkins-base\n",
"tree"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"#!/usr/bin/env python3\n",
"\n",
"class MyLib():\n",
"\n",
" def __init__(self):\n",
" pass\n",
"\n",
" def MyFunc(self):\n",
" return 'test'\n",
"\n",
"if __name__ == '__main__':\n",
" pass\n"
]
}
],
"source": [
"cat code/mylib.py"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"#!/usr/bin/env python3\n",
"import unittest, pytest\n",
"import mylib\n",
"\n",
"class Test(unittest.TestCase):\n",
"\n",
" def test_return(self):\n",
" m = mylib.MyLib()\n",
" self.assertTrue(m.MyFunc() == 'test')\n",
"\n",
"if __name__ == '__main__':\n",
" pytest.main(['./test.py'])\n"
]
}
],
"source": [
"cat code/test.py"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"pipeline {\n",
"\n",
" agent {\n",
" docker {\n",
" image 'python:3.7'\n",
" }\n",
" }\n",
"\n",
" environment {\n",
" HOME = \"$WORKSPACE\"\n",
" }\n",
"\n",
" stages {\n",
" stage('install dependencies') {\n",
" steps {\n",
" sh 'pip3 install --user pytest'\n",
" }\n",
" }\n",
" stage('run tests') {\n",
" steps {\n",
" sh '$HOME/.local/bin/pytest code/test.py'\n",
" }\n",
" }\n",
" }\n",
"\n",
"}\n"
]
}
],
"source": [
"cat Jenkinsfile"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"![](images/jenkins-base.png)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Example\n",
"## Jenkins dockerfile"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Switched to branch 'feature/jenkins-dockerfile'\n",
"Your branch is up to date with 'origin/feature/jenkins-dockerfile'.\n",
"\u001b[01;34m.\u001b[00m\n",
"├── \u001b[01;34mcode\u001b[00m\n",
"│ ├── mylib.py\n",
"│ └── \u001b[01;32mtest.py\u001b[00m\n",
"├── Dockerfile\n",
"├── Jenkinsfile\n",
"└── README\n",
"\n",
"1 directory, 5 files\n"
]
}
],
"source": [
"git checkout feature/jenkins-dockerfile\n",
"tree"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"pipeline {\n",
"\n",
" agent {\n",
" dockerfile true \n",
" }\n",
"\n",
" stages {\n",
" stage('run tests') {\n",
" steps {\n",
" sh 'pytest code/test.py'\n",
" }\n",
" }\n",
" }\n",
"\n",
"}\n"
]
}
],
"source": [
"cat Jenkinsfile"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"FROM python:3.7\n",
"RUN pip3 install --no-cache-dir pytest\n"
]
}
],
"source": [
"cat Dockerfile"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Example\n",
"### Jenkins junit"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Branch 'feature/jenkins-junit' set up to track remote branch 'feature/jenkins-junit' from 'origin'.\n",
"Switched to a new branch 'feature/jenkins-junit'\n",
"\u001b[01;34m.\u001b[00m\n",
"├── \u001b[01;34mcode\u001b[00m\n",
"│ ├── mylib.py\n",
"│ └── \u001b[01;32mtest.py\u001b[00m\n",
"├── Dockerfile\n",
"├── Jenkinsfile\n",
"└── README\n",
"\n",
"1 directory, 5 files\n"
]
}
],
"source": [
"git checkout feature/jenkins-junit\n",
"tree"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"pipeline {\n",
"\n",
" agent {\n",
" dockerfile true \n",
" }\n",
"\n",
" stages {\n",
" stage('run tests') {\n",
" steps {\n",
" sh 'pytest --junitxml results.xml code/test.py'\n",
" }\n",
" }\n",
" }\n",
"\n",
" post {\n",
" always {\n",
" junit 'results.xml'\n",
" }\n",
" }\n",
"\n",
"}\n"
]
}
],
"source": [
"cat Jenkinsfile"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"![](images/jenkins-junit.png)"
]
},
{
"cell_type": "markdown",
- "metadata": {},
+ "metadata": {
+ "slideshow": {
+ "slide_type": "subslide"
+ }
+ },
"source": [
"![](images/jenkins-junit2.png)"
]
}
],
"metadata": {
"celltoolbar": "Slideshow",
"kernelspec": {
"display_name": "Bash",
"language": "bash",
"name": "bash"
},
"language_info": {
"codemirror_mode": "shell",
"file_extension": ".sh",
"mimetype": "text/x-sh",
"name": "bash"
},
"livereveal": {
"height": 768,
"theme": "serif",
"transition": "none",
"width": 1024
}
},
"nbformat": 4,
"nbformat_minor": 2
}