Skip to content

Commit

Permalink
improve ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak committed Oct 31, 2023
1 parent 5d19e03 commit dc19226
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
42 changes: 40 additions & 2 deletions .github/workflows/mocha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,50 @@ jobs:
with:
github-token: '${{ secrets.GITHUB_TOKEN }}'

test-browser:
name: 'Browser Tests'
test-browser-local:
name: Browser Test [ChromeHeadless]
needs: smoke
runs-on: ubuntu-latest
timeout-minutes: 20
# Don't run forked 'pull_request' without saucelabs token
if: github.event_name == 'push' || !github.event.pull_request.head.repo.fork
steps:
- uses: actions/setup-node@v4
with:
node-version: lts/*
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: 'Cache node_modules'
uses: actions/cache@v3
with:
path: '~/.npm'
# this key is different than above, since we are running scripts
# (builds, postinstall lifecycle hooks, etc.)
key: "ubuntu-latest-node-full-lts-${{ hashFiles('**/package-lock.json') }}"
- name: Install Dependencies
run: npm ci
- name: Run Browser Tests
run: npm start test.browser
env:
BROWSER: ChromeHeadless

test-browser-saucelabs:
name: Browser Tests on SauceLabs [${{ matrix.browser }}]
needs:
- smoke
- test-browser-local
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
browser:
- firefox@latest
- chrome@latest
- MicrosoftEdge@latest
- safari@latest
# Don't run forked 'pull_request' without saucelabs token
if: github.event_name == 'push' || !github.event.pull_request.head.repo.fork
steps:
- uses: actions/setup-node@v4
with:
Expand All @@ -165,3 +202,4 @@ jobs:
env:
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
BROWSER: ${{ matrix.browser }}
8 changes: 8 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const rollupPlugin = require('./scripts/karma-rollup-plugin');
const BASE_BUNDLE_DIR_PATH = path.join(__dirname, '.karma');
const env = process.env;
const hostname = os.hostname();
const BROWSER = env.BROWSER;

const SAUCE_BROWSER_PLATFORM_MAP = {
'chrome@latest': 'Windows 10',
Expand Down Expand Up @@ -120,6 +121,13 @@ module.exports = config => {
files: [...cfg.files, {pattern: './mocha.js.map', included: false}]
};

if (BROWSER) {
cfg = {
...cfg,
browsers: [BROWSER]
};
}

config.set(cfg);
};

Expand Down

0 comments on commit dc19226

Please sign in to comment.