diff --git a/.circleci/auto_bps b/.circleci/auto_bps new file mode 100755 index 0000000..23123fb --- /dev/null +++ b/.circleci/auto_bps @@ -0,0 +1,27 @@ +#!/bin/bash + +output=$(eval git show -U0 | ./diff-lines2) +echo "$output" + +if [[ -z "$output" ]]; then + echo "No diff in this version, Not applying any breakpoints" + exit 0 +fi + +repoUrl=$(git remote get-url origin) + +echo "$output" | while IFS= read -r line; do + filename=$(echo "$line" | awk -F' ' '{print $1}') + lineno=$(echo "$line" | awk -F' ' '{print $2}') + + curl --location 'https://staging.rookout.com/api/v2/breakpoints/create' \ + --header 'X-Api-Key: '"$ROOKOUT_API_KEY" \ + --header 'Content-Type: application/json' \ + --data-raw '{ + "userEmail": "nathan@rookout.com", + "filepath": "'"$filename"'", + "lineNumber": '"$lineno"', + "repositoryURL": "'"$repoUrl"'", + "repositoryRevision": "master" + }' +done \ No newline at end of file diff --git a/.circleci/config.yml b/.circleci/config.yml index 834b9f8..4a9ed1f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -54,7 +54,7 @@ references: run: command: | apt-get update - apt-get install wget git -y + apt-get install wget git curl -y wget https://github.com/mikefarah/yq/releases/download/v4.27.5/yq_linux_amd64 -O /usr/bin/yq &&\ chmod +x /usr/bin/yq @@ -105,17 +105,13 @@ jobs: - *setup_workspace - *load_version - *install_deps + - run: cd .circleci && chmod +x auto_bps && ./auto_bps && cd .. - run: git config --global user.email "sonario@rookout.com" && git config --global user.name "sonariorobot" - run: git clone -b staging git@github.com:Rookout/gitops-demo.git - - run: PUBLISH_VERSION=$(echo $NEW_VERSION | sed 's/inner-999/1/g') yq -i -v '.tutorialPython.image.tag = strenv(PUBLISH_VERSION)' gitops-demo/argocd/apps/values.yaml + - run: PUBLISH_VERSION=$(echo $NEW_VERSION | sed 's/inner-999/1/g') yq -i -v '.tutorialPythonNathan.image.tag = strenv(PUBLISH_VERSION)' gitops-demo/argocd/apps/values.yaml - run: cd gitops-demo && git add argocd/apps/values.yaml - - run: cd gitops-demo && git commit -m "update tutorial-python $NEW_VERSION" + - run: cd gitops-demo && git commit -m "update tutorial-python-nathan $NEW_VERSION" - run: cd gitops-demo && git push https://sonariorobot:$GITHUB_TOKEN@github.com/Rookout/gitops-demo.git staging - - run: cd gitops-demo && git checkout production && git pull - - run: PUBLISH_VERSION=$(echo $NEW_VERSION | sed 's/inner-999/1/g') yq -i -v '.tutorialPython.image.tag = strenv(PUBLISH_VERSION)' gitops-demo/argocd/apps/values.yaml - - run: cd gitops-demo && git add argocd/apps/values.yaml - - run: cd gitops-demo && git commit -m "update tutorial-python $NEW_VERSION" - - run: cd gitops-demo && git push https://sonariorobot:$GITHUB_TOKEN@github.com/Rookout/gitops-demo.git production test_demo_servers_up: docker: @@ -151,11 +147,9 @@ workflows: - build_and_push_demo_image: requires: - checkout_code_upver - <<: *filter_master - deploy_demo_argo: requires: - build_and_push_demo_image - <<: *filter_master - test_demo_servers_up: requires: - deploy_demo_argo diff --git a/.circleci/diff-lines b/.circleci/diff-lines new file mode 100755 index 0000000..9c7dccc --- /dev/null +++ b/.circleci/diff-lines @@ -0,0 +1,24 @@ +#! /bin/bash + +diff-lines() { + local path= + local line= + while read; do + esc=$'\033' + if [[ $REPLY =~ ---\ (a/)?.* ]]; then + continue + elif [[ $REPLY =~ \+\+\+\ (b/)?([^[:blank:]$esc]+).* ]]; then + path=${BASH_REMATCH[2]} + elif [[ $REPLY =~ @@\ -[0-9]+(,[0-9]+)?\ \+([0-9]+)(,[0-9]+)?\ @@.* ]]; then + line=${BASH_REMATCH[2]} + elif [[ $REPLY =~ ^($esc\[[0-9;]*m)*([\ +-]) ]]; then + echo "$path:$line:$REPLY" + if [[ ${BASH_REMATCH[2]} != - ]]; then + ((line++)) + fi + fi + done +} + + +diff-lines \ No newline at end of file diff --git a/.circleci/diff-lines2 b/.circleci/diff-lines2 new file mode 100755 index 0000000..78e6a2a --- /dev/null +++ b/.circleci/diff-lines2 @@ -0,0 +1,29 @@ +#! /bin/bash + + +diff-lines() { + local path= + local line= + local content= + while read; do + esc=$'\033' + if [[ $REPLY =~ ---\ (a/)?.* ]]; then + continue + elif [[ $REPLY =~ \+\+\+\ (b/)?([^[:blank:]$esc]+).* ]]; then + path=${BASH_REMATCH[2]} + elif [[ $REPLY =~ @@\ -[0-9]+(,[0-9]+)?\ \+([0-9]+)(,[0-9]+)?\ @@.* ]]; then + line=${BASH_REMATCH[2]} + elif [[ $REPLY =~ ^($esc\[[0-9;]*m)*([\ +])(.*) ]]; then + content=${BASH_REMATCH[3]} +# echo $content + if [[ -n $content && $content != *"import"* && $content != *"def "* ]]; then + echo "$path:$line:$REPLY" + fi + if [[ ${BASH_REMATCH[2]} != - ]]; then + ((line++)) + fi + fi + done +} + +diff-lines | awk -F: 'match($1,/py/){ print $1 " " $2 }' | uniq \ No newline at end of file diff --git a/.circleci/rookctl b/.circleci/rookctl new file mode 100755 index 0000000..3183dd8 Binary files /dev/null and b/.circleci/rookctl differ diff --git a/app.py b/app.py index 8116eb9..c081cce 100644 --- a/app.py +++ b/app.py @@ -3,8 +3,6 @@ import string import random import json -from datetime import datetime -from random import randint from todos_store import Store import sentry_sdk from sentry_sdk.integrations.flask import FlaskIntegration @@ -90,7 +88,6 @@ def update_todo(): # add a new todo action - @app.route('/todos', methods=['POST']) def add_todo(): todos = Store.getInstance().todos @@ -100,7 +97,7 @@ def add_todo(): if not todoStr: return '', 400 todo = { - "title": cleanStr(req['title']), + "title": cleanStr(req['title'] + "bla"), "id": unsafeRandId(10), "completed": False } @@ -121,7 +118,7 @@ def duplicate_todo(todoId): todos = Store.getInstance().todos for todo in todos: if todoId == todo['id']: - dup = {'title': todo['completed'], + dup = {'title': todo['completed'] + "dup", 'id': unsafeRandId(10), 'completed': todo['title']} todos.append(dup) diff --git a/static/index.html b/static/index.html index c300598..ee2f58c 100644 --- a/static/index.html +++ b/static/index.html @@ -14,7 +14,7 @@

todos

- +