Skip to content

Commit

Permalink
ci: run electron runner tests on GH actions (#1373)
Browse files Browse the repository at this point in the history
Co-authored-by: Joe Haines <[email protected]>
  • Loading branch information
kattrali and imjoehaines authored May 4, 2021
1 parent 949b242 commit c109a1b
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 19 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/pr-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ jobs:
ref: ${{ github.base_ref }}

- name: Record before stats
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
run: |
mkdir .diff
npm ci
npx lerna bootstrap
npm run build
npm run test:unit -- --coverage
npm run test:coverage
cat packages/browser/dist/bugsnag.min.js | wc -c > .diff/size-before-minified
cat packages/browser/dist/bugsnag.min.js | gzip | wc -c > .diff/size-before-gzipped
cp coverage/coverage-summary.json .diff/coverage-before.json
Expand All @@ -33,11 +35,13 @@ jobs:
clean: false

- name: Record after stats
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
run: |
npm ci
npx lerna bootstrap
npm run build
npm run test:unit -- --coverage
npm run test:coverage
cat packages/browser/dist/bugsnag.min.js | wc -c > .diff/size-after-minified
cat packages/browser/dist/bugsnag.min.js | gzip | wc -c > .diff/size-after-gzipped
cp coverage/coverage-summary.json .diff/coverage-after.json
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test-electron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ jobs:
- name: (macOS) disable crash dialog
if: contains(matrix.os, 'macos')
run: defaults write com.apple.CrashReporter DialogType none
- name: run unit tests
run: npm run test:unit:electron-runner
- name: run integration tests
run: npm run test:electron
shell: bash
Expand Down
20 changes: 20 additions & 0 deletions config/electron-jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
projects: [
{
setupFilesAfterEnv: ['<rootDir>/test/electron/setup.ts'],
clearMocks: true,
modulePathIgnorePatterns: ['.verdaccio', 'fixtures', 'examples'],
displayName: 'electron main',
runner: '@jest-runner/electron/main',
testMatch: ['**/test/**/*.test-main.ts']
},
{
setupFilesAfterEnv: ['<rootDir>/test/electron/setup.ts'],
clearMocks: true,
modulePathIgnorePatterns: ['.verdaccio', 'fixtures', 'examples'],
displayName: 'electron renderer',
runner: '@jest-runner/electron',
testMatch: ['**/test/**/*.test-renderer.ts']
}
]
}
7 changes: 7 additions & 0 deletions config/full-suite-jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Run default and electron runner tests as a single suite
const { projects } = require('./electron-jest.config')
const config = require('../jest.config')

config.projects.push(...projects)

module.exports = config
17 changes: 1 addition & 16 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = {
collectCoverageFrom: [
`**/packages/*/**/*.{${extensions}}`,
`!**/*.test.{${extensions}}`,
`!**/*.test-*.{${extensions}}`,
'!**/*.d.ts',
'!**/dist/**',
'!**/packages/js/**',
Expand Down Expand Up @@ -129,22 +130,6 @@ module.exports = {
clearMocks: true,
modulePathIgnorePatterns: ['.verdaccio', 'fixtures']
}),
{
setupFilesAfterEnv: ['<rootDir>/test/electron/setup.ts'],
clearMocks: true,
modulePathIgnorePatterns: ['.verdaccio', 'fixtures'],
displayName: 'electron main',
runner: '@jest-runner/electron/main',
testMatch: ['**/test/**/*.test-main.ts']
},
{
setupFilesAfterEnv: ['<rootDir>/test/electron/setup.ts'],
clearMocks: true,
modulePathIgnorePatterns: ['.verdaccio', 'fixtures'],
displayName: 'electron renderer',
runner: '@jest-runner/electron',
testMatch: ['**/test/**/*.test-renderer.ts']
},
project('react native cli', ['react-native-cli'], { testEnvironment: 'node' })
]
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@
"build:electron": "lerna run build --scope '@bugsnag/plugin-electron-ipc' --scope '@bugsnag/plugin-electron-app' --scope '@bugsnag/plugin-electron-client-state-persistence'",
"test:lint": "eslint --ext .ts,.js --report-unused-disable-directives --max-warnings=0 .",
"test:lint-native": "bash scripts/cppcheck.sh",
"test:unit:electron-runner": "xvfb-maybe --auto-servernum -- jest -c config/electron-jest.config.js --rootDir .",
"test:unit": "xvfb-maybe --auto-servernum -- jest",
"test:coverage": "xvfb-maybe --auto-servernum -- jest --coverage",
"test:coverage": "xvfb-maybe --auto-servernum -- jest -c config/full-suite-jest.config.js --rootDir . --coverage",
"test:types": "tsc -p tsconfig.json && lerna run test:types",
"test:test-container-registry-login": "aws ecr get-login-password --profile=opensource | docker login --username AWS --password-stdin 855461928731.dkr.ecr.us-west-1.amazonaws.com",
"test:build-browser-container": "docker-compose up --build minimal-packager && docker-compose build --pull browser-maze-runner",
Expand Down

0 comments on commit c109a1b

Please sign in to comment.