Loading README.md +16 −15 Original line number Diff line number Diff line Loading @@ -51,7 +51,6 @@ Those stage are bound to the `build` stage, and uses the following variable: |-----------------|------------------------------------------------------------|------------------------------------------| | `NG_TEST_ARGS` | Angular [ng test](https://angular.io/cli/test) arguments | `test --code-coverage --reporters progress,junit` | | `NG_BUILD_ARGS` | Angular [ng build](https://angular.io/cli/build) arguments | `build --prod` | | `NG_JUNIT_TEST_REPORT_PATH` | Path to JUnit report | `reports/junit_test_report.xml` | The next chapters presents some requirements related to your unit tests (using Karma). Loading @@ -76,15 +75,16 @@ Add the config section: ```js // [to be continuous]: karma-coverage configuration (needs 'text-summary' to let GitLab grab coverage from stdout) coverageReporter: { dir: require("path").resolve("reports"), subdir: ".", dir: 'reports', subdir: '.', file: 'ng-coverage.lcov.info', reporters: [{ type: "lcovonly" }, { type: "text-summary" }], }, ``` #### JUnit report In order to be able to [integrate your test reports to GitLab](https://docs.gitlab.com/ee/ci/junit_test_reports.html), In order to be able to [integrate your test reports to GitLab](https://docs.gitlab.com/ee/ci/yaml/artifacts_reports.html#artifactsreportsjunit), the Angular template expects the following in your `karma.conf.js`. Add the [karma-junit-reporter](https://github.com/karma-runner/karma-junit-reporter) package as dev dependency: Loading @@ -102,10 +102,10 @@ In your `karma.conf.js`, add the plugin: Add the config section: ```js // [to be continuous]: karma-junit-reporter configuration (report needs to be in 'reports/junit_test_report.xml') // [to be continuous]: karma-junit-reporter configuration (report needs to be in 'reports/ng-test.xunit.xml') junitReporter: { outputDir: require('path').resolve('reports'), outputFile: 'junit_test_report.xml', outputDir: 'reports', outputFile: 'ng-test.xunit.xml', useBrowserName: false, ... } Loading @@ -131,9 +131,10 @@ In your `karma.conf.js`, add the plugin: Add the config section: ```js // [to be continuous]: karma-sonarqube-execution-reporter configuration (report needs to be in 'reports/ng-test.sonar.xml') sonarQubeExecutionReporter: { outputDir: require('path').resolve('reports'), outputFile: 'sonar_test_report.xml', outputDir: 'reports', outputFile: 'ng-test.sonar.xml', ... } ``` Loading @@ -152,7 +153,6 @@ This stage is bound to the `test` stage and uses the following variables : | Name | description | default value | |----------------------|------------------------------------------------------------|------------------------------------------| | `NG_E2E_ARGS` | Angular [ng e2e](https://angular.io/cli/e2e) arguments | `e2e` | | `NG_E2E_REPORT_PATH` | path where e2e reports are stored | `reports/e2e` | | `NG_E2E_ENABLED` | set to `true`to enable the e2e tests execution | *none (disabled by default)* | Implementation rely on the official [Angular CLI](https://cli.angular.io/) tool (`ng build` and `ng test` commands). Loading @@ -167,7 +167,8 @@ exports.config = { onPrepare() { jasmine.getEnv().addReporter(new JUnitXmlReporter({ consolidateAll: true, savePath: 'reports/e2e' savePath: 'reports', filePrefix: 'ng-e2e.xunit' })); } ... Loading Loading @@ -237,12 +238,12 @@ sonar.test.inclusions=**/*.spec.ts # tests report: generic format # set the path configured with karma-sonarqube-execution-reporter sonar.testExecutionReportPaths=reports/sonar_test_report.xml sonar.testExecutionReportPaths=reports/ng-test.sonar.xml # lint report: TSLint JSON sonar.typescript.tslint.reportPaths=reports/tslint-report.json sonar.typescript.tslint.reportPaths=reports/ng-lint.tslint.json # coverage report: LCOV format # set the path configured with karma-coverage-istanbul-reporter sonar.typescript.lcov.reportPaths=reports/lcov.info sonar.typescript.lcov.reportPaths=reports/ng-coverage.lcov.info ``` More info: Loading kicker.json +0 −6 Original line number Diff line number Diff line Loading @@ -94,12 +94,6 @@ "description": "ng [e2e](https://angular.io/cli/e2e) arguments", "default": "e2e", "advanced": true }, { "name": "NG_E2E_REPORT_PATH", "description": "path where e2e reports are stored", "default": "reports/e2e", "advanced": true } ] } Loading templates/gitlab-ci-angular.yml +7 −11 Original line number Diff line number Diff line Loading @@ -50,10 +50,6 @@ variables: # Default Docker image for ANGULAR CLI (can be overridden) NG_CLI_IMAGE: trion/ng-cli-karma:latest # JUnit test report NG_JUNIT_TEST_REPORT_PATH: "reports/junit_test_report.xml" NG_E2E_REPORT_PATH: "reports/e2e" # Angular lint NG_LINT_ARGS: "lint" Loading Loading @@ -133,10 +129,10 @@ stages: function sonar_lint_report() { if [[ -n "$SONAR_URL" ]] then mkdir -p reports mkdir -p -m 777 reports # generate ts lint report in json for SONARqube # shellcheck disable=SC2086 ng $NG_LINT_ARGS --format=json --force > reports/tslint-report.json ng $NG_LINT_ARGS --format=json --force > reports/ng-lint.tslint.json fi } Loading Loading @@ -474,13 +470,13 @@ ng-build: coverage: '/^Statements\s*:\s*([^%]+)/' artifacts: reports: junit: $NG_WORKSPACE_DIR/$NG_JUNIT_TEST_REPORT_PATH junit: - "$NG_WORKSPACE_DIR/reports/ng-test.xunit.xml" when: always # save artifact even if test failed name: "$CI_JOB_NAME artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG" paths: - $NG_WORKSPACE_DIR/coverage - $NG_WORKSPACE_DIR/dist - $NG_WORKSPACE_DIR/reports - $NG_WORKSPACE_DIR/reports/ng-*" expire_in: 1 day ############################################################################################### Loading @@ -494,11 +490,11 @@ ng-e2e: - ng $NG_E2E_ARGS artifacts: reports: junit: $NG_WORKSPACE_DIR/$NG_E2E_REPORT_PATH/junit*.xml junit: $NG_WORKSPACE_DIR/reports/ng-e2e.xunit.xml when: always # save artifact even if test failed name: "$CI_JOB_NAME artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG" paths: - $NG_WORKSPACE_DIR/$NG_E2E_REPORT_PATH - $NG_WORKSPACE_DIR/reports/ng-e2e.* expire_in: 1 day rules: # only run if feature is enabled Loading Loading
README.md +16 −15 Original line number Diff line number Diff line Loading @@ -51,7 +51,6 @@ Those stage are bound to the `build` stage, and uses the following variable: |-----------------|------------------------------------------------------------|------------------------------------------| | `NG_TEST_ARGS` | Angular [ng test](https://angular.io/cli/test) arguments | `test --code-coverage --reporters progress,junit` | | `NG_BUILD_ARGS` | Angular [ng build](https://angular.io/cli/build) arguments | `build --prod` | | `NG_JUNIT_TEST_REPORT_PATH` | Path to JUnit report | `reports/junit_test_report.xml` | The next chapters presents some requirements related to your unit tests (using Karma). Loading @@ -76,15 +75,16 @@ Add the config section: ```js // [to be continuous]: karma-coverage configuration (needs 'text-summary' to let GitLab grab coverage from stdout) coverageReporter: { dir: require("path").resolve("reports"), subdir: ".", dir: 'reports', subdir: '.', file: 'ng-coverage.lcov.info', reporters: [{ type: "lcovonly" }, { type: "text-summary" }], }, ``` #### JUnit report In order to be able to [integrate your test reports to GitLab](https://docs.gitlab.com/ee/ci/junit_test_reports.html), In order to be able to [integrate your test reports to GitLab](https://docs.gitlab.com/ee/ci/yaml/artifacts_reports.html#artifactsreportsjunit), the Angular template expects the following in your `karma.conf.js`. Add the [karma-junit-reporter](https://github.com/karma-runner/karma-junit-reporter) package as dev dependency: Loading @@ -102,10 +102,10 @@ In your `karma.conf.js`, add the plugin: Add the config section: ```js // [to be continuous]: karma-junit-reporter configuration (report needs to be in 'reports/junit_test_report.xml') // [to be continuous]: karma-junit-reporter configuration (report needs to be in 'reports/ng-test.xunit.xml') junitReporter: { outputDir: require('path').resolve('reports'), outputFile: 'junit_test_report.xml', outputDir: 'reports', outputFile: 'ng-test.xunit.xml', useBrowserName: false, ... } Loading @@ -131,9 +131,10 @@ In your `karma.conf.js`, add the plugin: Add the config section: ```js // [to be continuous]: karma-sonarqube-execution-reporter configuration (report needs to be in 'reports/ng-test.sonar.xml') sonarQubeExecutionReporter: { outputDir: require('path').resolve('reports'), outputFile: 'sonar_test_report.xml', outputDir: 'reports', outputFile: 'ng-test.sonar.xml', ... } ``` Loading @@ -152,7 +153,6 @@ This stage is bound to the `test` stage and uses the following variables : | Name | description | default value | |----------------------|------------------------------------------------------------|------------------------------------------| | `NG_E2E_ARGS` | Angular [ng e2e](https://angular.io/cli/e2e) arguments | `e2e` | | `NG_E2E_REPORT_PATH` | path where e2e reports are stored | `reports/e2e` | | `NG_E2E_ENABLED` | set to `true`to enable the e2e tests execution | *none (disabled by default)* | Implementation rely on the official [Angular CLI](https://cli.angular.io/) tool (`ng build` and `ng test` commands). Loading @@ -167,7 +167,8 @@ exports.config = { onPrepare() { jasmine.getEnv().addReporter(new JUnitXmlReporter({ consolidateAll: true, savePath: 'reports/e2e' savePath: 'reports', filePrefix: 'ng-e2e.xunit' })); } ... Loading Loading @@ -237,12 +238,12 @@ sonar.test.inclusions=**/*.spec.ts # tests report: generic format # set the path configured with karma-sonarqube-execution-reporter sonar.testExecutionReportPaths=reports/sonar_test_report.xml sonar.testExecutionReportPaths=reports/ng-test.sonar.xml # lint report: TSLint JSON sonar.typescript.tslint.reportPaths=reports/tslint-report.json sonar.typescript.tslint.reportPaths=reports/ng-lint.tslint.json # coverage report: LCOV format # set the path configured with karma-coverage-istanbul-reporter sonar.typescript.lcov.reportPaths=reports/lcov.info sonar.typescript.lcov.reportPaths=reports/ng-coverage.lcov.info ``` More info: Loading
kicker.json +0 −6 Original line number Diff line number Diff line Loading @@ -94,12 +94,6 @@ "description": "ng [e2e](https://angular.io/cli/e2e) arguments", "default": "e2e", "advanced": true }, { "name": "NG_E2E_REPORT_PATH", "description": "path where e2e reports are stored", "default": "reports/e2e", "advanced": true } ] } Loading
templates/gitlab-ci-angular.yml +7 −11 Original line number Diff line number Diff line Loading @@ -50,10 +50,6 @@ variables: # Default Docker image for ANGULAR CLI (can be overridden) NG_CLI_IMAGE: trion/ng-cli-karma:latest # JUnit test report NG_JUNIT_TEST_REPORT_PATH: "reports/junit_test_report.xml" NG_E2E_REPORT_PATH: "reports/e2e" # Angular lint NG_LINT_ARGS: "lint" Loading Loading @@ -133,10 +129,10 @@ stages: function sonar_lint_report() { if [[ -n "$SONAR_URL" ]] then mkdir -p reports mkdir -p -m 777 reports # generate ts lint report in json for SONARqube # shellcheck disable=SC2086 ng $NG_LINT_ARGS --format=json --force > reports/tslint-report.json ng $NG_LINT_ARGS --format=json --force > reports/ng-lint.tslint.json fi } Loading Loading @@ -474,13 +470,13 @@ ng-build: coverage: '/^Statements\s*:\s*([^%]+)/' artifacts: reports: junit: $NG_WORKSPACE_DIR/$NG_JUNIT_TEST_REPORT_PATH junit: - "$NG_WORKSPACE_DIR/reports/ng-test.xunit.xml" when: always # save artifact even if test failed name: "$CI_JOB_NAME artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG" paths: - $NG_WORKSPACE_DIR/coverage - $NG_WORKSPACE_DIR/dist - $NG_WORKSPACE_DIR/reports - $NG_WORKSPACE_DIR/reports/ng-*" expire_in: 1 day ############################################################################################### Loading @@ -494,11 +490,11 @@ ng-e2e: - ng $NG_E2E_ARGS artifacts: reports: junit: $NG_WORKSPACE_DIR/$NG_E2E_REPORT_PATH/junit*.xml junit: $NG_WORKSPACE_DIR/reports/ng-e2e.xunit.xml when: always # save artifact even if test failed name: "$CI_JOB_NAME artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG" paths: - $NG_WORKSPACE_DIR/$NG_E2E_REPORT_PATH - $NG_WORKSPACE_DIR/reports/ng-e2e.* expire_in: 1 day rules: # only run if feature is enabled Loading