fixing CI. adding coverage information.

This commit is contained in:
Jason Kulatunga 2022-10-14 08:51:34 -07:00
parent 50d4ff35de
commit 4d04e17280
6 changed files with 106 additions and 51 deletions

View File

@ -12,15 +12,13 @@ jobs:
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Test Frontend - name: Test Frontend
run: | run: |
cd frontend make frontend-test-coverage
yarn install --frozen-lockfile - name: Upload coverage
yarn run build -- --output-path=../dist uses: actions/upload-artifact@v3
# - name: Upload coverage with:
# uses: actions/upload-artifact@v3 name: coverage
# with: path: ${{ github.workspace }}/frontend/coverage/fastenhealth/lcov.info
# name: coverage retention-days: 1
# path: ${{ github.workspace }}/frontend/coverage/lcov.info
# retention-days: 1
test-backend: test-backend:
name: Test Backend name: Test Backend
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -32,37 +30,33 @@ jobs:
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Test Backend - name: Test Backend
run: | run: |
go mod vendor
go install github.com/golang/mock/mockgen@v1.6.0 go install github.com/golang/mock/mockgen@v1.6.0
go generate ./... go generate ./...
go vet ./... make backend-test-coverage
go test ./...
CGO_ENABLED=0 go build ./backend/cmd/fasten/ CGO_ENABLED=0 go build ./backend/cmd/fasten/
- name: Upload coverage
uses: actions/upload-artifact@v3
# - name: Upload coverage with:
# uses: actions/upload-artifact@v3 name: coverage
# with: path: ${{ github.workspace }}/backend-coverage.txt
# name: coverage retention-days: 1
# path: ${{ github.workspace }}/coverage.txt test-coverage:
# retention-days: 1 name: Test Coverage Upload
# test-coverage: needs:
# name: Test Coverage Upload - test-backend
# needs: - test-frontend
# - test-backend runs-on: ubuntu-latest
# - test-frontend steps:
# runs-on: ubuntu-latest - name: Checkout
# steps: uses: actions/checkout@v2
# - name: Checkout - name: Download coverage reports
# uses: actions/checkout@v2 uses: actions/download-artifact@v3
# - name: Download coverage reports with:
# uses: actions/download-artifact@v3 name: coverage
# with: - name: Upload coverage reports
# name: coverage uses: codecov/codecov-action@v2
# - name: Upload coverage reports with:
# uses: codecov/codecov-action@v2 files: ${{ github.workspace }}/backend-coverage.txt,${{ github.workspace }}/lcov.info
# with: flags: unittests
# files: ${{ github.workspace }}/coverage.txt,${{ github.workspace }}/lcov.info fail_ci_if_error: true
# flags: unittests verbose: true
# fail_ci_if_error: true
# verbose: true

View File

@ -41,3 +41,8 @@ frontend-dep:
# reduce logging, disable angular-cli analytics for ci environment # reduce logging, disable angular-cli analytics for ci environment
frontend-test: frontend-dep frontend-test: frontend-dep
cd frontend && ng test --watch=false cd frontend && ng test --watch=false
.PHONY: frontend-test-coverage
# reduce logging, disable angular-cli analytics for ci environment
frontend-test-coverage: frontend-dep
cd frontend && ng test --watch=false --code-coverage

View File

