Skip to content

Commit

Permalink
Added Github Actions workflow to run npm test script
Browse files Browse the repository at this point in the history
Also replaced phantomjs with chrome headless,
and removed puppeteer as part of modernizing
the test setup.
  • Loading branch information
MuhammadJaziraly authored and manicki committed Jan 8, 2025
1 parent 457733e commit 4780c21
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Lint and Test

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10, 12, 14]

steps:
- uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Setup Chrome
uses: browser-actions/setup-chrome@latest
with:
chrome-version: stable

- name: Configure Chrome Sandbox
run: |
sudo chown root:root /opt/hostedtoolcache/setup-chrome/chromium/stable/x64/chrome-sandbox
sudo chmod 4755 /opt/hostedtoolcache/setup-chrome/chromium/stable/x64/chrome-sandbox
- name: Install dependencies
run: npm install

- name: Run ESLint and tests
run: npm test
env:
CHROME_BIN: chrome
CHROME_FLAGS: --no-sandbox --headless --disable-gpu
14 changes: 13 additions & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ module.exports = function ( config ) {
port: 9876,

logLevel: config.LOG_INFO,
browsers: [ 'PhantomJS' ]
browsers: [ 'ChromeHeadless' ],
customLaunchers: {
ChromeHeadless: {
base: 'Chrome',
flags: [
'--no-sandbox',
'--headless',
'--disable-gpu',
'--disable-dev-shm-usage',
'--disable-software-rasterizer'
]
}
}
} );
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"eslint-config-wikimedia": "0.4.0",
"karma": "^6.1.0",
"karma-cli": "^1.0.1",
"karma-phantomjs-launcher": "^1.0.4",
"karma-chrome-launcher": "^3.1.0",
"karma-qunit": "^4.1.2",
"qunit": "^2.14.0"
},
Expand Down

0 comments on commit 4780c21

Please sign in to comment.