Skip to content

Commit

Permalink
CircleCI Setup 🤖
Browse files Browse the repository at this point in the history
  • Loading branch information
shetty-tejas committed Oct 24, 2022
1 parent 96856d0 commit 1abfcc8
Show file tree
Hide file tree
Showing 4 changed files with 295 additions and 2 deletions.
116 changes: 116 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
version: 2.1

orbs:
discord: antonioned/[email protected]
node: circleci/[email protected]

commands:
setup:
description: 'Set of common setup steps.'
steps:
- checkout
- node/install-packages

get_env:
description: 'Getting the environment variables loaded into the shell when needed.'
steps:
- attach_workspace:
at: '.'
- run: cat .env >> $BASH_ENV

failure_handler:
steps:
- discord/status:
fail_only: true
failure_message: ':skull_crossbones: Bruh! The CI workflow for the branch **$CIRCLE_BRANCH** failed. Get the branch fixed before deployment!'

success_handler:
steps:
- get_env
- discord/status:
success_only: true
success_message: ':rocket: Hurray! The CI workflow for the branch **$CIRCLE_BRANCH** is a success! Version ${BUILD_VERSION} is up!'

defaults: &defaults
docker:
- image: cimg/node:18.1.0

jobs:
build:
<<: *defaults
steps:
- setup

set_env:
<<: *defaults
steps:
- checkout
- run: mkdir -p tmp
- run: echo "export BUILD_VERSION=$(npm pkg get version | tr -d '\"')" >> tmp/.env
- persist_to_workspace:
root: tmp
paths:
- .env

lint:
<<: *defaults
steps:
- setup
- run: npm run lint

test:
<<: *defaults
steps:
- setup
- run: npm run test
- store_test_results:
path: reports/mocha
- store_artifacts:
path: coverage

publish:
<<: *defaults
steps:
- run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> .npmrc
- run: npm publish

workflows:
master-workflow:
when:
equal: [<< pipeline.git.branch >>, 'master']
jobs:
- build:
post-steps:
- failure_handler
- set_env:
post-steps:
- failure_handler
requires:
- build
- lint:
post-steps:
- failure_handler
requires:
- set_env
- test:
post-steps:
- failure_handler
requires:
- lint
- publish:
post-steps:
- failure_handler
- success_handler
requires:
- test
pr-workflow:
unless:
equal: [<< pipeline.git.branch >>, 'master']
jobs:
- build
- lint:
requires:
- build
- test:
requires:
- build
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.nyc_output
.npmrc
coverage
node_modules
node_modules
reports
Loading

0 comments on commit 1abfcc8

Please sign in to comment.