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

feat(tests): add code coverage reporting #817

Merged
merged 24 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ on:
description: The commit SHA to run the workflow on
required: false
type: string
secrets:
codecov_token:
description: Codecov token
required: true

jobs:
build:
Expand Down Expand Up @@ -70,11 +74,32 @@ jobs:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
with:
ref: ${{ inputs.sha }}

- name: Load test image
uses: guidojw/actions/load-docker-image@abb0ee8d1336edf73383f2e5a09abd3a22f25b13 # v1.3.3
with:
name: app

- name: Test
run: |
docker run -e CI=true -t app yarn test:ember
mkdir coverage
docker run -e CI=true -e COVERAGE=true -v "$(pwd)"'/coverage:/opt/app/coverage' app yarn test:ember

- name: Upload coverage report to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@54bcd8715eee62d40e33596ef5e8f0f48dbbccab # v4.1.0
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Upload coverage report artifact
if: ${{ !cancelled() }}
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: coverage
path: coverage/
if-no-files-found: error
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![Continuous Integration](https://github.com/csvalpha/amber-ui/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/csvalpha/amber-ui/actions/workflows/continuous-integration.yml)
[![Continuous Delivery](https://github.com/csvalpha/amber-ui/actions/workflows/continuous-delivery.yml/badge.svg)](https://github.com/csvalpha/amber-ui/actions/workflows/continuous-delivery.yml)
[![codecov](https://codecov.io/gh/csvalpha/amber-ui/graph/badge.svg?token=GMTXV28YQF)](https://codecov.io/gh/csvalpha/amber-ui)

## Prerequisites

Expand Down
1 change: 1 addition & 0 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module.exports = function (defaults) {
},

babel: {
plugins: [...require('ember-cli-code-coverage').buildBabelPlugin()],
sourceMaps: 'inline',
},

Expand Down
2 changes: 2 additions & 0 deletions mirage/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export default function () {
this.passthrough('/write-coverage');

this.namespace = '/api/v1';

this.post(
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"ember-can": "^4.2.0",
"ember-cli": "~4.11.0",
"ember-cli-babel": "^7.26.10",
"ember-cli-code-coverage": "^2.0.0",
"ember-cli-content-security-policy": "^2.0.3",
"ember-cli-dependency-checker": "^3.2.0",
"ember-cli-dropzonejs": "^1.3.6",
Expand Down
9 changes: 9 additions & 0 deletions tests/test-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@ import * as QUnit from 'qunit';
import { setApplication } from '@ember/test-helpers';
import { setup } from 'qunit-dom';
import { start } from 'ember-qunit';
import {
forceModulesToBeLoaded,
sendCoverage,
} from 'ember-cli-code-coverage/test-support';

setApplication(Application.create(config.APP));

setup(QUnit.assert);

QUnit.done(async function () {
forceModulesToBeLoaded();
await sendCoverage();
});

start();
Loading
Loading