<commit_before>box: koding/base@0.0.20
no-response-timeout: 10
services:
  - userminddeployer/postgresql9.3@0.0.7-usermind-9.3-1
  - wercker/rabbitmq@1.0.1
  - wercker/redis@0.0.8
  - wercker/mongodb@1.0.1

build:
  steps:
    - add-ssh-key:
        keyname: DEPLOYMENT_KEY
    - script:
        name: setup git identity
        code: |
          git config --global user.email '<EMAIL>'
          git config --global user.name 'Koding Bot'
    - script:
        name: fetch pull requests
        code: |
          git config --add remote.origin.fetch '+refs/pull/*/head:refs/remotes/origin/pull/*'
          git fetch --force --quiet origin
    - script:
        name: build started
        code: |
          scripts/notify-cebeci.sh "build" "<$WERCKER_BUILD_URL|build> of $WERCKER_GIT_BRANCH is in progress" "building" 10
    - script:
        name: check package.json files
        code: |
          scripts/check_package_json_constraints.sh
    - script:
        name: setup nvm
        code: |
          source $HOME/.nvm/nvm.sh
          nvm use 0.10.33
    - script:
        name: koding node modules
        code: |
          scripts/wercker/install-node-modules koding
          npm install
    - script:
        name: notify cebeci
        code: |
          scripts/notify-cebeci.sh "build" "<$WERCKER_BUILD_URL|build> of $WERCKER_GIT_BRANCH - build preparation finished" "building" 30
    - script:
        name: change mod of test instace private key
        code: |
          chmod 600 ./scripts/test-instance/koding-test-instances-2015-06.pem
    - mktemp:
        envvar: INSTANCE_IP
    - script:
        name: create data files
        code: touch INSTANCE_DATA CLIENT_TEST
    - script:
        name: launch test instance
        code: |
          INSTANCE_OPTIONS=$(scripts/test-instance/get-options)
          scripts/test-instance/launch $INSTANCE_OPTIONS > INSTANCE_DATA
          cat INSTANCE_DATA
    - script:
        name: copy prod creds
        code: ./scripts/copy-prod-creds.sh
    - script:
        name: check configs
        code: |
          ./configure --config sandbox
          ./configure --config prod
    - script:
        name: configure build
        code: ./configure --config $CONFIG --projectRoot $WERCKER_SOURCE_DIR --ebEnvName $EB_ENV_NAME
    - script:
        name: delete prod creds unless prod
        code: ./scripts/delete-prod-creds-unless-prod.sh
    - script:
        name: client node modules
        code: scripts/install-npm.sh -d client -u
    - script:
        name: build client
        code: |
          make -C client dist
          scripts/notify-cebeci.sh "build" "<$WERCKER_BUILD_URL|build> of $WERCKER_GIT_BRANCH - build client finished" "building" 35
    - script:
        name: build go binaries
        code: go/build.sh
    - script:
        name: build social api
        cwd: go/src/socialapi
        code: |
          make configure
          make install
          make build
    - script:
        name: build backend finished
        code: |
          scripts/notify-cebeci.sh "build" "<$WERCKER_BUILD_URL|build> of $WERCKER_GIT_BRANCH - build backend finished" "building" 40
    - script:
        name: run coffeelint
        code: |
          ./scripts/lint-coffeescript.sh
    - script:
        name: check social api code quality
        code: |
          ./scripts/check_socialapi_code_quality.sh
    - script:
        name: testing backend started
        code: |
          scripts/notify-cebeci.sh "build" "<$WERCKER_BUILD_URL|build> of $WERCKER_GIT_BRANCH - test backend started" "building" 41
    - script:
        name: create postgresql tables
        cwd: go
        code: |
          mkdir -p src/socialapi/db/sql/kontrol
          cp src/github.com/koding/kite/kontrol/*.sql src/socialapi/db/sql/kontrol/
          src/socialapi/db/sql/definition/create-wercker.sh src/socialapi/db/sql
          bin/migrate -url "postgres://$WERCKER_POSTGRESQL_HOST:$WERCKER_POSTGRESQL_PORT/$WERCKER_POSTGRESQL_DATABASE?user=$WERCKER_POSTGRESQL_USERNAME&password=$WERCKER_POSTGRESQL_PASSWORD" -path "src/socialapi/db/sql/migrations" up
    - script:
        name: prepare test data
        code: |
          go run ./go/src/socialapi/workers/cmd/migrator/main.go -c ./go/src/socialapi/config/test.toml
    - script:
        name: test social api
        code: |
          sudo -E scripts/wercker/init-socialapi.sh
          tail -n 100 /var/log/koding/social-api.log
          tail -n 100 /var/log/koding/social-populartopic.log
          tail -n 100 /var/log/koding/social-pinnedpost.log
          tail -n 100 /var/log/koding/social-webhook.log
          tail -n 100 /var/log/koding/social-webhookmiddleware.log
          cd go/src/socialapi
          EXTRAS="-story=true" make testapi config=./config/test.toml
    - script:
        name: test janitor
        code: ./run janitortests
    - script:
        name: test gatheringestor
        code: ./run gatheringestortests
    - script:
        name: test koding mongo models
        code: ./run gomodeltests
    - script:
        name: test vmwatcher
        code: ./run vmwatchertests
    - script:
        name: testing backend finished
        code: |
          scripts/notify-cebeci.sh "build" "<$WERCKER_BUILD_URL|build> of $WERCKER_GIT_BRANCH - test backend finished" "building" 45
    - script:
        name: check connectivity
        code: scripts/wercker/check-connectivity $(pwd)/INSTANCE_DATA
    - script:
        name: test nodejs
        code: |
          echo "testing nodejs (social worker, nodejs web server)"
          scripts/node-testing/run-tests $(pwd)/INSTANCE_DATA
    - script:
        name: testing client started
        code: |
          echo started > CLIENT_TEST
          scripts/notify-cebeci.sh "build" "<$WERCKER_BUILD_URL|build> of $WERCKER_GIT_BRANCH - test client started" "building" 46
    - script:
        name: run test suites
        code: scripts/wercker/run-tests $(pwd)/INSTANCE_DATA
    - script:
        name: testing client finished
        code: |
          scripts/notify-cebeci.sh "build" "<$WERCKER_BUILD_URL|build> of $WERCKER_GIT_BRANCH - test client finished" "building" 85
  after-steps:
    - script:
        name: test suite timeline breakdown
        code: |
          cat TEST_SUITE_TIMELINE || :
    - script:
        name: setup nvm
        code: |

          source $HOME/.nvm/nvm.sh
          nvm use 0.10.33
    - script:
        name: upload logs
        code: scripts/wercker/upload-logs INSTANCE_DATA
    - script:
        name: cleanup
        code: |
          export CLIENT_TEST=$(cat CLIENT_TEST)
          scripts/wercker/after-step-cleanup INSTANCE_DATA
          rm -f INSTANCE_DATA CLIENT_TEST
    - jessefulton/slack-notify:
        subdomain: koding
        token: $SLACK_TOKEN
        channel: announce
        username: wercker
        icon_url: https://avatars3.githubusercontent.com/u/1695193?s=140
    - script:
        name: build finished
        code: |
          scripts/notify-cebeci.sh "build" "<$WERCKER_BUILD_URL|build> of $WERCKER_GIT_BRANCH is $WERCKER_RESULT " $WERCKER_RESULT 100
    - script:
        name: cat socialapi
        code: |
          tail -n 1000 /var/log/koding/social-api.log || :
          tail -n 100 /var/log/koding/social-populartopic.log || :
          tail -n 100 /var/log/koding/social-pinnedpost.log || :
          tail -n 100 /var/log/koding/social-webhook.log || :
          tail -n 100 /var/log/koding/social-webhookmiddleware.log || :
deploy:
  steps:
    - add-ssh-key:
        keyname: DEPLOYMENT_KEY
    - script:
        name: deploy started
        code: |
          $WERCKER_ROOT/scripts/notify-cebeci.sh "deploy" "<$WERCKER_DEPLOY_URL|deploy> of $WERCKER_GIT_BRANCH started" "deploying" 5
    - create-file:
        name: write version file
        filename: $WERCKER_ROOT/VERSION
        content: ${WERCKER_GIT_COMMIT:0:8}
        overwrite: true
    - script:
        name: setup nvm
        code: |
          source $HOME/.nvm/nvm.sh
          nvm use 0.10.33
    - script:
        name: copy prod creds
        code: ./scripts/copy-prod-creds.sh
    - script:
        name: zip
        code: |
          cd $WERCKER_ROOT

          ./configure --config $CONFIG --projectRoot /opt/koding --ebEnvName $EB_ENV_NAME

          rm -rf .git .build node_modules client/node_modules client/builder/node_modules client/landing/node_modules client/.sprites
          rm -rf go/bin go/pkg
          zip -q --symlinks -r $ARCHIVE .

          $WERCKER_ROOT/scripts/notify-cebeci.sh "deploy" "created deploy file $ARCHIVE" "deploying" 45
    - script:
        name: delete prod creds unless prod
        code: ./scripts/delete-prod-creds-unless-prod.sh


    - koding/eb-deploy@0.0.8:
        access-key: $S3_KEY_ID
        secret-key: $S3_KEY_SECRET
        app-name: koding
        env-name: $EB_ENV_NAME
        version-label: $ARCHIVE
        region: $EB_ENV_REGION
        s3-bucket: $S3_EB_DEPLOY-$EB_ENV_REGION
        s3-key: $ARCHIVE
    - script:
        name: notify-cebeci with eb trigger
        code: |
          $WERCKER_ROOT/scripts/notify-cebeci.sh "deploy" "triggered $EB_ENV_NAME EB" "deploying" 95

  after-steps:
    - jessefulton/slack-notify:
        subdomain: koding
        token: $SLACK_TOKEN
        channel: announce
        username: wercker
        icon_url: https://avatars3.githubusercontent.com/u/1695193?s=140
    - script:
        name: notify-cebeci with result
        code: |
          $WERCKER_ROOT/scripts/notify-cebeci.sh "deploy" "wercker is done with the <$WERCKER_DEPLOY_URL|deploy> of $WERCKER_GIT_BRANCH result: $WERCKER_RESULT" $WERCKER_RESULT 100
<commit_msg>wercker after-step: destroy user machines<commit_after>box: koding/base@0.0.20
no-response-timeout: 10
services:
  - userminddeployer/postgresql9.3@0.0.7-usermind-9.3-1
  - wercker/rabbitmq@1.0.1
  - wercker/redis@0.0.8
  - wercker/mongodb@1.0.1

build:
  steps:
    - add-ssh-key:
        keyname: DEPLOYMENT_KEY
    - script:
        name: setup git identity
        code: |
          git config --global user.email '<EMAIL>'
          git config --global user.name 'Koding Bot'
    - script:
        name: fetch pull requests
        code: |
          git config --add remote.origin.fetch '+refs/pull/*/head:refs/remotes/origin/pull/*'
          git fetch --force --quiet origin
    - script:
        name: build started
        code: |
          scripts/notify-cebeci.sh "build" "<$WERCKER_BUILD_URL|build> of $WERCKER_GIT_BRANCH is in progress" "building" 10
    - script:
        name: check package.json files
        code: |
          scripts/check_package_json_constraints.sh
    - script:
        name: setup nvm
        code: |
          source $HOME/.nvm/nvm.sh
          nvm use 0.10.33
    - script:
        name: koding node modules
        code: |
          scripts/wercker/install-node-modules koding
          npm install
    - script:
        name: notify cebeci
        code: |
          scripts/notify-cebeci.sh "build" "<$WERCKER_BUILD_URL|build> of $WERCKER_GIT_BRANCH - build preparation finished" "building" 30
    - script:
        name: change mod of test instace private key
        code: |
          chmod 600 ./scripts/test-instance/koding-test-instances-2015-06.pem
    - mktemp:
        envvar: INSTANCE_IP
    - script:
        name: create data files
        code: touch INSTANCE_DATA CLIENT_TEST
    - script:
        name: launch test instance
        code: |
          INSTANCE_OPTIONS=$(scripts/test-instance/get-options)
          scripts/test-instance/launch $INSTANCE_OPTIONS > INSTANCE_DATA
          cat INSTANCE_DATA
    - script:
        name: copy prod creds
        code: ./scripts/copy-prod-creds.sh
    - script:
        name: check configs
        code: |
          ./configure --config sandbox
          ./configure --config prod
    - script:
        name: configure build
        code: ./configure --config $CONFIG --projectRoot $WERCKER_SOURCE_DIR --ebEnvName $EB_ENV_NAME
    - script:
        name: delete prod creds unless prod
        code: ./scripts/delete-prod-creds-unless-prod.sh
    - script:
        name: client node modules
        code: scripts/install-npm.sh -d client -u
    - script:
        name: build client
        code: |
          make -C client dist
          scripts/notify-cebeci.sh "build" "<$WERCKER_BUILD_URL|build> of $WERCKER_GIT_BRANCH - build client finished" "building" 35
    - script:
        name: build go binaries
        code: go/build.sh
    - script:
        name: build social api
        cwd: go/src/socialapi
        code: |
          make configure
          make install
          make build
    - script:
        name: build backend finished
        code: |
          scripts/notify-cebeci.sh "build" "<$WERCKER_BUILD_URL|build> of $WERCKER_GIT_BRANCH - build backend finished" "building" 40
    - script:
        name: run coffeelint
        code: |
          ./scripts/lint-coffeescript.sh
    - script:
        name: check social api code quality
        code: |
          ./scripts/check_socialapi_code_quality.sh
    - script:
        name: testing backend started
        code: |
          scripts/notify-cebeci.sh "build" "<$WERCKER_BUILD_URL|build> of $WERCKER_GIT_BRANCH - test backend started" "building" 41
    - script:
        name: create postgresql tables
        cwd: go
        code: |
          mkdir -p src/socialapi/db/sql/kontrol
          cp src/github.com/koding/kite/kontrol/*.sql src/socialapi/db/sql/kontrol/
          src/socialapi/db/sql/definition/create-wercker.sh src/socialapi/db/sql
          bin/migrate -url "postgres://$WERCKER_POSTGRESQL_HOST:$WERCKER_POSTGRESQL_PORT/$WERCKER_POSTGRESQL_DATABASE?user=$WERCKER_POSTGRESQL_USERNAME&password=$<PASSWORD>" -path "src/socialapi/db/sql/migrations" up
    - script:
        name: prepare test data
        code: |
          go run ./go/src/socialapi/workers/cmd/migrator/main.go -c ./go/src/socialapi/config/test.toml
    - script:
        name: test social api
        code: |
          sudo -E scripts/wercker/init-socialapi.sh
          tail -n 100 /var/log/koding/social-api.log
          tail -n 100 /var/log/koding/social-populartopic.log
          tail -n 100 /var/log/koding/social-pinnedpost.log
          tail -n 100 /var/log/koding/social-webhook.log
          tail -n 100 /var/log/koding/social-webhookmiddleware.log
          cd go/src/socialapi
          EXTRAS="-story=true" make testapi config=./config/test.toml
    - script:
        name: test janitor
        code: ./run janitortests
    - script:
        name: test gatheringestor
        code: ./run gatheringestortests
    - script:
        name: test koding mongo models
        code: ./run gomodeltests
    - script:
        name: test vmwatcher
        code: ./run vmwatchertests
    - script:
        name: testing backend finished
        code: |
          scripts/notify-cebeci.sh "build" "<$WERCKER_BUILD_URL|build> of $WERCKER_GIT_BRANCH - test backend finished" "building" 45
    - script:
        name: check connectivity
        code: scripts/wercker/check-connectivity $(pwd)/INSTANCE_DATA
    - script:
        name: test nodejs
        code: |
          echo "testing nodejs (social worker, nodejs web server)"
          scripts/node-testing/run-tests $(pwd)/INSTANCE_DATA
    - script:
        name: testing client started
        code: |
          echo started > CLIENT_TEST
          scripts/notify-cebeci.sh "build" "<$WERCKER_BUILD_URL|build> of $WERCKER_GIT_BRANCH - test client started" "building" 46
    - script:
        name: run test suites
        code: scripts/wercker/run-tests $(pwd)/INSTANCE_DATA
    - script:
        name: testing client finished
        code: |
          scripts/notify-cebeci.sh "build" "<$WERCKER_BUILD_URL|build> of $WERCKER_GIT_BRANCH - test client finished" "building" 85
  after-steps:
    - script:
        name: test suite timeline breakdown
        code: |
          cat TEST_SUITE_TIMELINE || :
    - script:
        name: setup nvm
        code: |

          source $HOME/.nvm/nvm.sh
          nvm use 0.10.33
    - script:
        name: upload logs
        code: scripts/wercker/upload-logs INSTANCE_DATA
    - script:
        name: cleanup
        code: |
          export CLIENT_TEST=$(cat CLIENT_TEST)
          scripts/wercker/destroy-user-machines INSTANCE_DATA
          scripts/wercker/after-step-cleanup INSTANCE_DATA
          rm -f INSTANCE_DATA CLIENT_TEST
    - jessefulton/slack-notify:
        subdomain: koding
        token: $SLACK_TOKEN
        channel: announce
        username: wercker
        icon_url: https://avatars3.githubusercontent.com/u/1695193?s=140
    - script:
        name: build finished
        code: |
          scripts/notify-cebeci.sh "build" "<$WERCKER_BUILD_URL|build> of $WERCKER_GIT_BRANCH is $WERCKER_RESULT " $WERCKER_RESULT 100
    - script:
        name: cat socialapi
        code: |
          tail -n 1000 /var/log/koding/social-api.log || :
          tail -n 100 /var/log/koding/social-populartopic.log || :
          tail -n 100 /var/log/koding/social-pinnedpost.log || :
          tail -n 100 /var/log/koding/social-webhook.log || :
          tail -n 100 /var/log/koding/social-webhookmiddleware.log || :
deploy:
  steps:
    - add-ssh-key:
        keyname: DEPLOYMENT_KEY
    - script:
        name: deploy started
        code: |
          $WERCKER_ROOT/scripts/notify-cebeci.sh "deploy" "<$WERCKER_DEPLOY_URL|deploy> of $WERCKER_GIT_BRANCH started" "deploying" 5
    - create-file:
        name: write version file
        filename: $WERCKER_ROOT/VERSION
        content: ${WERCKER_GIT_COMMIT:0:8}
        overwrite: true
    - script:
        name: setup nvm
        code: |
          source $HOME/.nvm/nvm.sh
          nvm use 0.10.33
    - script:
        name: copy prod creds
        code: ./scripts/copy-prod-creds.sh
    - script:
        name: zip
        code: |
          cd $WERCKER_ROOT

          ./configure --config $CONFIG --projectRoot /opt/koding --ebEnvName $EB_ENV_NAME

          rm -rf .git .build node_modules client/node_modules client/builder/node_modules client/landing/node_modules client/.sprites
          rm -rf go/bin go/pkg
          zip -q --symlinks -r $ARCHIVE .

          $WERCKER_ROOT/scripts/notify-cebeci.sh "deploy" "created deploy file $ARCHIVE" "deploying" 45
    - script:
        name: delete prod creds unless prod
        code: ./scripts/delete-prod-creds-unless-prod.sh


    - koding/eb-deploy@0.0.8:
        access-key: $S3_KEY_ID
        secret-key: $S3_KEY_SECRET
        app-name: koding
        env-name: $EB_ENV_NAME
        version-label: $ARCHIVE
        region: $EB_ENV_REGION
        s3-bucket: $S3_EB_DEPLOY-$EB_ENV_REGION
        s3-key: $ARCHIVE
    - script:
        name: notify-cebeci with eb trigger
        code: |
          $WERCKER_ROOT/scripts/notify-cebeci.sh "deploy" "triggered $EB_ENV_NAME EB" "deploying" 95

  after-steps:
    - jessefulton/slack-notify:
        subdomain: koding
        token: $SLACK_TOKEN
        channel: announce
        username: wercker
        icon_url: https://avatars3.githubusercontent.com/u/1695193?s=140
    - script:
        name: notify-cebeci with result
        code: |
          $WERCKER_ROOT/scripts/notify-cebeci.sh "deploy" "wercker is done with the <$WERCKER_DEPLOY_URL|deploy> of $WERCKER_GIT_BRANCH result: $WERCKER_RESULT" $WERCKER_RESULT 100

{'fraction_non_alphanumeric': 0.09995358192789726, 'fraction_numerical': 0.014131724173500438, 'mean_word_length': 2.0062015503875967, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 32, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7604972', 'n_tokens_mistral': 6510, 'n_tokens_neox': 6319, 'n_words': 1412}