From 6f77d5fc9eb957788f5a3589c23c4ed16a89036a Mon Sep 17 00:00:00 2001 From: Evilebot Tnawi Date: Fri, 26 Apr 2019 15:29:24 +0300 Subject: [PATCH] feat: migrate on azure pipelines (#172) BREAKING CHANGE: now we use `azure-pipelines` for CI --- src/tasks/git.js | 3 +- src/tasks/package.js | 9 +- src/tasks/templates.js | 3 +- templates/.circleci/config.yml | 145 ------------------------ templates/README.md | 4 +- templates/appveyor.yml | 45 -------- templates/azure-pipelines.yml | 201 +++++++++++++++++++++++++++++++++ 7 files changed, 209 insertions(+), 201 deletions(-) delete mode 100644 templates/.circleci/config.yml delete mode 100644 templates/appveyor.yml create mode 100644 templates/azure-pipelines.yml diff --git a/src/tasks/git.js b/src/tasks/git.js index 9907ffa..f096327 100644 --- a/src/tasks/git.js +++ b/src/tasks/git.js @@ -26,8 +26,9 @@ const gitignore = [ const gitattributes = [ '* text=auto', - 'package-lock.json -diff', + 'bin/* eol=lf', 'yarn.lock -diff', + 'package-lock.json -diff', ]; module.exports = () => { diff --git a/src/tasks/package.js b/src/tasks/package.js index 831dc9c..b7ee35b 100644 --- a/src/tasks/package.js +++ b/src/tasks/package.js @@ -16,10 +16,12 @@ const devPackages = [ 'standard-version', '@commitlint/cli', '@commitlint/config-conventional', + 'commitlint-azure-pipelines-cli', 'husky', // Jest 'jest', + 'jest-junit', 'babel-jest', // Babel @@ -80,12 +82,7 @@ module.exports = (config) => { 'test:watch': 'jest --watch', 'test:coverage': "jest --collectCoverageFrom='src/**/*.js' --coverage", pretest: 'npm run lint', - test: 'npm run test:only', - 'ci:lint': 'npm run lint && npm run security', - 'ci:test': 'npm run test:only -- --runInBand', - 'ci:coverage': 'npm run test:coverage -- --runInBand', - 'ci:lint:commits': - 'commitlint --from=origin/master --to=${CIRCLE_SHA1}', + test: 'npm run test:coverage', defaults: 'webpack-defaults', }, files: existing.files || ['dist/', 'lib/', 'index.js'], diff --git a/src/tasks/templates.js b/src/tasks/templates.js index c13f691..b4b71b7 100644 --- a/src/tasks/templates.js +++ b/src/tasks/templates.js @@ -5,13 +5,12 @@ const { copyFiles } = require('mrm-core'); // These files will be overwritten without any confirmation const files = [ - '.circleci/config.yml', '.github/CODEOWNERS', '.github/PULL_REQUEST_TEMPLATE.md', '.github/CONTRIBUTING.md', '.editorconfig', '.eslintrc.js', - 'appveyor.yml', + 'azure-pipelines.yml', 'LICENSE', ]; diff --git a/templates/.circleci/config.yml b/templates/.circleci/config.yml deleted file mode 100644 index 2671e54..0000000 --- a/templates/.circleci/config.yml +++ /dev/null @@ -1,145 +0,0 @@ -unit_tests: &unit_tests - steps: - - checkout - - restore_cache: - key: dependency-cache-{{ checksum "package-lock.json" }} - - run: - name: Install Latest NPM. - # npm@3 is buggy - command: if [[ $(npm -v | cut -c -1) > 3 ]] ; then npm i -g npm@latest; else echo "Skip npm updating"; fi - - run: - name: NPM Install. - command: npm ci || npm i - - run: - name: Run Test. - command: npm run ci:test -canary_tests: &canary_tests - steps: - - checkout - - restore_cache: - key: dependency-cache-{{ checksum "package-lock.json" }} - - run: - name: Install Latest NPM. - command: npm i -g npm@latest - - run: - name: NPM Install. - command: npm ci - - run: - name: Install Webpack Canary. - command: npm i --no-save webpack@next - - run: - name: Run Test. - command: if [[ $(compver --name webpack --gte next --lt latest) < 1 ]] ; then printf "Next is older than Latest - Skipping Canary Suite"; else npm run ci:test || true; fi - -version: 2 -jobs: - dependency_cache: - docker: - - image: webpackcontrib/circleci-node-base:latest - steps: - - checkout - - restore_cache: - key: dependency-cache-{{ checksum "package-lock.json" }} - - run: - name: Install Latest NPM. - command: npm i -g npm@latest - - run: - name: NPM Install. - command: npm ci - - save_cache: - key: dependency-cache-{{ checksum "package-lock.json" }} - paths: - - ./node_modules - analysis: - docker: - - image: webpackcontrib/circleci-node-base:latest - steps: - - checkout - - restore_cache: - key: dependency-cache-{{ checksum "package-lock.json" }} - - run: - name: Install Latest NPM. - command: npm i -g npm@latest - - run: - name: NPM Install. - command: npm ci - - run: - name: Run linting. - command: npm run lint - - run: - name: Run NPM Audit. - command: npm run security - - run: - name: Validate Commit Messages. - command: npm run ci:lint:commits - node6-latest: - docker: - - image: webpackcontrib/circleci-node6:latest - <<: *unit_tests - node8-latest: - docker: - - image: webpackcontrib/circleci-node8:latest - <<: *unit_tests - node10-latest: - docker: - - image: webpackcontrib/circleci-node10:latest - steps: - - checkout - - restore_cache: - key: dependency-cache-{{ checksum "package-lock.json" }} - - run: - name: Install Latest NPM. - command: npm i -g npm@latest - - run: - name: NPM Install. - command: npm ci - - run: - name: Run Test. - command: npm run ci:coverage - - run: - name: Submit coverage data to codecov. - command: bash <(curl -s https://codecov.io/bash) - when: on_success - node8-canary: - docker: - - image: webpackcontrib/circleci-node8:latest - <<: *canary_tests - -workflows: - version: 2 - test: - jobs: - - dependency_cache - - analysis: - requires: - - dependency_cache - filters: - tags: - only: /.*/ - - node6-latest: - requires: - - dependency_cache - filters: - tags: - only: /.*/ - - node8-latest: - requires: - - analysis - - node6-latest - filters: - tags: - only: /.*/ - - node10-latest: - requires: - - analysis - - node6-latest - filters: - tags: - only: /.*/ - - node8-canary: - requires: - - analysis - - node6-latest - filters: - tags: - only: /.*/ diff --git a/templates/README.md b/templates/README.md index f62e23b..8ae80a8 100644 --- a/templates/README.md +++ b/templates/README.md @@ -154,8 +154,8 @@ Please take a moment to read our contributing guidelines if you haven't yet done [node-url]: https://nodejs.org [deps]: https://david-dm.org/webpack-contrib/${package}.svg [deps-url]: https://david-dm.org/webpack-contrib/${package} -[tests]: https://img.shields.io/circleci/project/github/webpack-contrib/${package}.svg -[tests-url]: https://circleci.com/gh/webpack-contrib/${package} +[tests]: https://dev.azure.com/webpack-contrib/${package}/_apis/build/status/webpack-contrib.${package}?branchName=master +[tests-url]: https://dev.azure.com/webpack-contrib/${package}/_build/latest?definitionId=2&branchName=master [cover]: https://codecov.io/gh/webpack-contrib/${package}/branch/master/graph/badge.svg [cover-url]: https://codecov.io/gh/webpack-contrib/${package} [chat]: https://img.shields.io/badge/gitter-webpack%2Fwebpack-brightgreen.svg diff --git a/templates/appveyor.yml b/templates/appveyor.yml deleted file mode 100644 index 18caa03..0000000 --- a/templates/appveyor.yml +++ /dev/null @@ -1,45 +0,0 @@ -branches: - only: - - master - - next -init: - - git config --global core.autocrlf input -cache: - - node_modules - - '%APPDATA%\npm-cache' -environment: - matrix: - - nodejs_version: '6' - webpack_version: latest - job_part: test - - nodejs_version: '8' - webpack_version: latest - job_part: test - - nodejs_version: '10' - webpack_version: latest - job_part: test - - nodejs_version: '11' - webpack_version: latest - job_part: test - - nodejs_version: '8' - webpack_version: next - job_part: test -build: 'off' -matrix: - fast_finish: true - allow_failures: - - nodejs_version: '8' - webpack_version: next - job_part: test -install: - - ps: Install-Product node $env:nodejs_version x64 - - npm i -g npm@latest - - npm ci - - npm i -g @webpack-contrib/tag-versions -before_test: - - cmd: npm install webpack@%webpack_version% -test_script: - - node --version - - npm --version - - cmd: FOR /F %%I in ('compver --name webpack --gte %webpack_version% --lt latest') do SET COMPARED_VERSION_RESULT=%%I - - cmd: IF %COMPARED_VERSION_RESULT% NEQ -1 (npm run ci:%job_part%) ELSE (ECHO "Next is older than Latest - Skipping Canary Suite") diff --git a/templates/azure-pipelines.yml b/templates/azure-pipelines.yml new file mode 100644 index 0000000..d91a2db --- /dev/null +++ b/templates/azure-pipelines.yml @@ -0,0 +1,201 @@ +trigger: + - master + - next + +jobs: + - job: Lint + pool: + vmImage: ubuntu-16.04 + steps: + - task: NodeTool@0 + inputs: + versionSpec: ^10.13.0 + displayName: 'Install Node.js' + - task: Npm@1 + inputs: + command: custom + customCommand: i -g npm@latest + displayName: 'Install latest NPM' + - script: | + node -v + npm -v + displayName: 'Print versions' + - task: Npm@1 + inputs: + command: custom + customCommand: ci + displayName: 'Install dependencies' + - script: npm run lint + displayName: 'Run lint' + - script: npm run security + displayName: 'Run NPM audit' + - script: ./node_modules/.bin/commitlint-azure-pipelines + displayName: 'Run lint commit message' + + - job: Linux + pool: + vmImage: ubuntu-16.04 + strategy: + maxParallel: 5 + matrix: + node-12: + node_version: ^12.0.0 + webpack_version: latest + node-10: + node_version: ^10.13.0 + webpack_version: latest + node-8: + node_version: ^8.9.0 + webpack_version: latest + node-6: + node_version: ^6.9.0 + webpack_version: latest + node-8-canary: + node_version: ^8.9.0 + webpack_version: next + continue_on_error: true + steps: + - task: NodeTool@0 + inputs: + versionSpec: $(node_version) + displayName: 'Install Node.js $(node_version)' + - task: Npm@1 + inputs: + command: custom + customCommand: i -g npm@latest + displayName: 'Install latest NPM' + - script: | + node -v + npm -v + displayName: 'Print versions' + - task: Npm@1 + inputs: + command: custom + customCommand: ci + displayName: 'Install dependencies' + - script: npm i webpack@$(webpack_version) + displayName: 'Install "webpack@$(webpack_version)"' + - script: npm run test:coverage -- --ci --reporters="default" --reporters="jest-junit" || $(continue_on_error) + displayName: 'Run tests with coverage' + - task: PublishTestResults@2 + inputs: + testRunTitle: 'Linux with Node.js $(node_version)' + testResultsFiles: '**/junit.xml' + condition: succeededOrFailed() + displayName: 'Publish test results' + - script: curl -s https://codecov.io/bash | bash -s -- -t $(CODECOV_TOKEN) + condition: succeededOrFailed() + displayName: 'Submit coverage data to codecov' + + - job: macOS + pool: + vmImage: macOS-10.14 + strategy: + maxParallel: 5 + matrix: + node-12: + node_version: ^12.0.0 + webpack_version: latest + node-10: + node_version: ^10.13.0 + webpack_version: latest + node-8: + node_version: ^8.9.0 + webpack_version: latest + node-6: + node_version: ^6.9.0 + webpack_version: latest + node-8-canary: + node_version: ^8.9.0 + webpack_version: next + continue_on_error: true + steps: + - task: NodeTool@0 + inputs: + versionSpec: $(node_version) + displayName: 'Install Node.js $(node_version)' + - task: Npm@1 + inputs: + command: custom + customCommand: i -g npm@latest + displayName: 'Install latest NPM' + - script: | + node -v + npm -v + displayName: 'Print versions' + - task: Npm@1 + inputs: + command: custom + customCommand: ci + displayName: 'Install dependencies' + - script: npm i webpack@$(webpack_version) + displayName: 'Install "webpack@$(webpack_version)"' + - script: npm run test:coverage -- --ci --reporters="default" --reporters="jest-junit" || $(continue_on_error) + displayName: 'Run tests with coverage' + - task: PublishTestResults@2 + inputs: + testRunTitle: 'Linux with Node.js $(node_version)' + testResultsFiles: '**/junit.xml' + condition: succeededOrFailed() + displayName: 'Publish test results' + - script: curl -s https://codecov.io/bash | bash -s -- -t $(CODECOV_TOKEN) + condition: succeededOrFailed() + displayName: 'Submit coverage data to codecov' + + - job: Windows + pool: + vmImage: windows-2019 + strategy: + maxParallel: 5 + matrix: + node-12: + node_version: ^12.0.0 + webpack_version: latest + node-10: + node_version: ^10.13.0 + webpack_version: latest + node-8: + node_version: ^8.9.0 + webpack_version: latest + node-6: + node_version: ^6.9.0 + webpack_version: latest + node-8-canary: + node_version: ^8.9.0 + webpack_version: next + continue_on_error: true + steps: + - script: 'git config --global core.autocrlf input' + displayName: 'Config git core.autocrlf' + - checkout: self + - task: NodeTool@0 + inputs: + versionSpec: $(node_version) + displayName: 'Install Node.js $(node_version)' + - task: Npm@1 + inputs: + command: custom + customCommand: i -g npm@latest + displayName: 'Install latest NPM' + - script: | + node -v + npm -v + displayName: 'Print versions' + - task: Npm@1 + inputs: + command: custom + customCommand: ci + displayName: 'Install dependencies' + - script: npm i webpack@$(webpack_version) + displayName: 'Install "webpack@$(webpack_version)"' + - script: npm run test:coverage -- --ci --reporters="default" --reporters="jest-junit" || $(continue_on_error) + displayName: 'Run tests with coverage' + - task: PublishTestResults@2 + inputs: + testRunTitle: 'Linux with Node.js $(node_version)' + testResultsFiles: '**/junit.xml' + condition: succeededOrFailed() + displayName: 'Publish test results' + - script: curl -s https://codecov.io/bash | bash -s -- -t $(CODECOV_TOKEN) + condition: succeededOrFailed() + displayName: 'Submit coverage data to codecov'