2022-03-27 08:05:30 +08:00
|
|
|
name: 'BrowserStack Test'
|
2022-03-28 05:33:06 +08:00
|
|
|
|
2022-03-27 08:05:30 +08:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches: [ master, develop ]
|
|
|
|
pull_request:
|
|
|
|
branches: [ master, develop ]
|
2022-03-28 05:33:06 +08:00
|
|
|
|
2022-03-27 08:05:30 +08:00
|
|
|
jobs:
|
|
|
|
ubuntu-job:
|
|
|
|
name: 'BrowserStack Test on Ubuntu'
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2022-03-31 15:22:18 +08:00
|
|
|
- name: set up env vars
|
|
|
|
# Only the first line of commit msg
|
|
|
|
run: echo "COMMIT_MSG=$(printf "%s" "${{ github.event.head_commit.message }}" | head -n 1)" >> $GITHUB_ENV
|
2022-03-27 08:05:30 +08:00
|
|
|
|
2022-03-27 10:54:45 +08:00
|
|
|
- name: '📦 Checkout the repository'
|
2022-03-27 08:05:30 +08:00
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: '🚚 Upgrade NPM'
|
|
|
|
run: npm install -g npm
|
|
|
|
|
2022-03-27 10:59:45 +08:00
|
|
|
- name: '⚙ Setup Node.js v17.x'
|
|
|
|
uses: actions/setup-node@v2
|
|
|
|
with:
|
|
|
|
node-version: 17.x
|
|
|
|
cache: 'npm'
|
2022-03-27 08:05:30 +08:00
|
|
|
|
2022-03-27 10:54:45 +08:00
|
|
|
- name: '📖 Get current package version'
|
2022-03-27 11:13:12 +08:00
|
|
|
id: package-version
|
2022-04-20 20:32:05 +08:00
|
|
|
uses: martinbeentjes/npm-get-version-action@v1.2.0
|
2022-03-27 10:54:45 +08:00
|
|
|
|
2022-03-28 05:33:06 +08:00
|
|
|
- name: '📝 Print build version and commit msg'
|
2022-03-31 15:03:09 +08:00
|
|
|
run: 'printf "version: %s\n build:%s\n message:%s\n" "${{ steps.package-version.outputs.current-version}}" "${{ github.run_id }}" "$COMMIT_MSG"'
|
2022-03-27 11:16:12 +08:00
|
|
|
|
2022-03-27 11:13:12 +08:00
|
|
|
- name: '📱 BrowserStack Env Setup' # Invokes the setup-env action
|
2022-03-27 10:54:45 +08:00
|
|
|
uses: browserstack/github-actions/setup-env@master
|
|
|
|
with:
|
|
|
|
username: ${{ secrets.BROWSERSTACK_USERNAME }}
|
|
|
|
access-key: ${{ secrets.BROWSERSTACK_ACCESSKEY }}
|
|
|
|
project-name: 'showdown'
|
2022-03-27 11:13:12 +08:00
|
|
|
build-name: ${{ steps.package-version.outputs.current-version}}-${{ github.run_id }}
|
2022-03-27 10:54:45 +08:00
|
|
|
|
2022-03-27 11:13:12 +08:00
|
|
|
- name: '🚇 BrowserStack Local Tunnel Setup' # Invokes the setup-local action
|
2022-03-27 10:54:45 +08:00
|
|
|
uses: browserstack/github-actions/setup-local@master
|
|
|
|
with:
|
|
|
|
local-testing: start
|
|
|
|
local-identifier: random
|
|
|
|
|
2022-03-27 10:59:45 +08:00
|
|
|
- name: '🚚 Install dependencies for CI'
|
|
|
|
run: npm ci
|
|
|
|
|
|
|
|
- name: '🏗 Building src files for testing'
|
|
|
|
run: npx grunt concat:test
|
|
|
|
|
|
|
|
- name: '✅ Running test on BrowserStack with Karma'
|
2022-03-27 08:25:36 +08:00
|
|
|
run: npx karma start karma.browserstack.js
|
2022-03-27 08:05:30 +08:00
|
|
|
|
2022-03-27 10:59:45 +08:00
|
|
|
- name: '🛑 BrowserStackLocal Stop' # Terminating the BrowserStackLocal tunnel connection
|
2022-03-27 08:05:30 +08:00
|
|
|
uses: browserstack/github-actions/setup-local@master
|
|
|
|
with:
|
|
|
|
local-testing: stop
|