Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.ipynb_checkpoints/
.idea/
.idea/
**/__pycache__
13 changes: 13 additions & 0 deletions github workflow/README.md
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions github workflow/main.py
Original file line number Diff line number Diff line change
@@ -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)
120 changes: 120 additions & 0 deletions github workflow/presentation/presentation_github_workflow.tex
Original file line number Diff line number Diff line change
@@ -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}

Empty file added github workflow/src/__init__.py
Empty file.
31 changes: 31 additions & 0 deletions github workflow/src/cakes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from src.utils.cooking_techniques import mix, bake

def banana_cake(*ingredients):

Comment thread
Bachibouzouk marked this conversation as resolved.
dough = mix(*ingredients)
return bake(dough)

def cheesecake(*ingredients):
dough = mix(*ingredients)
return bake(dough)

def pekan_pie(*ingredients):
Comment on lines +8 to +12
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More specific about many lines

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dsasfdsdsa

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")
4 changes: 4 additions & 0 deletions github workflow/src/sauces.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from src.utils.cooking_techniques import stir

def vanilla_sauce(*ingredients):
return stir(*ingredients)
Empty file.
10 changes: 10 additions & 0 deletions github workflow/src/utils/cooking_techniques.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
def mix(*ingredients):
return ",".join(ingredients)


def bake(dough):
return f"baked {dough}"


def stir(*ingredients):
return mix(*ingredients)