Skip to content
asingularity edited this page Jan 5, 2017 · 80 revisions

cleverbuild

Welcome to the cleverbuild wiki!

cleverbuild is a public github project!!

cleverbuild is a set of helper scripts that (hopefully!) helps you build and deploy your projects!!

  1. encourage many small builds/deploys (vs few large builds/deploys) by..
  2. .. making it as painless and hassle-free as possible to do builds/deploys
  3. building and deploying should be fearless, painless and uneventful

Install

linux and mac:

pip install https://github.com/CleverPet/cleverbuild/archive/master.zip

u really do NOT wanna do "sudo pip install" here.. really.. u don't.. especially on macosx el capitan

Concept

  1. helper scripts to help you run your build and deploy scripts in clean/reproducible sandboxes
  2. a monotonically increasing cleverbuild number (CLEVERBUILD_NUMBER environment variable, increases on successful builds), persisted in the target git project as a git tag, e.g., "cleverbuild-5"
  3. a single per-project non-idempotent ".cleverbuild" script (optional) that, when run with /usr/local/bin/cleverbuild, results in a new git tag to help you build (and manage) your project
  4. multiple per-project idempotent ".cleverscript" scripts (optional) that, when run with /usr/local/bin/cleverscript, do "interesting things" to help you deploy (and manage) your projects
  5. .cleverbuild scripts act as documentation on how to build your projects
  6. .cleverscript scripts act as documentation on how to deploy your projects

Overview

there are two (2) main cleverbuild actions/concepts:

  1. cleverbuild (runs .cleverbuild script)
  2. cleverscript (runs .cleverscript scripts)

example use

cd cleverpet-cloud

cleverbuild

confirm success, there should be a new tag created

SECRETS_ZIP=~/Downloads/secrets.zip cleverscript .clever-script-deploy-staging

check developer console --> app engine --> versions, to confirm its deployed

/usr/local/bin/cleverbuild

  1. runs the project's .cleverbuild script in a isolated sandbox, with the next optimistic monotonically increasing cleverbuild number (or an explicit previous cleverbuild number), to try to build a new build and
  2. if success then tags git repo with the cleverbuild number
  3. provides CLEVERBUILD_BRANCH environment variable, e.g., "master"
  4. provides CLEVERBUILD_NUMBER environment variable, e.g., "5"

/usr/local/bin/cleverscript

  1. runs the project's .cleverbuild script in a isolated sandbox with the most recent cleverbuild number (or an explicit previous cleverbuild number)
  2. runs a project .cleverscript script in the same isolated sandbox
  3. provides CLEVERBUILD_BRANCH environment variable, e.g., "master"
  4. provides CLEVERBUILD_NUMBER environment variable, e.g., "5"

running cleverbuild creates a new git tag; running cleverscripts do not

there is only one (1) .cleverbuild script; there may be zero or more .cleverscripts (as many as u need to do whatever u need to do that makes sense for your project)

be conservative when running cleverbuild (because it creates new git tags); be liberal when running .cleverscript scripts (because they do not create new git tags)

Tips

cleverbuild scripts should be "fail fast", e.g., for bash scripts use

#!/bin/sh -e

-e means "fail fast"

better yet, use -ex, e.g.,

#!/bin/sh -ex

-x means print commands as they are run

Appendix

things I didn't like (never liked) about building software w/jenkins

  1. jenkins kept track of "failed" builds (and incremented build number on failed builds too).. this is understandable on jenkins part as jenkins is primarily a unit test runner and u do want to keep track of failed unit tests
  2. because jenkins kept track of build number then that meant that the jenkins install was "sacred", i.e., that it needed to be managed in case of disaster (e.g., backup/restore)

TODO

  1. branches, e.g., "cleverbuild hotfix1" TODO: scrub branch-name
  2. self hosted clevertools, i.e., clevertools uses clevertools
  3. automatically create rough draft release notes?
  4. if cleverbuild and no diff then run cleverscript? bad idea
  5. cleverbuild/script assumes "origin".. needs fixing? 5a. might use something like this: "git config --get branch.master.remote" -> github
  6. prune /tmp folders
  7. don't run "git fetch" ?!? cleverbuild runs git fetch (rationale: because it also pushes git tags.. i.e., it already modifies the local git dir so a fetch isn't anything new).. cleverscript does not run git fetch.. rationale: it doesn't modify the local git dir in anyway whatsoever.. its supposed to be idempotent
  8. cleverscript --cleverbuild_number zzz
  9. pass args to .cleverbuild and/or .cleverscripts
  10. http://stackoverflow.com/questions/33004708/osx-el-capitan-sudo-pip-install-oserror-errno-1-operation-not-permitted/33463702#33463702