@@ -202,3 +202,58 @@ same syntax to update the Pipfile and viceversa.
202202
203203At the moment this has to be done manually so please make sure to update both
204204files accordingly.
205+
206+ # Uncommon tasks
207+
208+ ## Compare generated Dockerfiles between repo2docker versions
209+
210+ For larger refactorings it can be useful to check that the generated Dockerfiles match
211+ between an older version of r2d and the current version. The following shell script
212+ automates this test.
213+
214+ ``` bash
215+ #! /bin/bash -e
216+
217+ current_version=$( jupyter-repo2docker --version | sed s@+@-@)
218+ echo " Comparing $( pwd) (local $current_version vs. $R2D_COMPARE_TO )"
219+ basename=" dockerfilediff"
220+
221+ diff_r2d_dockerfiles_with_version () {
222+ docker run --rm -t -v " $( pwd) " :" $( pwd) " --user 1000 jupyter/repo2docker:" $1 " jupyter-repo2docker --no-build --debug " $( pwd) " & > " $basename " ." $1 "
223+ jupyter-repo2docker --no-build --debug " $( pwd) " & > " $basename " ." $current_version "
224+
225+ # remove first line logging the path
226+ sed -i ' /^\[Repo2Docker\]/d' " $basename " ." $1 "
227+ sed -i ' /^\[Repo2Docker\]/d' " $basename " ." $current_version "
228+
229+ diff --strip-trailing-cr " $basename " ." $1 " " $basename " ." $current_version " | colordiff
230+ rm " $basename " ." $current_version " " $basename " ." $1 "
231+ }
232+
233+ startdir=" $( pwd) "
234+ cd " $1 "
235+
236+ # diff_r2d_dockerfiles 0.10.0-22.g4f428c3.dirty
237+ diff_r2d_dockerfiles_with_version " $R2D_COMPARE_TO "
238+
239+ cd " $startdir "
240+ ```
241+
242+ Put the code above in a file ` tests/dockerfile_diff.sh ` and make it executable: ` chmod +x dockerfile_diff.sh ` .
243+
244+ Configure the repo2docker version you want to compare with your local version in the environment variable ` R2D_COMPARE_TO ` .
245+ The scripts takes one input: the directory where repo2docker should be executed.
246+
247+ ``` bash
248+ cd tests/
249+ R2D_COMPARE_TO=0.10.0 ./dockerfile_diff.sh venv/py35/
250+ ```
251+
252+ Run it for all directories where there is a ` verify ` file:
253+
254+ ``` bash
255+ cd tests/
256+ R2D_COMPARE_TO=0.10.0 CMD=$( pwd) /dockerfile_diff.sh find . -name ' verify' -execdir bash -c ' $CMD $(pwd)' \;
257+ ```
258+
259+ To keep the created Dockefilers for further inspection, comment out the deletion line in the script.
0 commit comments