Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run tests on multiple browsers #191

Merged
merged 11 commits into from
Mar 11, 2024
Merged
119 changes: 119 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,122 @@ jobs:
- name: Output coverage to summary
if: success() || failure() && steps.run-unit-tests.outcome == 'success'
run: cat ./platform/reports/SummaryGithub.md >> $GITHUB_STEP_SUMMARY


build-mac:
runs-on: macos-latest

steps:
- uses: actions/checkout@v4

- name: Setup node 18
uses: actions/setup-node@v4
with:
node-version: 18

- name: Install node dependencies
run: |
npm ci
npm install -g karma-cli

- name: Setup safari driver
run: |
sudo safaridriver --enable

- name: Build the education platform
id: build-platform
if: success() || failure()
run: npm run build --workspaces

- name: Run the unit tests
id: run-unit-tests
if: success() || failure() && steps.build-platform.outcome == 'success'
run: npm test --workspaces -- --browsers SafariNative

- name: Create test report
uses: dorny/test-reporter@v1
if: success() || failure() && steps.run-unit-tests.outcome == 'success'
with:
name: Unit Test Results - mac
path: platform/reports/TESTS*.xml
reporter: java-junit
fail-on-error: true

- name: Setup .NET Core - for coverage report # Required to execute ReportGenerator
uses: actions/setup-dotnet@v4
if: success() || failure() && steps.run-unit-tests.outcome == 'success'
with:
dotnet-version: 8.x
dotnet-quality: 'ga'

- name: Create coverage md report
uses: danielpalme/[email protected]
if: success() || failure() && steps.run-unit-tests.outcome == 'success'
with:
reports: ./platform/reports/coverage-report.xml
targetdir: ./platform/reports/
reporttypes: MarkdownSummaryGithub

- name: Output coverage to summary
if: success() || failure() && steps.run-unit-tests.outcome == 'success'
run: cat ./platform/reports/SummaryGithub.md >> $GITHUB_STEP_SUMMARY


build-win:
runs-on: windows-latest
env:
EDGE_BIN: C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe
steps:
- uses: actions/checkout@v4

- name: Setup node 18
uses: actions/setup-node@v4
with:
node-version: 18

- name: Install node dependencies
run: |
npm ci
npm install -g karma-cli

- name: Setup edge driver
run: |
choco install selenium-chromium-edge-driver

- name: Build the education platform
id: build-platform
if: success() || failure()
run: npm run build --workspaces

- name: Run the unit tests
id: run-unit-tests
if: success() || failure() && steps.build-platform.outcome == 'success'
run: npm test --workspaces -- --browsers EdgeHeadless

- name: Create test report
uses: dorny/test-reporter@v1
if: success() || failure() && steps.run-unit-tests.outcome == 'success'
with:
name: Unit Test Results - win
path: platform/reports/TESTS*.xml
reporter: java-junit
fail-on-error: true

- name: Setup .NET Core - for coverage report # Required to execute ReportGenerator
uses: actions/setup-dotnet@v4
if: success() || failure() && steps.run-unit-tests.outcome == 'success'
with:
dotnet-version: 8.x
dotnet-quality: 'ga'

- name: Create coverage md report
uses: danielpalme/[email protected]
if: success() || failure() && steps.run-unit-tests.outcome == 'success'
with:
reports: ./platform/reports/coverage-report.xml
targetdir: ./platform/reports/
reporttypes: MarkdownSummaryGithub

- name: Output coverage to summary
if: success() || failure() && steps.run-unit-tests.outcome == 'success'
run: Get-Content -Path ".\platform\reports\SummaryGithub.md" >> $Env:GITHUB_STEP_SUMMARY
130 changes: 129 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion platform/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ module.exports = function(config) {
require('karma-coverage'),
require('karma-jasmine'),
require('karma-chrome-launcher'),
require("karma-firefox-launcher"),
require("karma-edgium-launcher"),
require("karma-safarinative-launcher"),
require('karma-jasmine-html-reporter'),
require('karma-junit-reporter')
],
Expand Down Expand Up @@ -97,7 +100,7 @@ module.exports = function(config) {

// start these browsers
// available browser launchers: https://www.npmjs.com/search?q=keywords:karma-launcher
browsers: ['ChromeHeadless'],
browsers: ['ChromeHeadless','FirefoxHeadless'],


// Continuous Integration mode
Expand Down
3 changes: 3 additions & 0 deletions platform/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@
"karma": "^6.4.1",
"karma-chrome-launcher": "^3.1.1",
"karma-coverage": "^2.2.1",
"karma-edgium-launcher": "^4.0.0-0",
"karma-firefox-launcher": "^2.1.3",
"karma-jasmine": "^5.1.0",
"karma-jasmine-html-reporter": "^2.0.0",
"karma-junit-reporter": "^2.0.1",
"karma-safarinative-launcher": "^1.1.0",
"karma-webpack": "^5.0.0",
"webpack": "^5.90.3",
"webpack-cli": "^5.1.1"
Expand Down