From bdde25a9e444f05de11912d6e31fa80ae3bccfb2 Mon Sep 17 00:00:00 2001 From: Futago-za Ryuu Date: Tue, 1 Jan 2019 12:26:41 +0000 Subject: [PATCH] Set up CI with Azure Pipelines (#596) * Add support for Azure Pipelines * Remove Travis CI support * coverage: Generate cobertura and lcov reports only * Add support for Code Climate --- .gitignore | 1 + .nowignore | 8 +++-- .nycrc | 4 +-- .travis.yml | 23 ------------ README.md | 4 ++- azure-pipelines.yml | 76 ++++++++++++++++++++++++++++++++++++++++ package.json | 6 ++-- packages/pegjs/README.md | 4 ++- test/config.json | 6 ++++ test/mocha.opts | 2 ++ yarn.lock | 47 +++++++++++++++++++++++-- 11 files changed, 148 insertions(+), 33 deletions(-) delete mode 100644 .travis.yml create mode 100644 azure-pipelines.yml create mode 100644 test/config.json create mode 100644 test/mocha.opts diff --git a/.gitignore b/.gitignore index 5978a60..0e9dcc7 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ node_modules /website/js/*-bundle.js /*.log /sh.exe.stackdump +/test/junit-results.xml diff --git a/.nowignore b/.nowignore index 5a3ac54..ba58a53 100644 --- a/.nowignore +++ b/.nowignore @@ -1,5 +1,9 @@ +.github .idea .nyc_output -node_modules -dist coverage +dist +node_modules +.eslint* +.nycrc +azure-pipelines.yml diff --git a/.nycrc b/.nycrc index 1199be7..638e7f8 100644 --- a/.nycrc +++ b/.nycrc @@ -1,7 +1,7 @@ { "include": [ "packages/**" ], "reporter": [ - "text", - "text-summary" + "cobertura", + "lcov" ] } diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 23ad594..0000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -sudo: false - -language: node_js - -node_js: - - "6" - - "8" - - "10" - -before_install: - - curl -o- -L https://yarnpkg.com/install.sh | bash - - export PATH="$HOME/.yarn/bin:$PATH" - -install: - - yarn install --ignore-engines - -after_success: - - yarn coverage - -cache: - yarn: true - directories: - - node_modules diff --git a/README.md b/README.md index ee76092..4d76363 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ -[![ci](https://img.shields.io/travis/pegjs/pegjs.svg)](https://travis-ci.org/pegjs/pegjs) +[![Build Status](https://dev.azure.com/pegjs/pegjs/_apis/build/status/Azure%20Pipelines?branchName=master)](https://dev.azure.com/pegjs/pegjs/_build/latest?definitionId=1?branchName=master) +[![Test Coverage](https://api.codeclimate.com/v1/badges/2d1f0313dea3e28e191f/test_coverage)](https://codeclimate.com/github/pegjs/pegjs/test_coverage) [![coverage](https://img.shields.io/coveralls/github/pegjs/pegjs.svg)](https://coveralls.io/github/pegjs/pegjs) +[![Maintainability](https://api.codeclimate.com/v1/badges/2d1f0313dea3e28e191f/maintainability)](https://codeclimate.com/github/pegjs/pegjs/maintainability) [![forum](https://gitq.com/badge.svg)](https://gitq.com/pegjs/pegjs) [![license](https://img.shields.io/badge/license-mit-blue.svg)](https://opensource.org/licenses/MIT) diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..c28bce4 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,76 @@ +name: $(BuildID) + +trigger: + batch: true + paths: + exclude: + - CHANGELOG.md + - LICENSE + - README.md + +pool: + vmImage: 'ubuntu-16.04' + +variables: +- group: 'env-variables' + +strategy: + maxParallel: 3 + matrix: + Node 6: + node_version: 6.x + Node 8: + node_version: 8.x + Node 10: + node_version: 10.x + +steps: +- task: NodeTool@0 + inputs: + versionSpec: $(node_version) + displayName: 'Install Node.js' + +- script: | + yarn install --ignore-engines + curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter + chmod +x ./cc-test-reporter + displayName: 'Install dependencies' + +- script: | + ./cc-test-reporter before-build + yarn ci 2> /dev/null + if [ $? -eq 0 ] + then + echo '"yarn ci" passed, publishing to code climate.' + ./cc-test-reporter after-build --exit-code 0 + exit 0 + else + echo '"yarn ci" failed, publishing to code climate.' + ./cc-test-reporter after-build --exit-code 1 + exit 1 + fi + displayName: 'Lint source code, Run unit tests & Publish to Code Climate' + env: + CC_TEST_REPORTER_ID: $(CC_TEST_REPORTER_ID) + GIT_BRANCH: $(Build.SourceBranch) + GIT_COMMIT_SHA: $(Build.SourceVersion) + +- script: yarn coverage + displayName: 'Publish code coverage results (coveralls.io)' + env: + COVERALLS_SERVICE_NAME: $(COVERALLS_SERVICE_NAME) + COVERALLS_REPO_TOKEN: $(COVERALLS_REPO_TOKEN) + +- task: PublishTestResults@2 + displayName: 'Publish test results (Azure Pipelines)' + condition: succeededOrFailed() + inputs: + testRunner: JUnit + testResultsFiles: 'test/junit-results.xml' + +- task: PublishCodeCoverageResults@1 + displayName: 'Publish code coverage results (Azure Pipelines)' + inputs: + codeCoverageTool: Cobertura + summaryFileLocation: '$(System.DefaultWorkingDirectory)/coverage/cobertura-coverage.xml' + reportDirectory: '$(System.DefaultWorkingDirectory)/coverage/lcov-report' diff --git a/package.json b/package.json index 8e64fc1..289393b 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ ], "scripts": { "lint": "eslint --ext .js,.vue . docs/.vuepress", - "spec": "mocha --recursive", + "test": "nyc mocha --recursive", "benchmark": "node tools/benchmark/node", "build-docs": "vuepress build docs", "watch-docs": "vuepress dev docs", @@ -19,7 +19,7 @@ "impact": "node tools/impact master", "start": "node website/server.js", "now-build": "npm run build-docs", - "test": "npm run lint && nyc mocha --recursive", + "ci": "npm run lint && npm run test", "coverage": "nyc report --reporter=text-lcov | coveralls" }, "devDependencies": { @@ -29,6 +29,8 @@ "eslint-config-futagozaryuu": "5", "eslint-plugin-vue": "5", "mocha": "5.2.0", + "mocha-junit-reporter": "1.18.0", + "mocha-multi-reporters": "1.1.7", "vuepress": "next", "nyc": "13.1.0" }, diff --git a/packages/pegjs/README.md b/packages/pegjs/README.md index 75f632d..56bebb2 100644 --- a/packages/pegjs/README.md +++ b/packages/pegjs/README.md @@ -1,5 +1,7 @@ -[![ci](https://img.shields.io/travis/pegjs/pegjs.svg)](https://travis-ci.org/pegjs/pegjs) +[![Build Status](https://dev.azure.com/pegjs/pegjs/_apis/build/status/Azure%20Pipelines?branchName=master)](https://dev.azure.com/pegjs/pegjs/_build/latest?definitionId=1?branchName=master) +[![Test Coverage](https://api.codeclimate.com/v1/badges/2d1f0313dea3e28e191f/test_coverage)](https://codeclimate.com/github/pegjs/pegjs/test_coverage) [![coverage](https://img.shields.io/coveralls/github/pegjs/pegjs.svg)](https://coveralls.io/github/pegjs/pegjs) +[![Maintainability](https://api.codeclimate.com/v1/badges/2d1f0313dea3e28e191f/maintainability)](https://codeclimate.com/github/pegjs/pegjs/maintainability) [![license](https://img.shields.io/badge/license-mit-blue.svg)](https://opensource.org/licenses/MIT) PEG.js is a simple parser generator for JavaScript that produces fast parsers with excellent error reporting. You can use it to process complex data or computer languages and build transformers, interpreters, compilers and other tools easily. diff --git a/test/config.json b/test/config.json new file mode 100644 index 0000000..45f0e76 --- /dev/null +++ b/test/config.json @@ -0,0 +1,6 @@ +{ + "reporterEnabled": "spec, mocha-junit-reporter", + "mochaJunitReporterReporterOptions": { + "mochaFile": "test/junit-results.xml" + } +} diff --git a/test/mocha.opts b/test/mocha.opts new file mode 100644 index 0000000..b7c8d4e --- /dev/null +++ b/test/mocha.opts @@ -0,0 +1,2 @@ +--reporter mocha-multi-reporters +--reporter-options configFile=test/config.json diff --git a/yarn.lock b/yarn.lock index fdb780d..e764c72 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2103,6 +2103,11 @@ chardet@^0.7.0: resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e" integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA== +charenc@~0.0.1: + version "0.0.2" + resolved "https://registry.yarnpkg.com/charenc/-/charenc-0.0.2.tgz#c0a1d2f3a7092e03774bfa83f14c0fc5790a8667" + integrity sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc= + check-error@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" @@ -2576,6 +2581,11 @@ cross-spawn@^6.0.5: shebang-command "^1.2.0" which "^1.2.9" +crypt@~0.0.1: + version "0.0.2" + resolved "https://registry.yarnpkg.com/crypt/-/crypt-0.0.2.tgz#88d7ff7ec0dfb86f713dc87bbb42d044d3e6c41b" + integrity sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs= + crypto-browserify@^3.11.0: version "3.12.0" resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec" @@ -4459,7 +4469,7 @@ is-binary-path@^1.0.0: dependencies: binary-extensions "^1.0.0" -is-buffer@^1.1.5: +is-buffer@^1.1.5, is-buffer@~1.1.1: version "1.1.6" resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w== @@ -5247,7 +5257,7 @@ lodash.uniq@^4.5.0: resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M= -lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.17.5: +lodash@^4.16.4, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.17.5: version "4.17.11" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg== @@ -5451,6 +5461,15 @@ md5.js@^1.3.4: inherits "^2.0.1" safe-buffer "^5.1.2" +md5@^2.1.0: + version "2.2.1" + resolved "https://registry.yarnpkg.com/md5/-/md5-2.2.1.tgz#53ab38d5fe3c8891ba465329ea23fac0540126f9" + integrity sha1-U6s41f48iJG6RlMp6iP6wFQBJvk= + dependencies: + charenc "~0.0.1" + crypt "~0.0.1" + is-buffer "~1.1.1" + mdurl@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/mdurl/-/mdurl-1.0.1.tgz#fe85b2ec75a59037f2adfec100fd6c601761152e" @@ -5723,6 +5742,25 @@ mkdirp@0.5.1, mkdirp@0.5.x, mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@ dependencies: minimist "0.0.8" +mocha-junit-reporter@1.18.0: + version "1.18.0" + resolved "https://registry.yarnpkg.com/mocha-junit-reporter/-/mocha-junit-reporter-1.18.0.tgz#9209a3fba30025ae3ae5e6bfe7f9c5bc3c2e8ee2" + integrity sha512-y3XuqKa2+HRYtg0wYyhW/XsLm2Ps+pqf9HaTAt7+MVUAKFJaNAHOrNseTZo9KCxjfIbxUWwckP5qCDDPUmjSWA== + dependencies: + debug "^2.2.0" + md5 "^2.1.0" + mkdirp "~0.5.1" + strip-ansi "^4.0.0" + xml "^1.0.0" + +mocha-multi-reporters@1.1.7: + version "1.1.7" + resolved "https://registry.yarnpkg.com/mocha-multi-reporters/-/mocha-multi-reporters-1.1.7.tgz#cc7f3f4d32f478520941d852abb64d9988587d82" + integrity sha1-zH8/TTL0eFIJQdhSq7ZNmYhYfYI= + dependencies: + debug "^3.1.0" + lodash "^4.16.4" + mocha@5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/mocha/-/mocha-5.2.0.tgz#6d8ae508f59167f940f2b5b3c4a612ae50c90ae6" @@ -8947,6 +8985,11 @@ xdg-basedir@^3.0.0: resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-3.0.0.tgz#496b2cc109eca8dbacfe2dc72b603c17c5870ad4" integrity sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ= +xml@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5" + integrity sha1-eLpyAgApxbyHuKgaPPzXS0ovweU= + xtend@^4.0.0, xtend@~4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af"