Skip to content

Commit

Permalink
feat(tests): add code coverage reporting (#817)
Browse files Browse the repository at this point in the history
* feat(tests): add code coverage

* fix: change volume handling

* fix: volume host dir

* refactor: remove ifs

* fix: use lcov

* fix: passthrough in mirage

* test: remove files

* fix: add codecov path fixes

* fix: add leading slash path fix

* refactor: remove unnecessary files input

* fix: remove leading slash again

* fix: test other fix

* fix: set files again

aaaaaa

* chore: remove codecov.yml

* fix: change Istanbul reporters

* fix: prefix path with ./

* test: only upload lcov.info

* fix: disable search

* fix: functionalities input

* fix: checkout code

* refactor: remove unnecessary -t

* feat: add if-no-files-found on upload-artifact

* refactor: try tokenless report uploading

* chore: update codecov-action
  • Loading branch information
guidojw authored Oct 11, 2024
1 parent 4b41cf4 commit c8e78f2
Show file tree
Hide file tree
Showing 7 changed files with 2,211 additions and 24 deletions.
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

0 comments on commit c8e78f2

Please sign in to comment.