DeveloperPlayBook
Python
Python
  • Introduction
  • Architecture
    • Technology Stack
    • ADR Records
  • Design
  • Bootstraping
  • Development Environment
    • Accounts (AWS, GCP, CircleCI)
  • Services/API
    • Serverless
    • Containers
    • Python
    • Firebase
    • Chatbots
    • Testing
  • Frontend
    • Serverless
    • Containers
    • Chatbot
  • Plattform
  • IAM - IAMaaS
  • Persistance - DBaaS
    • Serverless
    • Container
  • Event Driven / Streaming aaS
    • Kinesis
  • AI - AIaaS
  • Production / Reliability Engineering
  • create-k8s-secrets
  • VI
  • Tools
Powered by GitBook
On this page
  • Serverless Development Environment for Python, Javascript/React and Node Developers (on OSX):
  • Setup a template for git to prevent checking in credentials
  • Setup visual studio code
  • Create project and initialise repositories
  • Documentation
  • Git Knowledge
  • Development Pipeline:

Development Environment

PreviousBootstrapingNextAccounts (AWS, GCP, CircleCI)

Last updated 7 years ago

Serverless Development Environment for Python, Javascript/React and Node Developers (on OSX):

Install Prerequesits Package Manger Homebrew and CLI Tools:

xcode-select --install
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install Runtime for Javascript and Python:

brew install node python3

Install Python and Javascript packages / Dependencies:

pip3 install virtualenv
npm install -g serverless create-react-app

Source:

Additional tools to improve the developer experience:

brew cask install google-chrome
brew cask install visual-studio-code
brew cask install iterm2
brew cask install postman
brew install git
git config --global credential.helper osxkeychain
brew install git-secrets

Setup a template for git to prevent checking in credentials

  1. Make a directory for the template:

    mkdir ~/.git-template
  2. Install the hooks in the template directory:

    git secrets --install ~/.git-template
  3. Tell git to use it:

    git config --global init.templateDir '~/.git-template'
  4. Install AWS patterns globally to be prevented to be checked in to git:

    git secrets --register-aws --global
  5. Check the list of secrets git secrets will scan for:

    git secrets --list

It should return something like:

ecrets.providers git secrets --aws-provider
secrets.patterns [A-Z0-9]{20}
secrets.patterns ("|')?(AWS|aws|Aws)?_?(SECRET|secret|Secret)?_?(ACCESS|access|Access)?_?(KEY|key|Key)("|')?\s*(:|=>|=)\s*("|')?[A-Za-z0-9/\+=]{40}("|')?
secrets.patterns ("|')?(AWS|aws|Aws)?_?(ACCOUNT|account|Account)_?(ID|id|Id)?("|')?\s*(:|=>|=)\s*("|')?[0-9]{4}\-?[0-9]{4}\-?[0-9]{4}("|')?
secrets.allowed AKIAIOSFODNN7EXAMPLE
secrets.allowed wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

Now every time you run git init or git clone, your hooks will be copied into the .git directory of your freshly created repo. If you don’t want to set the template globally, you can use it as needed with git init --template ’~/.git-template’.

That covers new repo creation, and cloning, but we haven’t addressed the problem of existing repos that weren’t created with the template. Here we have a couple options:

git init is a non-destructive operation, so feel free to run it in existing repos. It’s safe, and will retroactively apply the template you specify.

OR

Setup visual studio code

List all my installed extensions:

code --list-extensions
HookyQR.beautify
PeterJausovec.vscode-docker
dbaeumer.vscode-eslint
dzannotti.vscode-babel-coloring
formulahendry.auto-close-tag
jebbs.plantuml
magicstack.MagicPython
ms-python.python
msjsdiag.debugger-for-chrome
taichi.react-beautify
tht13.python
tushortz.python-extended-snippets
vscodevim.vim
yzhang.markdown-all-in-one

Create project and initialise repositories

mkdir apis-api
cd apis-api
git init
git remote add origin https://github.com/denseidel/apis-api.git
npm init
git add .
git commit -am "add package.json and ignore local python files"
git push --set-upstream origin master

Documentation

Use Gitbooks:

Install gitbook CLI:

npm install -g gitbook-cli

Initialize:

gitbook init

Generate output to custom folder

gitbook build . docs

Git Knowledge

  • Merge multiple commits:

  • Modify the last two commits:

git rebase -i HEAD~2

Or if they are the last two:

git reset --soft "HEAD^"
git commit --amend
git push -f
# stash current state
git stash save "Worked on get identities/{identityId}"
# apply current stage (e.g. in other branch) but keep stash
git stash add
# apply current state and delete stash
git stash pop

Development Pipeline:

  • Use CircleCI as a SaaS as Pipeline:

  1. Setup a project as described (e.g. add the folder .circleciwith the config.yml file)

Link to config.yml file

  • for containers

  • for serverless

If you want to go “all in” and ensure that every repo has the proper hooks, here’s a that will recursively walk a directory, such as ~/Projects and run git secrets --install in all repos.

Code:

Use branches and if needed

Use git stash to switch change between branches -

Go to

Add the git repo to it:

http://sourabhbajaj.com/mac-setup/Python/virtualenv.html
Source
script
https://github.com/denseidel/apis-api/commit/ecc27aaf1f7a714938d99f1b5d656a67376c934b
Git Styleguide
Create new branches
squash all commits related to a single issue into one commit
https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History
https://robots.thoughtbot.com/autosquashing-git-commits
https://www.ralfebert.de/git/rebase/
https://stackoverflow.com/a/24690646/1929968
https://www.youtube.com/watch?v=KLEDKgMmbBI
https://circleci.com/dashboard