-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In this example we will be doing a bisect
- Loading branch information
1 parent
4fa93d1
commit 24d8100
Showing
6 changed files
with
122 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3.9, 3.8, 3.7, 3.6, 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye, 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster | ||
ARG VARIANT=3-bullseye | ||
FROM mcr.microsoft.com/vscode/devcontainers/python:${VARIANT} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,43 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: | ||
// https://github.com/microsoft/vscode-dev-containers/tree/v0.238.1/containers/python-3 | ||
{ | ||
"image": "mcr.microsoft.com/devcontainers/base:ubuntu", | ||
"postCreateCommand": "bash scripts/install.sh" | ||
} | ||
|
||
"name": "Python 3", | ||
"build": { | ||
"dockerfile": "Dockerfile", | ||
"context": "..", | ||
"args": { | ||
// Update 'VARIANT' to pick a Python version: 3, 3.10, 3.9, 3.8, 3.7, 3.6 | ||
// Append -bullseye or -buster to pin to an OS version. | ||
// Use -bullseye variants on local on arm64/Apple Silicon. | ||
"VARIANT": "3.10-bullseye", | ||
// Options | ||
"NODE_VERSION": "none" | ||
} | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
// Set *default* container specific settings.json values on container create. | ||
"settings": { | ||
"python.defaultInterpreterPath": "/usr/local/bin/python", | ||
"python.linting.enabled": true, | ||
"python.linting.pylintEnabled": true, | ||
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8", | ||
"python.formatting.blackPath": "/usr/local/py-utils/bin/black", | ||
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf", | ||
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit", | ||
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8", | ||
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy", | ||
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle", | ||
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle", | ||
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint" | ||
}, | ||
// Add the IDs of extensions you want installed when the container is created. | ||
"extensions": [ | ||
"ms-python.python", | ||
"ms-python.vscode-pylance" | ||
] | ||
} | ||
}, | ||
"postCreateCommand": "bash scripts/install.sh", // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. | ||
"remoteUser": "vscode" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/bash | ||
|
||
pushd examples | ||
git init example_7 | ||
cp ../template/add.py example_7/add.py | ||
cp ../template/check_function.sh example_7/check_function.sh | ||
|
||
pushd example_7 | ||
|
||
# Initial commit | ||
git add add.py | ||
commit_msg="Add bisect exercise | ||
In this example we will be doing a bisect, there will | ||
be a very long history, where you will not be able to | ||
tell from the commit message where a bug has been | ||
introduced, however at one point the python function has | ||
changed from returning a + b -> a * b, your task is to | ||
use bisect to figure out in which commit that happened | ||
You have a helper script, check_function.sh which you | ||
can use to determine if the commit is good or bad." | ||
|
||
git commit -m "$commit_msg" | ||
|
||
last_var="<random>" | ||
random_commits=$(( $RANDOM % 2000 + 500 )) | ||
# Add random text | ||
for ((i=1;i<=$random_commits;i++)) | ||
do | ||
var=$RANDOM | ||
sed -i "s/$last_var/$var/" add.py | ||
git add add.py | ||
git commit -m "$var" | ||
last_var=$var | ||
done | ||
|
||
sed -i "s/[+]/*/" add.py | ||
git add add.py | ||
|
||
commit_msg="$RANDOM | ||
Congratulations, you found me" | ||
|
||
git commit -m "$commit_msg" | ||
|
||
|
||
random_commits=$(( $RANDOM % 2000 + 500 )) | ||
for ((i=1;i<=$random_commits;i++)) | ||
do | ||
var=$RANDOM | ||
sed -i "s/$last_var/$var/" add.py | ||
git add add.py | ||
git commit -m "$var" | ||
last_var=$var | ||
done | ||
|
||
popd | ||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env python | ||
|
||
import sys | ||
|
||
|
||
def add(a, b): | ||
return a + b # <random> | ||
|
||
|
||
if __name__ == "__main__": | ||
result = add(2, 3) | ||
if result == 5: | ||
sys.exit(0) | ||
sys.exit(f"Wrong result, should be 5, is {result}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
python add.py |