diff --git a/.circleci/build_and_push.sh b/.circleci/build_and_push.sh index e86fbb7..c864977 100755 --- a/.circleci/build_and_push.sh +++ b/.circleci/build_and_push.sh @@ -2,7 +2,7 @@ set -e aws ecr get-login --region $AWS_REGION --no-include-email | bash echo "Building docker image..." -cp pkg/fluent-plugin-kubernetes-metrics-*.gem docker +cp /tmp/pkg/fluent-plugin-kubernetes-metrics-*.gem docker echo "Copy latest fluent-plugin-splunk-hec gem from S3" aws s3 cp s3://k8s-ci-artifacts/fluent-plugin-splunk-hec-${FLUENT_SPLUNK_HEC_GEM_VERSION}.gem ./docker docker build --no-cache -t splunk/fluent-plugin-kubernetes-metrics:metrics ./docker diff --git a/.circleci/config.yml b/.circleci/config.yml index 950c810..748b886 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,9 +3,7 @@ jobs: build: docker: - image: circleci/ruby:2.6.1-node-browsers - working_directory: ~/repo - steps: - checkout - setup_remote_docker: @@ -13,26 +11,66 @@ jobs: - run: name: Install dependencies command: | - gem install bundler -v 2.0.1 - bundle update --bundler - bundle install - + .circleci/install_dep.sh - run: name: Builder command: | rake build -t -v + cp -R pkg /tmp + - persist_to_workspace: + root: /tmp + paths: + - pkg + test: + docker: + - image: circleci/ruby:2.6.1-node-browsers + working_directory: ~/repo + steps: + - attach_workspace: + at: /tmp + - checkout + - setup_remote_docker: + reusable: true + - run: + name: Install dependencies + command: | + .circleci/install_dep.sh - run: name: Run unit tests command: | rake test -t -v + push: + docker: + - image: circleci/ruby:2.6.1-node-browsers + working_directory: ~/repo + steps: + - attach_workspace: + at: /tmp + - checkout + - setup_remote_docker: + reusable: true - run: name: Push rubygem to s3 command: | .circleci/push_gem.sh - - run: name: Build and push docker image to ecr command: | - .circleci/build_and_push.sh \ No newline at end of file + .circleci/build_and_push.sh + +workflows: + version: 2 + build_test_push: + jobs: + - build + - test: + requires: + - build + - push: + requires: + - test + filters: + branches: + only: develop diff --git a/.circleci/install_dep.sh b/.circleci/install_dep.sh new file mode 100755 index 0000000..7c4d131 --- /dev/null +++ b/.circleci/install_dep.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -e +gem install bundler +bundle update --bundler +bundle install \ No newline at end of file diff --git a/.circleci/push_gem.sh b/.circleci/push_gem.sh index d995882..62743c4 100755 --- a/.circleci/push_gem.sh +++ b/.circleci/push_gem.sh @@ -4,4 +4,4 @@ sudo apt-get install -y python-pip libpython-dev > /dev/null 2>&1 echo "Installing aws cli..." sudo pip install awscli > /dev/null 2>&1 echo "Pushing metrics gem to s3..." -aws s3 cp pkg/*.gem s3://k8s-ci-artifacts/ \ No newline at end of file +aws s3 cp /tmp/pkg/*.gem s3://k8s-ci-artifacts/ \ No newline at end of file