From dc19226728ad9a7acd6e82b04734dec1f8a007fb Mon Sep 17 00:00:00 2001 From: uzlopak Date: Tue, 31 Oct 2023 17:39:15 +0100 Subject: [PATCH] improve ci --- .github/workflows/mocha.yml | 42 +++++++++++++++++++++++++++++++++++-- karma.conf.js | 8 +++++++ 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mocha.yml b/.github/workflows/mocha.yml index ab063f88df..a71d47804e 100644 --- a/.github/workflows/mocha.yml +++ b/.github/workflows/mocha.yml @@ -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: @@ -165,3 +202,4 @@ jobs: env: SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} + BROWSER: ${{ matrix.browser }} diff --git a/karma.conf.js b/karma.conf.js index 162328926f..728632151b 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -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', @@ -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); };