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 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 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 diff --git a/github workflow/presentation/presentation_github_workflow.tex b/github workflow/presentation/presentation_github_workflow.tex new file mode 100644 index 0000000..1aff0cc --- /dev/null +++ b/github workflow/presentation/presentation_github_workflow.tex @@ -0,0 +1,120 @@ +\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}{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 +\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} + 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 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