Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Angular
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
to be continuous...
Angular
Commits
1f80fc9c
Commit
1f80fc9c
authored
2 years ago
by
Pierre Smeyers
Browse files
Options
Downloads
Patches
Plain Diff
feat: normalize reports
parent
831204f5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+16
-15
16 additions, 15 deletions
README.md
kicker.json
+0
-6
0 additions, 6 deletions
kicker.json
templates/gitlab-ci-angular.yml
+7
-11
7 additions, 11 deletions
templates/gitlab-ci-angular.yml
with
23 additions
and
32 deletions
README.md
+
16
−
15
View file @
1f80fc9c
...
...
@@ -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).
...
...
@@ -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:
...
...
@@ -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_repor
t.xml')
// [to be continuous]: karma-junit-reporter configuration (report needs to be in 'reports/
ng-test.xuni
t.xml')
junitReporter
:
{
outputDir
:
require
(
'
path
'
).
resolve
(
'
reports
'
)
,
outputFile
:
'
junit_test_repor
t.xml
'
,
outputDir
:
'
reports
'
,
outputFile
:
'
ng-test.xuni
t.xml
'
,
useBrowserName
:
false
,
...
}
...
...
@@ -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
'
,
...
}
```
...
...
@@ -152,8 +153,7 @@ 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)*
|
|
`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).
...
...
@@ -167,7 +167,8 @@ exports.config = {
onPrepare
()
{
jasmine
.
getEnv
().
addReporter
(
new
JUnitXmlReporter
({
consolidateAll
:
true
,
savePath
:
'
reports/e2e
'
savePath
:
'
reports
'
,
filePrefix
:
'
ng-e2e.xunit
'
}));
}
...
...
...
@@ -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-repor
t.json
sonar.typescript.tslint.reportPaths
=
reports/
ng-lint.tslin
t.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:
...
...
This diff is collapsed.
Click to expand it.
kicker.json
+
0
−
6
View file @
1f80fc9c
...
...
@@ -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
}
]
}
...
...
This diff is collapsed.
Click to expand it.
templates/gitlab-ci-angular.yml
+
7
−
11
View file @
1f80fc9c
...
...
@@ -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"
...
...
@@ -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-repor
t.json
ng $NG_LINT_ARGS --format=json --force > reports/
ng-lint.tslin
t.json
fi
}
...
...
@@ -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
###############################################################################################
...
...
@@ -494,11 +490,11 @@ ng-e2e:
-
ng $NG_E2E_ARGS
artifacts
:
reports
:
junit
:
$NG_WORKSPACE_DIR/
$NG_E2E_REPORT_PATH/j
unit
*
.xml
junit
:
$NG_WORKSPACE_DIR/
reports/ng-e2e.x
unit.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
...
...
This diff is collapsed.
Click to expand it.
Ghost User
@ghost
mentioned in commit
f70ec8b1
·
2 years ago
mentioned in commit
f70ec8b1
mentioned in commit f70ec8b195a2f0a5ae1cca6a9cf354363494b3bd
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment