Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding circleci configuration #10

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
jobs:
build:
working_directory: ~/node-logtify-logstash
docker:
- image: circleci/node:8.9
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
steps:
- checkout
- run:
name: Install make
command: sudo apt-get update && sudo apt-get -y install gcc make

# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ .Branch }}-{{ checksum "package.json" }}
- v1-dependencies-{{ .Branch }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies
- run:
name: Install dependencies
command: make deps
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ .Branch }}-{{ checksum "package.json" }}
- run:
name: Test project
command: make test

# Special step used to persist a temporary file to be used by another job in the workflow
- persist_to_workspace:
root: ~/node-logtify-logstash
paths:
- coverage

sonarqube:
working_directory: ~/node-logtify-logstash
docker:
# Sonarqube need OpenJDK 8 to run his analysis correctly
- image: circleci/openjdk:8-jdk
steps:
- checkout
# Special step used to attach the workflow’s workspace to the current container
# Retrieve coverage's folder for sonarqube
- attach_workspace:
at: ~/node-logtify-logstash

# Sonarqube need to have node installed to run his analysis
- run:
name: Install node
command: |
sudo apt install curl
curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -
sudo apt install nodejs
- run:
name: Sonar analysis
command: make sonar

workflows:
version: 2
build_and_test:
jobs:
- build
- sonarqube:
# sonarqube's job waiting for build's job before to run
requires:
- build
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ sonar:
echo sonar.projectVersion=`cat package.json | python -c "import json,sys;obj=json.load(sys.stdin);print obj['version'];"` >> sonar-project.properties
wget https://s3.eu-central-1.amazonaws.com/dialonce-cdn/utilities/sonar-scanner-cli.zip
unzip sonar-scanner-*
ifdef CI_PULL_REQUEST
@sonar-scanner/bin/sonar-scanner -e -Dsonar.analysis.mode=preview -Dsonar.github.pullRequest=${shell basename $(CI_PULL_REQUEST)} -Dsonar.github.repository=$(REPO_SLUG) -Dsonar.github.oauth=$(GITHUB_TOKEN) -Dsonar.login=$(SONAR_LOGIN) -Dsonar.password=$(SONAR_PASS) -Dsonar.host.url=$(SONAR_HOST_URL)
ifdef CIRCLE_PULL_REQUEST
@sonar-scanner/bin/sonar-scanner -e -Dsonar.analysis.mode=preview -Dsonar.github.pullRequest=${shell basename $(CIRCLE_PULL_REQUEST)} -Dsonar.github.repository=$(REPO_SLUG) -Dsonar.github.oauth=$(GITHUB_TOKEN) -Dsonar.login=$(SONAR_LOGIN) -Dsonar.password=$(SONAR_PASS) -Dsonar.host.url=$(SONAR_HOST_URL)
endif
ifeq ($(CIRCLE_BRANCH),develop)
@sonar-scanner/bin/sonar-scanner -e -Dsonar.analysis.mode=publish -Dsonar.host.url=$(SONAR_HOST_URL) -Dsonar.login=$(SONAR_LOGIN) -Dsonar.password=$(SONAR_PASS)
endif
rm -rf sonar-scanner
rm -rf sonar-scanner*