From 6cf0d62503bb077badf4babdddfe809c7983790f Mon Sep 17 00:00:00 2001 From: Yaroslav Admin Date: Fri, 1 Oct 2021 19:53:48 +0200 Subject: [PATCH 1/4] chore: migrate to GitHub Actions for CI - Use headless browsers instead of xfvb where possible. - Replace commitlint-travis with usage of the base commitlint as there is no official CLI for GitHub Actions. - Remove CI badges as GitHub displays the CI status natively for each commit. --- .github/workflows/release.yml | 33 ++++++++++++++++++ .github/workflows/test.yml | 65 +++++++++++++++++++++++++++++++++++ .travis.yml | 43 ----------------------- README.md | 2 +- appveyor.yml | 34 ------------------ docs/dev/02-making-changes.md | 2 +- docs/dev/03-maintaining.md | 2 +- package-lock.json | 52 ---------------------------- package.json | 4 +-- test/client/karma.conf.js | 16 ++++----- test/e2e/basic.feature | 2 +- test/e2e/module-types.feature | 2 +- test/e2e/runInParent.feature | 2 +- test/e2e/tag.feature | 4 +-- 14 files changed, 114 insertions(+), 149 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml delete mode 100644 appveyor.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..161dfa8b0 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,33 @@ +name: Release + +on: + push: + branches: + - master + +jobs: + main: + name: Main + runs-on: ubuntu-latest + env: + BROWSER_STACK_USERNAME: ${{ secrets.BROWSER_STACK_USERNAME }} + BROWSER_STACK_ACCESS_KEY: ${{ secrets.BROWSER_STACK_ACCESS_KEY }} + SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} + SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + GH_TOKEN: ${{ secrets.GH_TOKEN }} + KARMA_TEST_NO_FALLBACK: 1 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 14 + cache: npm + - run: npm ci + - run: npm run lint + - run: npm run build:check + - run: npm run test:unit + - run: npm run test:e2e + - run: npm run test:client + - run: npm run test:integration + - run: npm run semantic-release diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..b3c3b2b35 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,65 @@ +name: Test + +on: + push: + branches-ignore: + - master + pull_request: + branches: + - master + +jobs: + main: + name: Main + runs-on: ubuntu-latest + env: + BROWSER_STACK_USERNAME: ${{ secrets.BROWSER_STACK_USERNAME }} + BROWSER_STACK_ACCESS_KEY: ${{ secrets.BROWSER_STACK_ACCESS_KEY }} + SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} + SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: actions/setup-node@v2 + with: + node-version: 14 + cache: npm + - run: npm ci + - run: npm run commitlint -- --from `git merge-base origin/master $GITHUB_SHA` + - run: npm run lint + - run: npm run build:check + - run: npm run test:unit + - run: npm run test:e2e + - run: npm run test:client + - run: npm run test:integration + linux: + name: Node ${{ matrix.node }} on Linux + runs-on: ubuntu-latest + strategy: + matrix: + node: [ 10, 12 ] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + cache: npm + - run: npm ci + - run: npm run test:unit + - run: npm run test:e2e + windows: + name: Node ${{ matrix.node }} on Windows + runs-on: windows-latest + strategy: + matrix: + node: [10, 12, 14] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + cache: npm + - run: npm ci + - run: npm run test:unit + - run: npm run test:client diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index bbc3f0547..000000000 --- a/.travis.yml +++ /dev/null @@ -1,43 +0,0 @@ -os: linux -dist: xenial -language: node_js - -jobs: - include: - - node_js: "10" - script: - - npm run test:unit - - npm run test:e2e - - - node_js: "12" - script: - - npm run test:unit - - npm run test:e2e - - - node_js: "14" - script: - - if [[ "$TRAVIS_BRANCH" != "master" ]]; then - commitlint-travis; - fi; - - npm run lint - - npm run build:check - - npm run test:unit - - npm run test:e2e - - npm run test:client - - npm run test:integration - - after_success: - # run automated release process with semantic-release - - echo "TRAVIS_BRANCH=$TRAVIS_BRANCH, TRAVIS_EVENT_TYPE=$TRAVIS_EVENT_TYPE - - if [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_EVENT_TYPE" == "push" ]]; then - npm run semantic-release; - fi; - -before_install: - - npm config set loglevel warn - -addons: - firefox: "latest" - -services: - - xvfb diff --git a/README.md b/README.md index e22171069..4a4459431 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Karma [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/karma-runner/karma) [![npm version](https://img.shields.io/npm/v/karma.svg?style=flat-square)](https://www.npmjs.com/package/karma) [![npm downloads](https://img.shields.io/npm/dm/karma.svg?style=flat-square)](https://npmcharts.com/compare/karma?minimal=true) -[![Build Status](https://img.shields.io/travis/karma-runner/karma/master.svg?style=flat-square)](https://travis-ci.org/karma-runner/karma) [![Build Status](https://img.shields.io/appveyor/ci/dignifiedquire/karma/master.svg?style=flat-square)](https://ci.appveyor.com/project/dignifiedquire/karma) [![Code Climate](https://img.shields.io/codeclimate/github/karma-runner/karma.svg?style=flat-square)](https://codeclimate.com/github/karma-runner/karma) [![PRs Welcome](https://img.shields.io/badge/prs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com/) [![Dependency Status](https://img.shields.io/david/karma-runner/karma.svg?style=flat-square)](https://david-dm.org/karma-runner/karma) [![devDependency Status](https://img.shields.io/david/dev/karma-runner/karma.svg?style=flat-square)](https://david-dm.org/karma-runner/karma#info=devDependencies) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) + [![Code Climate](https://img.shields.io/codeclimate/github/karma-runner/karma.svg?style=flat-square)](https://codeclimate.com/github/karma-runner/karma) [![PRs Welcome](https://img.shields.io/badge/prs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com/) [![Dependency Status](https://img.shields.io/david/karma-runner/karma.svg?style=flat-square)](https://david-dm.org/karma-runner/karma) [![devDependency Status](https://img.shields.io/david/dev/karma-runner/karma.svg?style=flat-square)](https://david-dm.org/karma-runner/karma#info=devDependencies) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) A simple tool that allows you to execute JavaScript code in multiple _real_ browsers. diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 3bdd08d81..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,34 +0,0 @@ -version: "{build}" - -environment: - matrix: - - nodejs_version: "10" - - nodejs_version: "12" - - nodejs_version: "14" - -matrix: - fast_finish: true - -install: - # Install Node.js - - ps: Install-Product node $env:nodejs_version x64 - - # Output our current versions for debugging - - node --version - - npm --version - - # Install our package dependencies - - appveyor-retry npm install - -test_script: - - npm run test:unit - - npm run test:client - -build: off - -notifications: - - provider: GitHubPullRequest - auth_token: - secure: EsLCrNVrISCIxbBSTorZ5uxFQf/zRaLNznqYPWQ0LBEl2KG2IgCFRnjiNKpTfTDs - template: "{{#passed}}:white_check_mark:{{/passed}}{{#failed}}:x:{{/failed}} [Build {{&projectName}} {{buildVersion}} {{status}}]({{buildUrl}}) (commit {{commitUrl}} by @{{&commitAuthorUsername}})" - diff --git a/docs/dev/02-making-changes.md b/docs/dev/02-making-changes.md index 7985e0458..a0d875427 100644 --- a/docs/dev/02-making-changes.md +++ b/docs/dev/02-making-changes.md @@ -2,7 +2,7 @@ TODO: - add more info about updating PR - rebasing/squashing changes - - making sure Travis is green + - making sure CI is green - how to run tests on sauce labs - how to set up plugins --> diff --git a/docs/dev/03-maintaining.md b/docs/dev/03-maintaining.md index 6e541ffb1..5144ff571 100644 --- a/docs/dev/03-maintaining.md +++ b/docs/dev/03-maintaining.md @@ -21,7 +21,7 @@ An issue or pull request is untriaged (needs to be triaged) when it is not assig ## Merging a pull request Please, make sure: -- Travis build is green. +- CI build is green. - At least one owner (other than you) approved the PR - by commenting “LGTM” or something like that. - if it’s just a simple docs change or a typo fix, feel free to skip this step. diff --git a/package-lock.json b/package-lock.json index 38a279855..ef7fa5c4a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1003,58 +1003,6 @@ } } }, - "@commitlint/travis-cli": { - "version": "8.3.5", - "resolved": "https://registry.npmjs.org/@commitlint/travis-cli/-/travis-cli-8.3.5.tgz", - "integrity": "sha512-E456A36Ya9Zrr0+ONfkPoHNdWnX4zfR6seHjuzTy0393iSHNc9cZ250mGw0SKQiYQu8x1QHrQyWwyRXLb2iASw==", - "dev": true, - "requires": { - "@commitlint/cli": "^8.3.5", - "babel-runtime": "6.26.0", - "execa": "0.11.0" - }, - "dependencies": { - "execa": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-0.11.0.tgz", - "integrity": "sha512-k5AR22vCt1DcfeiRixW46U5tMLtBg44ssdJM9PiXw3D8Bn5qyxFCSnKY/eR22y+ctFDGPqafpaXg2G4Emyua4A==", - "dev": true, - "requires": { - "cross-spawn": "^6.0.0", - "get-stream": "^4.0.0", - "is-stream": "^1.1.0", - "npm-run-path": "^2.0.0", - "p-finally": "^1.0.0", - "signal-exit": "^3.0.0", - "strip-eof": "^1.0.0" - } - }, - "get-stream": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", - "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", - "dev": true, - "requires": { - "pump": "^3.0.0" - } - }, - "npm-run-path": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", - "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", - "dev": true, - "requires": { - "path-key": "^2.0.0" - } - }, - "p-finally": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", - "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", - "dev": true - } - } - }, "@marionebl/sander": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/@marionebl/sander/-/sander-0.6.1.tgz", diff --git a/package.json b/package.json index e6511014e..758dfe39c 100644 --- a/package.json +++ b/package.json @@ -444,7 +444,6 @@ "devDependencies": { "@commitlint/cli": "^8.3.4", "@commitlint/config-conventional": "^8.3.4", - "@commitlint/travis-cli": "^8.3.5", "@semantic-release/changelog": "^3.0.6", "@semantic-release/git": "^7.0.18", "browserify": "^16.2.3", @@ -511,6 +510,7 @@ "build:check": "node scripts/client.js check", "build:watch": "node scripts/client.js watch", "test:integration": "./scripts/integration-tests.sh", - "semantic-release": "semantic-release" + "semantic-release": "semantic-release", + "commitlint": "commitlint" } } diff --git a/test/client/karma.conf.js b/test/client/karma.conf.js index 47dc56ed7..8f324f2da 100644 --- a/test/client/karma.conf.js +++ b/test/client/karma.conf.js @@ -1,4 +1,8 @@ -const TRAVIS_WITH_BS = !!process.env.BROWSER_STACK_ACCESS_KEY +// When running pre-release tests we want tests to fail if BrowserStack is not +// configured instead of falling back to the headless browser. That's what +// KARMA_TEST_NO_FALLBACK variable controls. +const useBrowserStack = (process.env.BROWSER_STACK_USERNAME && process.env.BROWSER_STACK_ACCESS_KEY) || + process.env.KARMA_TEST_NO_FALLBACK const launchers = { bs_chrome: { @@ -35,14 +39,6 @@ const launchers = { } } -let browsers = ['Chrome'] - -if (process.env.TRAVIS) { - if (TRAVIS_WITH_BS) { - browsers = Object.keys(launchers) - } -} - module.exports = function (config) { config.set({ // base path, that will be used to resolve files and exclude @@ -99,7 +95,7 @@ module.exports = function (config) { // - PhantomJS // - IE (only Windows) // CLI --browsers Chrome,Firefox,Safari - browsers: browsers, + browsers: useBrowserStack ? Object.keys(launchers) : ['ChromeHeadless'], customLaunchers: launchers, diff --git a/test/e2e/basic.feature b/test/e2e/basic.feature index 413648f62..d86dd438c 100644 --- a/test/e2e/basic.feature +++ b/test/e2e/basic.feature @@ -24,7 +24,7 @@ Feature: Basic Testrunner Given a configuration with: """ files = ['basic/plus.js', 'basic/test.js'] - browsers = ['Firefox'] + browsers = ['FirefoxHeadless'] plugins = [ 'karma-jasmine', 'karma-firefox-launcher' diff --git a/test/e2e/module-types.feature b/test/e2e/module-types.feature index 0a2011b5e..15bf8c6e2 100644 --- a/test/e2e/module-types.feature +++ b/test/e2e/module-types.feature @@ -14,7 +14,7 @@ Feature: ES Modules // manually enable modules). customLaunchers = { FirefoxWithModules: { - base: 'Firefox', + base: 'FirefoxHeadless', prefs: { 'dom.moduleScripts.enabled': true } diff --git a/test/e2e/runInParent.feature b/test/e2e/runInParent.feature index 2bd59b321..ac5470517 100644 --- a/test/e2e/runInParent.feature +++ b/test/e2e/runInParent.feature @@ -28,7 +28,7 @@ Feature: runInParent option Given a configuration with: """ files = ['basic/plus.js', 'basic/test.js'] - browsers = ['Firefox'] + browsers = ['FirefoxHeadless'] plugins = [ 'karma-jasmine', 'karma-firefox-launcher' diff --git a/test/e2e/tag.feature b/test/e2e/tag.feature index d51ab5f2b..04f686356 100644 --- a/test/e2e/tag.feature +++ b/test/e2e/tag.feature @@ -7,7 +7,7 @@ Feature: JavaScript Tag Given a configuration with: """ files = ['tag/tag.js', 'tag/test-with-version.js']; - browsers = ['Firefox'] + browsers = ['FirefoxHeadless'] plugins = [ 'karma-jasmine', 'karma-firefox-launcher' @@ -41,7 +41,7 @@ Feature: JavaScript Tag Given a configuration with: """ files = ['tag/tag.js', 'tag/test-without-version.js']; - browsers = ['Firefox'] + browsers = ['FirefoxHeadless'] plugins = [ 'karma-jasmine', 'karma-firefox-launcher' From 046f8b69869919d699acaff9240a247d571a83e1 Mon Sep 17 00:00:00 2001 From: Jonathan Ginsburg Date: Thu, 14 Oct 2021 10:30:40 -0500 Subject: [PATCH 2/4] chore: use BS plugin's compatible env names See: https://github.com/karma-runner/karma-browserstack-launcher#:~:text=username%20your%20BS,BROWSERSTACK_ACCESS_KEY%20env%20variable. --- .github/workflows/release.yml | 4 ++-- .github/workflows/test.yml | 4 ++-- test/client/karma.conf.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 161dfa8b0..c3a1730fe 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,8 +10,8 @@ jobs: name: Main runs-on: ubuntu-latest env: - BROWSER_STACK_USERNAME: ${{ secrets.BROWSER_STACK_USERNAME }} - BROWSER_STACK_ACCESS_KEY: ${{ secrets.BROWSER_STACK_ACCESS_KEY }} + BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME}} + BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b3c3b2b35..564c0333f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,8 +13,8 @@ jobs: name: Main runs-on: ubuntu-latest env: - BROWSER_STACK_USERNAME: ${{ secrets.BROWSER_STACK_USERNAME }} - BROWSER_STACK_ACCESS_KEY: ${{ secrets.BROWSER_STACK_ACCESS_KEY }} + BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME}} + BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} steps: diff --git a/test/client/karma.conf.js b/test/client/karma.conf.js index 8f324f2da..3dc337178 100644 --- a/test/client/karma.conf.js +++ b/test/client/karma.conf.js @@ -1,7 +1,7 @@ // When running pre-release tests we want tests to fail if BrowserStack is not // configured instead of falling back to the headless browser. That's what // KARMA_TEST_NO_FALLBACK variable controls. -const useBrowserStack = (process.env.BROWSER_STACK_USERNAME && process.env.BROWSER_STACK_ACCESS_KEY) || +const useBrowserStack = (process.env.BROWSERSTACK_USERNAME && process.env.BROWSERSTACK_ACCESS_KEY) || process.env.KARMA_TEST_NO_FALLBACK const launchers = { From 0ad4ab82b55e3d3c65b000d912dd76ccf00a9d63 Mon Sep 17 00:00:00 2001 From: Jonathan Ginsburg Date: Thu, 14 Oct 2021 11:18:44 -0500 Subject: [PATCH 3/4] chore: improve GH Actions workflow's job names This is needed because in GH's configuration, we need to distinguish the required checks for protected branches and giving them unique names results in easiera configs. --- .github/workflows/release.yml | 2 +- .github/workflows/test.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c3a1730fe..ce351d4be 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,7 +7,7 @@ on: jobs: main: - name: Main + name: Test, Tag Commit and Release to NPM runs-on: ubuntu-latest env: BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME}} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 564c0333f..1465fc08b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ on: jobs: main: - name: Main + name: Lint and Unit (Client and Server), E2E and Integration Test runs-on: ubuntu-latest env: BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME}} @@ -34,7 +34,7 @@ jobs: - run: npm run test:client - run: npm run test:integration linux: - name: Node ${{ matrix.node }} on Linux + name: "Node ${{ matrix.node }} on Linux: Server Unit and E2E Test" runs-on: ubuntu-latest strategy: matrix: @@ -49,7 +49,7 @@ jobs: - run: npm run test:unit - run: npm run test:e2e windows: - name: Node ${{ matrix.node }} on Windows + name: "Node ${{ matrix.node }} on Windows: Server Unit and Client Unit Test" runs-on: windows-latest strategy: matrix: From a050f4cd76bbc46b7ae323dae93b5cdc6030387f Mon Sep 17 00:00:00 2001 From: Jonathan Ginsburg Date: Thu, 14 Oct 2021 16:01:43 -0500 Subject: [PATCH 4/4] chore: remove client testing from the windows job of test.yml The purpose of this test is to make sure that client JS works in different browsers and it does not need to be run on different OS/Node versions. --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1465fc08b..476ac60e8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -62,4 +62,3 @@ jobs: cache: npm - run: npm ci - run: npm run test:unit - - run: npm run test:client