diff --git a/Runner.php b/Runner.php index e41b091..7113332 100644 --- a/Runner.php +++ b/Runner.php @@ -20,24 +20,47 @@ public function __construct($config, $server) public function queueDirectory($dir, $prefix = '') { + if(isset($this->config['include_paths'])) { + $this->queueWithIncludePaths(); + } else { + $this->queuePaths($dir, $prefix, $this->config['exclude_paths']); + } + + $this->server->process_work(false); + } + + public function queueWithIncludePaths() { + foreach ($this->config['include_paths'] as $f) { + if ($f !== '.' and $f !== '..') { + + if (is_dir("/code$f")) { + $this->queuePaths("/code$f", "$f/"); + continue; + } + + $this->server->addwork(array("/code/$f")); + } + } + } + + public function queuePaths($dir, $prefix = '', $exclusions = []) { $dir = rtrim($dir, '\\/'); foreach (scandir($dir) as $f) { - if (in_array("$prefix$f", $this->config["exclude_paths"])) { + if (in_array("$prefix$f", $exclusions)) { continue; } if ($f !== '.' and $f !== '..') { if (is_dir("$dir/$f")) { - $this->queueDirectory("$dir/$f", "$prefix$f/"); + $this->queuePaths("$dir/$f", "$prefix$f/", $exclusions); continue; } + $prefix = ltrim($prefix, "\\/"); $this->server->addwork(array("/code/$prefix$f")); } } - - $this->server->process_work(false); } public function run($files) diff --git a/circle.yml b/circle.yml index f6356ce..480c1f8 100644 --- a/circle.yml +++ b/circle.yml @@ -3,20 +3,23 @@ machine: - docker environment: CLOUDSDK_CORE_DISABLE_PROMPTS: 1 - -dependencies: - override: - - echo $gcloud_json_key_base64 | sed 's/ //g' | base64 -d > /tmp/gcloud_key.json - - curl https://sdk.cloud.google.com | bash - - gcloud auth activate-service-account --key-file /tmp/gcloud_key.json - - gcloud docker -a + PRIVATE_REGISTRY: us.gcr.io/code_climate test: override: - - docker build -t=$registry_root/$CIRCLE_PROJECT_REPONAME:b$CIRCLE_BUILD_NUM . + - docker build -t=$PRIVATE_REGISTRY/$CIRCLE_PROJECT_REPONAME:b$CIRCLE_BUILD_NUM . deployment: registry: branch: master + owner: codeclimate commands: - - docker push $registry_root/$CIRCLE_PROJECT_REPONAME:b$CIRCLE_BUILD_NUM + - echo $GCLOUD_JSON_KEY_BASE64 | sed 's/ //g' | base64 -d > /tmp/gcloud_key.json + - curl https://sdk.cloud.google.com | bash + - gcloud auth activate-service-account $gcloud_account_email --key-file /tmp/gcloud_key.json + - gcloud docker -a + - docker push $PRIVATE_REGISTRY/$CIRCLE_PROJECT_REPONAME:b$CIRCLE_BUILD_NUM + +notify: + webhooks: + - url: https://cc-slack-proxy.herokuapp.com/circle