diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..281cabb --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,75 @@ +defaults: &defaults + working_directory: /angular-bro-app + docker: + - image: adambullmer/circleci-node:6.10.3 + +version: 2 +jobs: + build: + <<: *defaults + steps: + - checkout + - run: + name: npm-config + command: 'npm config set progress=false' + - restore_cache: + key: dependency-cache-{{ checksum "package.json" }} + - run: + name: install-npm + command: npm install + - save_cache: + key: dependency-cache-{{ checksum "package.json" }} + paths: + - node_modules + - persist_to_workspace: + root: . + paths: + - node_modules + + test: + <<: *defaults + steps: + - checkout + - attach_workspace: + at: /angular-bro-app + - run: + name: unit-tests + command: npm run test -- --reporter mocha-junit-reporter --reporter-options mochaFile=$(pwd)/junit/test-results.xml + - run: + name: collect-coverage + command: npm run coverage -- --report-dir coverage/ + # - run: + # name: report-coveralls-coverage + # command: npm run coveralls + - store_test_results: + path: /angular-bro-app/junit + - store_artifacts: + path: coverage + prefix: coverage + + deploy: + <<: *defaults + steps: + - checkout + - run: + name: prep-node-credentials + command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc + - run: + name: publish-npm + command: npm publish + +workflows: + version: 2 + build_and_test: + jobs: + - build + - test: + requires: + - build + - deploy: + requires: + - build + - test + filters: + branches: + only: master diff --git a/.circleci/images/primary/Dockerfile b/.circleci/images/primary/Dockerfile new file mode 100644 index 0000000..ee96da6 --- /dev/null +++ b/.circleci/images/primary/Dockerfile @@ -0,0 +1,13 @@ +FROM alpine:3.6 +MAINTAINER Adam Bullmer + +RUN apk update && \ + apk add --no-cache \ + git \ + tar \ + gzip \ + ca-certificates \ + nodejs \ + nodejs-npm \ + && \ + rm -rf /var/cache/apk/* diff --git a/.gitignore b/.gitignore index 3c3629e..1e59e82 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ node_modules +.nyc_output +coverage diff --git a/circle.yml b/circle.yml deleted file mode 100644 index 24c9789..0000000 --- a/circle.yml +++ /dev/null @@ -1,18 +0,0 @@ -machine: - node: - version: 6.1.0 - -dependencies: - override: - - npm install - -test: - override: - - npm test - -deployment: - npm: - branch: master - commands: - - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc - - npm publish diff --git a/package.json b/package.json index bb05781..c617daf 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,11 @@ "description": "Angular broccoli plugin and compilation routine", "main": "lib/angular-app.js", "scripts": { - "test": "eslint lib/*.js" + "test": "nyc mocha 'test/**/*.test.js'", + "posttest": "npm run coverage", + "lint": "eslint .", + "coverage": "nyc report --reporter=html", + "coveralls": "nyc report --reporter=text-lcov | coveralls" }, "repository": { "type": "git", @@ -59,7 +63,11 @@ "lodash": "^4.6.1" }, "devDependencies": { - "eslint": "^3.18.0" + "coveralls": "^2.13.1", + "mocha": "^3.2.0", + "mocha-eslint": "^4.0.0", + "mocha-junit-reporter": "^1.13.0", + "nyc": "^11.0.3" }, "peerDependencies": { "phantomjs-prebuilt": "^2.1.6" diff --git a/test/.eslintrc b/test/.eslintrc new file mode 100644 index 0000000..2adb0a5 --- /dev/null +++ b/test/.eslintrc @@ -0,0 +1,15 @@ +{ + "env": { + "es6": true, + "node": true, + "mocha": true + }, + "extends": "../.eslintrc", + "rules": { + "prefer-arrow-callback": "off", + "global-require": "off", + "no-invalid-this": "off", + "no-empty-function": "off", + "max-lines": "off" + } +} diff --git a/test/lint.test.js b/test/lint.test.js new file mode 100644 index 0000000..08d0dab --- /dev/null +++ b/test/lint.test.js @@ -0,0 +1,12 @@ +/** + * Run ESLint as Mocha Tests + */ +const LINTER_SLOW = 1000, + lint = require('mocha-eslint'), + paths = [ + 'lib/**/*.js', + 'test/**/*.test.js', + ], + options = { slow: LINTER_SLOW }; + +lint(paths, options);