Add separate build and test stages.

This commit is contained in:
Spencer Ofwiti 2020-11-25 17:58:36 +03:00
parent 987f8edebe
commit 0745c3089d
3 changed files with 53 additions and 5 deletions

View File

@ -1,11 +1,14 @@
stages: stages:
- install - install
- build_and_test - build_and_test
- build
- test
variables: variables:
PROJECT_PATH: "$CI_PROJECT_DIR" PROJECT_PATH: "$CI_PROJECT_DIR"
APP_OUTPUT_PATH: "$CI_PROJECT_DIR/artifacts/app" APP_OUTPUT_PATH: "$CI_PROJECT_DIR/dist/cic-staff-client"
OUTPUT_PATH: "$CI_PROJECT_DIR/artifacts" OUTPUT_PATH: "$CI_PROJECT_DIR/dist"
CLI_VERSION: 10.2.0
install_dependencies: install_dependencies:
stage: install stage: install
@ -41,6 +44,7 @@ build_app:
- cp $PROJECT_PATH/Dockerfile $APP_OUTPUT_PATH - cp $PROJECT_PATH/Dockerfile $APP_OUTPUT_PATH
artifacts: artifacts:
name: "cic-staff-client-pipeline" name: "cic-staff-client-pipeline"
expire_in: 30 days
paths: paths:
- $APP_OUTPUT_PATH - $APP_OUTPUT_PATH
cache: cache:
@ -77,3 +81,47 @@ test_app:
paths: paths:
- node_modules - node_modules
policy: pull policy: pull
build:
stage: build
image: trion/ng-cli
tags:
- docker
before_script:
- npm ci
script:
- ng build --prod
artifacts:
expire_in: 1 days
paths:
- dist/cic-staff-client
test:karma:
stage: test
image: trion/ng-cli-karma:$(CLI_VERSION)
allow_failure: false
tags:
- docker
script:
- ng test --code-coverage --progress false --watch false
coverage: '/Lines \W+: (\d+\.\d+)%.*/'
artifacts:
paths:
- coverage/
test:e2e:
stage: test
image: trion/ng-cli-e2e:$(CLI_VERSION)
allow_failure: false
tags:
- docker
script:
- ng e2e
test:nglint:
stage: test
image: trion/ng-cli:$(CLI_VERSION)
tags:
- docker
script:
- ng lint

View File

@ -17,7 +17,7 @@
"build": { "build": {
"builder": "@angular-devkit/build-angular:browser", "builder": "@angular-devkit/build-angular:browser",
"options": { "options": {
"outputPath": "artifacts/app", "outputPath": "dist/cic-staff-client",
"index": "src/index.html", "index": "src/index.html",
"main": "src/main.ts", "main": "src/main.ts",
"polyfills": "src/polyfills.ts", "polyfills": "src/polyfills.ts",

View File

@ -17,7 +17,7 @@ module.exports = function (config) {
clearContext: false // leave Jasmine Spec Runner output visible in browser clearContext: false // leave Jasmine Spec Runner output visible in browser
}, },
coverageIstanbulReporter: { coverageIstanbulReporter: {
dir: require('path').join(__dirname, './artifacts/coverage'), dir: require('path').join(__dirname, './coverage/cic-staff-client'),
reports: ['html', 'lcovonly', 'text-summary', 'cobertura'], reports: ['html', 'lcovonly', 'text-summary', 'cobertura'],
fixWebpackSourcePaths: true, fixWebpackSourcePaths: true,
'report-config': { 'report-config': {
@ -27,7 +27,7 @@ module.exports = function (config) {
}, },
}, },
junitReporter: { junitReporter: {
outputDir: 'artifacts/tests', outputDir: require('path').join(__dirname, './tests/cic-staff-client'),
outputFile: 'junit-test-results.xml', outputFile: 'junit-test-results.xml',
useBrowserName: false useBrowserName: false
}, },