diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..3b356fb --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,49 @@ +version: 2 + +jobs: + test: + machine: + docker_layer_caching: true + working_directory: ~/codeclimate/codeclimate-rubymotion + steps: + - checkout + - run: make image + - run: make test + + release_images: + machine: + docker_layer_caching: true + working_directory: ~/codeclimate/codeclimate-rubymotion + steps: + - checkout + - run: + name: Validate owner + command: | + if [ "$CIRCLE_PROJECT_USERNAME" -ne "codeclimate" ] + then + echo "Skipping release for non-codeclimate branches" + circleci step halt + fi + - run: make image + - run: echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin + - run: + name: Push image to Dockerhub + command: | + make release RELEASE_TAG="b$CIRCLE_BUILD_NUM" + make release RELEASE_TAG="$(echo $CIRCLE_BRANCH | grep -oP 'channel/\K[\w\-]+')" + +workflows: + version: 2 + build_deploy: + jobs: + - test + - release_images: + context: Quality + requires: + - test + filters: + branches: + only: /master|channel\/[\w-]+/ +notify: + webhooks: + - url: https://cc-slack-proxy.herokuapp.com/circle diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..746885b --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ +.PHONY: image test release + +IMAGE_NAME ?= codeclimate/codeclimate-rubymotion +RELEASE_REGISTRY ?= codeclimate + +ifndef RELEASE_TAG +override RELEASE_TAG = latest +endif + +image: + docker build --rm -t $(IMAGE_NAME) . + +test: image + docker run --rm $(IMAGE_NAME) sh -c "cd /usr/src/app && bundle install --with=test && bundle exec rake" + +release: + docker tag $(IMAGE_NAME) $(RELEASE_REGISTRY)/codeclimate-rubymotion:$(RELEASE_TAG) + docker push $(RELEASE_REGISTRY)/codeclimate-rubymotion:$(RELEASE_TAG) diff --git a/circle.yml b/circle.yml deleted file mode 100644 index 48262a7..0000000 --- a/circle.yml +++ /dev/null @@ -1,24 +0,0 @@ -machine: - services: - - docker - environment: - CLOUDSDK_CORE_DISABLE_PROMPTS: 1 - image_name: codeclimate-rubymotion - -dependencies: - pre: - - 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 - -test: - override: - - bundle exec rake - - docker build -t=$registry_root/$image_name:b$CIRCLE_BUILD_NUM . - -deployment: - registry: - branch: master - commands: - - docker push $registry_root/$image_name:b$CIRCLE_BUILD_NUM