From 3260974a8a8b0e3b6bddfd9325d6e25471a0eb80 Mon Sep 17 00:00:00 2001 From: "pierre-francois.duc" Date: Wed, 6 Apr 2022 10:45:02 +0200 Subject: [PATCH 1/7] Create readme file --- github workflow/README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 github workflow/README.md diff --git a/github workflow/README.md b/github workflow/README.md new file mode 100644 index 0000000..e92947e --- /dev/null +++ b/github workflow/README.md @@ -0,0 +1,13 @@ + + + +## Setup for the workshop + +1. create a branch `fake_main` to mimic a conflict without impacting `main` + +add cake and pie code +move pie to a different module + + +## Reference +https://docs.github.com/en/get-started/quickstart/github-flow \ No newline at end of file From a5365238b06b933d988db594745734316052fad8 Mon Sep 17 00:00:00 2001 From: "pierre-francois.duc" Date: Wed, 6 Apr 2022 10:46:16 +0200 Subject: [PATCH 2/7] Add draft of presentation --- .../presentation_github_workflow.tex | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 github workflow/presentation/presentation_github_workflow.tex diff --git a/github workflow/presentation/presentation_github_workflow.tex b/github workflow/presentation/presentation_github_workflow.tex new file mode 100644 index 0000000..4ce617d --- /dev/null +++ b/github workflow/presentation/presentation_github_workflow.tex @@ -0,0 +1,102 @@ +\documentclass{beamer} + +\input{template/2019-08-23-rli-beamer-template-stylev0-0.tex} +\setbeamertemplate{footline}[frame number] +\usepackage{amsmath} +\usepackage{tikz} +\usepackage{listings} + +% Overlays for TIKZ pictures +\tikzset{ + invisible/.style={opacity=0}, + visible on/.style={alt={#1{}{invisible}}}, + alt/.code args={<#1>#2#3}{% + \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path + }, +} + +\title[Yo]{\textbf{SimRunde Workshop} \\ Github workflow} +\author{Pierre-Francois Duc\\ +} +\institute{Reiner Lemoine Institut} +\date{\today} + +\begin{document} + +\begin{frame} + \titlepage +\end{frame} + +\begin{frame}{Why should you care?} + + \begin{enumerate} + \item Help make the changes in the code more transparent, important for open\_source + \item Help reviewing and reviewing help avoiding bugs + \item Issue and resolution can be linked + \end{enumerate} + +\end{frame} + +\begin{frame}{Agenda} + \begin{enumerate} + \item Branch out + \item Commiting changes + \item Push changes and create pull request (or merge request for gitlab) + \item Interacting on the pull request (from now on PR) + \item Preparing for code review + \item CI and checks, protecting branches + \item Merging the PR + \end{enumerate} + +\end{frame} + +\begin{frame}{Branch out} + +Main or develop (or dev) branch should not be used to push daily commits, one should work in a dedicated branch + + +{\tt git checkout main} + +{\tt git pull} + +{\tt git checkout -b feature/nameyoucomeupwith} + + +\end{frame} + +\begin{frame}{Commiting changes} + +Make changes locally and ``save'' them by commiting them, a commit can be parts of a file or several files or whole files. The idea is that a commit should be a conceptual change like ``Correct spelling mistakes'', or ``Improved paragraph 1 by elaborating on the benefit of berries on the diet''. Typically changes done reworking and entire book chapter for many hours should ideally not be packed into one commit. What is important is to still make the commits and push them to the remote to have backup of your work (and show your chefs you are making progress). + +{\tt git push} + +\end{frame} + +\begin{frame}{Create pull request} +Once you pushed your changes, github will automatically propose you to open a Pull Request, so you can click on the green button, don't worry you can edit most of its content later. You can even flag it as Draft Request to indicate that this is not ready yet for review. +\end{frame} + +\begin{frame}{Interacting on pull request} +\begin{itemize} + \item Comments (suggestions) + \item View changes + \item Commit view (come back on it after rework) + \item Linking with open Issues +\end{itemize} + +\end{frame} + + +\begin{frame}{CI and checks} +If we have time +\end{frame} + +\begin{frame}{Merging the PR} +After it has been reviewed and approved, the person making the changes should normally merge the PR and delete the branch. + +\end{frame} + + + +\end{document} + From 10c9b3fb81cdaf8f2b844352ae88f7037cc29831 Mon Sep 17 00:00:00 2001 From: "pierre-francois.duc" Date: Wed, 6 Apr 2022 10:46:40 +0200 Subject: [PATCH 3/7] Add slide for preparing code review --- .../presentation_github_workflow.tex | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/github workflow/presentation/presentation_github_workflow.tex b/github workflow/presentation/presentation_github_workflow.tex index 4ce617d..1aff0cc 100644 --- a/github workflow/presentation/presentation_github_workflow.tex +++ b/github workflow/presentation/presentation_github_workflow.tex @@ -86,6 +86,24 @@ \end{frame} +\begin{frame}{Preparing for code review} + +Reset commits but keep changes + +{\tt git checkout dev } +{\tt git pull } +{\tt git checkout feature/nameyoucomeupwith }(without the -b because it exists) +{\tt git rebase -i dev } +(solve potential conflicts) + +{\tt git reset --soft dev } + + +Make thoughful commits + +{\tt git push -f } (if you are alone on the branch it is ok, careful if more than one working on the branch) + +\end{frame} \begin{frame}{CI and checks} If we have time From e68a9900a329f6ce78b6c305600b57f9ad84114a Mon Sep 17 00:00:00 2001 From: "pierre-francois.duc" Date: Wed, 6 Apr 2022 10:47:43 +0200 Subject: [PATCH 4/7] Add __pycache__ files to gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d92c64f..9914716 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .ipynb_checkpoints/ -.idea/ \ No newline at end of file +.idea/ +**/__pycache__ \ No newline at end of file From 72a11d114d642082858954d93770f5aaf822f780 Mon Sep 17 00:00:00 2001 From: "pierre-francois.duc" Date: Wed, 6 Apr 2022 10:48:13 +0200 Subject: [PATCH 5/7] Add main dummy code --- github workflow/main.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 github workflow/main.py diff --git a/github workflow/main.py b/github workflow/main.py new file mode 100644 index 0000000..7f8a96a --- /dev/null +++ b/github workflow/main.py @@ -0,0 +1,7 @@ +from src.cakes import banana_cake +from src.sauces import vanilla_sauce + +my_banana_cake = banana_cake("flour", "banana", "sugar", "milk") +a_vanilla_sauce = vanilla_sauce("eggs", "milk", "vanilla", "sugar") + +print(a_vanilla_sauce) \ No newline at end of file From a35699bb62e270f79fad55152454b95d451a5133 Mon Sep 17 00:00:00 2001 From: "pierre-francois.duc" Date: Wed, 6 Apr 2022 10:48:41 +0200 Subject: [PATCH 6/7] Add recipes modules --- github workflow/src/__init__.py | 0 github workflow/src/cakes.py | 31 +++++++++++++++++++++++++++++++ github workflow/src/sauces.py | 4 ++++ 3 files changed, 35 insertions(+) create mode 100644 github workflow/src/__init__.py create mode 100644 github workflow/src/cakes.py create mode 100644 github workflow/src/sauces.py diff --git a/github workflow/src/__init__.py b/github workflow/src/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/github workflow/src/cakes.py b/github workflow/src/cakes.py new file mode 100644 index 0000000..54f4129 --- /dev/null +++ b/github workflow/src/cakes.py @@ -0,0 +1,31 @@ +from src.utils.cooking_techniques import mix, bake + +def banana_cake(*ingredients): + + dough = mix(*ingredients) + return bake(dough) + +def cheesecake(*ingredients): + dough = mix(*ingredients) + return bake(dough) + +def pekan_pie(*ingredients): + dough = mix(*ingredients) + return bake(dough) + + + + +def cake(*ingredients, cake_name=""): + dough = mix(*ingredients) + return f"{bake(dough)}for {cake_name}" + +def banana_cake(*ingredients): + + return cake(*ingredients, cake_name="banana cake") + +def cheesecake(*ingredients): + return cake(*ingredients, cake_name="cheesecake") + +def pekan_pie(*ingredients): + return cake(*ingredients, cake_name="pekan_pie") \ No newline at end of file diff --git a/github workflow/src/sauces.py b/github workflow/src/sauces.py new file mode 100644 index 0000000..3c607dc --- /dev/null +++ b/github workflow/src/sauces.py @@ -0,0 +1,4 @@ +from src.utils.cooking_techniques import stir + +def vanilla_sauce(*ingredients): + return stir(*ingredients) \ No newline at end of file From ce650faed14a797df07bdbdc1d571161a165f84e Mon Sep 17 00:00:00 2001 From: "pierre-francois.duc" Date: Wed, 6 Apr 2022 10:49:02 +0200 Subject: [PATCH 7/7] Add cooking techniques modules --- github workflow/src/utils/__init__.py | 0 github workflow/src/utils/cooking_techniques.py | 10 ++++++++++ 2 files changed, 10 insertions(+) create mode 100644 github workflow/src/utils/__init__.py create mode 100644 github workflow/src/utils/cooking_techniques.py diff --git a/github workflow/src/utils/__init__.py b/github workflow/src/utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/github workflow/src/utils/cooking_techniques.py b/github workflow/src/utils/cooking_techniques.py new file mode 100644 index 0000000..f4229d4 --- /dev/null +++ b/github workflow/src/utils/cooking_techniques.py @@ -0,0 +1,10 @@ +def mix(*ingredients): + return ",".join(ingredients) + + +def bake(dough): + return f"baked {dough}" + + +def stir(*ingredients): + return mix(*ingredients) \ No newline at end of file