Skip to content

Commit

Permalink
chore: migrate to GitHub Actions for CI (karma-runner#3701)
Browse files Browse the repository at this point in the history
* 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.

* 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.

* 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.

* 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.

Co-authored-by: Jonathan Ginsburg <jginsburgn@google.com>
  • Loading branch information
devoto13 and Jonathan Ginsburg authored Oct 14, 2021
1 parent 2b71a3c commit 9a99189
Show file tree
Hide file tree
Showing 14 changed files with 113 additions and 149 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Release

on:
push:
branches:
- master

jobs:
main:
name: Test, Tag Commit and Release to NPM
runs-on: ubuntu-latest
env:
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 }}
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
64 changes: 64 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Test

on:
push:
branches-ignore:
- master
pull_request:
branches:
- master

jobs:
main:
name: Lint and Unit (Client and Server), E2E and Integration Test
runs-on: ubuntu-latest
env:
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:
- 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: Server Unit and E2E Test"
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: Server Unit and Client Unit Test"
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
43 changes: 0 additions & 43 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
34 changes: 0 additions & 34 deletions appveyor.yml

This file was deleted.

2 changes: 1 addition & 1 deletion docs/dev/02-making-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-->
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/03-maintaining.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
52 changes: 0 additions & 52 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
}
16 changes: 6 additions & 10 deletions test/client/karma.conf.js
Original file line number Diff line number Diff line change
@@ -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.BROWSERSTACK_USERNAME && process.env.BROWSERSTACK_ACCESS_KEY) ||
process.env.KARMA_TEST_NO_FALLBACK

const launchers = {
bs_chrome: {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/basic.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/module-types.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Feature: ES Modules
// manually enable modules).
customLaunchers = {
FirefoxWithModules: {
base: 'Firefox',
base: 'FirefoxHeadless',
prefs: {
'dom.moduleScripts.enabled': true
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/runInParent.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/tag.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit 9a99189

Please sign in to comment.