Skip to content

Commit ca5d70b

Browse files
MuhammadJaziralymanicki
authored andcommitted
Added Github Actions workflow to run npm test script
Also replaced phantomjs with chrome headless as a part of modernizing the test setup.
1 parent 457733e commit ca5d70b

File tree

3 files changed

+56
-2
lines changed

3 files changed

+56
-2
lines changed

.github/workflows/ci.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Lint and Test
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [10, 12, 14]
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v3
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
25+
- name: Setup Chrome
26+
uses: browser-actions/setup-chrome@latest
27+
with:
28+
chrome-version: stable
29+
30+
- name: Configure Chrome Sandbox
31+
run: |
32+
sudo chown root:root /opt/hostedtoolcache/setup-chrome/chromium/stable/x64/chrome-sandbox
33+
sudo chmod 4755 /opt/hostedtoolcache/setup-chrome/chromium/stable/x64/chrome-sandbox
34+
35+
- name: Install dependencies
36+
run: npm install
37+
38+
- name: Run ESLint and tests
39+
run: npm test
40+
env:
41+
CHROME_BIN: chrome
42+
CHROME_FLAGS: --no-sandbox --headless --disable-gpu

karma.conf.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ module.exports = function ( config ) {
3131
port: 9876,
3232

3333
logLevel: config.LOG_INFO,
34-
browsers: [ 'PhantomJS' ]
34+
browsers: [ 'ChromeHeadless' ],
35+
customLaunchers: {
36+
ChromeHeadless: {
37+
base: 'Chrome',
38+
flags: [
39+
'--no-sandbox',
40+
'--headless',
41+
'--disable-gpu',
42+
'--disable-dev-shm-usage',
43+
'--disable-software-rasterizer'
44+
]
45+
}
46+
}
3547
} );
3648
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"eslint-config-wikimedia": "0.4.0",
3838
"karma": "^6.1.0",
3939
"karma-cli": "^1.0.1",
40-
"karma-phantomjs-launcher": "^1.0.4",
40+
"karma-chrome-launcher": "^3.1.0",
4141
"karma-qunit": "^4.1.2",
4242
"qunit": "^2.14.0"
4343
},

0 commit comments

Comments
 (0)