@ -115,6 +115,7 @@
"test": { "test": {
"builder": "@angular-devkit/build-angular:karma", "builder": "@angular-devkit/build-angular:karma",
"options": { "options": {
"codeCoverage": true,
"main": "src/test.ts", "main": "src/test.ts",
"polyfills": "src/polyfills.ts", "polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json", "tsConfig": "tsconfig.spec.json",

View File

@ -1,7 +1,5 @@
// Karma configuration file, see link for more information // karma.conf.js
// https://karma-runner.github.io/1.0/config/configuration-file.html module.exports = function(config) {
module.exports = function (config) {
config.set({ config.set({
basePath: '', basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'], frameworks: ['jasmine', '@angular-devkit/build-angular'],
@ -9,18 +7,41 @@ module.exports = function (config) {
require('karma-jasmine'), require('karma-jasmine'),
require('karma-chrome-launcher'), require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'), require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'), require('karma-coverage'),
require('@angular-devkit/build-angular/plugins/karma') require('@angular-devkit/build-angular/plugins/karma')
], ],
client: { client: {
jasmine: {
// you can add configuration options for Jasmine here
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
// for example, you can disable the random execution with `random: false`
// or set a specific seed with `seed: 4321`
},
clearContext: false // leave Jasmine Spec Runner output visible in browser clearContext: false // leave Jasmine Spec Runner output visible in browser
}, },
coverageIstanbulReporter: { jasmineHtmlReporter: {
dir: require('path').join(__dirname, './coverage/fasten'), suppressAll: true // removes the duplicated traces
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
}, },
reporters: ['progress', 'kjhtml'], coverageReporter: {
dir: require('path').join(__dirname, './coverage/fastenhealth'),
subdir: '.',
reporters: [
{ type: 'html' },
{ type: 'text-summary' },
{ type: 'lcovonly' }
],
check: {
global: {
statements: 80,
branches: 80,
functions: 80,
lines: 80
}
}
},
// coverage reporter generates the coverage
reporters: ['progress', 'coverage'],
port: 9876, port: 9876,
colors: true, colors: true,
logLevel: config.LOG_INFO, logLevel: config.LOG_INFO,
@ -28,5 +49,6 @@ module.exports = function (config) {
browsers: ['Chrome'], browsers: ['Chrome'],
singleRun: false, singleRun: false,
restartOnFileChange: true restartOnFileChange: true
}); });
}; };

View File

@ -64,6 +64,7 @@
"jasmine-spec-reporter": "~5.0.0", "jasmine-spec-reporter": "~5.0.0",
"karma": "~6.4.0", "karma": "~6.4.0",
"karma-chrome-launcher": "~3.1.0", "karma-chrome-launcher": "~3.1.0",
"karma-coverage": "^2.2.0",
"karma-coverage-istanbul-reporter": "~3.0.2", "karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0", "karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0", "karma-jasmine-html-reporter": "^1.5.0",

View File

@ -5001,6 +5001,17 @@ istanbul-lib-instrument@^5.0.4:
istanbul-lib-coverage "^3.2.0" istanbul-lib-coverage "^3.2.0"
semver "^6.3.0" semver "^6.3.0"
istanbul-lib-instrument@^5.1.0:
version "5.2.1"
resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-5.2.1.tgz#d10c8885c2125574e1c231cacadf955675e1ce3d"
integrity sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg==
dependencies:
"@babel/core" "^7.12.3"
"@babel/parser" "^7.14.7"
"@istanbuljs/schema" "^0.1.2"
istanbul-lib-coverage "^3.2.0"
semver "^6.3.0"
istanbul-lib-report@^3.0.0: istanbul-lib-report@^3.0.0:
version "3.0.0" version "3.0.0"
resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz#7518fe52ea44de372f460a76b5ecda9ffb73d8a6" resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz#7518fe52ea44de372f460a76b5ecda9ffb73d8a6"
@ -5021,7 +5032,16 @@ istanbul-lib-source-maps@^3.0.6:
rimraf "^2.6.3" rimraf "^2.6.3"
source-map "^0.6.1" source-map "^0.6.1"
istanbul-reports@^3.0.2: istanbul-lib-source-maps@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz#895f3a709fcfba34c6de5a42939022f3e4358551"
integrity sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==
dependencies:
debug "^4.1.1"
istanbul-lib-coverage "^3.0.0"
source-map "^0.6.1"
istanbul-reports@^3.0.2, istanbul-reports@^3.0.5:
version "3.1.5" version "3.1.5"
resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-3.1.5.tgz#cc9a6ab25cb25659810e4785ed9d9fb742578bae" resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-3.1.5.tgz#cc9a6ab25cb25659810e4785ed9d9fb742578bae"
integrity sha512-nUsEMa9pBt/NOHqbcbeJEgqIlY/K7rVWUX6Lql2orY5e9roQOthbR3vtY4zzf2orPELg80fnxxk9zUyPlgwD1w== integrity sha512-nUsEMa9pBt/NOHqbcbeJEgqIlY/K7rVWUX6Lql2orY5e9roQOthbR3vtY4zzf2orPELg80fnxxk9zUyPlgwD1w==
@ -5211,6 +5231,18 @@ karma-coverage-istanbul-reporter@~3.0.2:
istanbul-reports "^3.0.2" istanbul-reports "^3.0.2"
minimatch "^3.0.4" minimatch "^3.0.4"
karma-coverage@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/karma-coverage/-/karma-coverage-2.2.0.tgz#64f838b66b71327802e7f6f6c39d569b7024e40c"
integrity sha512-gPVdoZBNDZ08UCzdMHHhEImKrw1+PAOQOIiffv1YsvxFhBjqvo/SVXNk4tqn1SYqX0BJZT6S/59zgxiBe+9OuA==
dependencies:
istanbul-lib-coverage "^3.2.0"
istanbul-lib-instrument "^5.1.0"
istanbul-lib-report "^3.0.0"
istanbul-lib-source-maps "^4.0.1"
istanbul-reports "^3.0.5"
minimatch "^3.0.4"
karma-jasmine-html-reporter@^1.5.0: karma-jasmine-html-reporter@^1.5.0:
version "1.7.0" version "1.7.0"
resolved "https://registry.yarnpkg.com/karma-jasmine-html-reporter/-/karma-jasmine-html-reporter-1.7.0.tgz#52c489a74d760934a1089bfa5ea4a8fcb84cc28b" resolved "https://registry.yarnpkg.com/karma-jasmine-html-reporter/-/karma-jasmine-html-reporter-1.7.0.tgz#52c489a74d760934a1089bfa5ea4a8fcb84cc28b"