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

View File

@ -41,3 +41,8 @@ frontend-dep:
# reduce logging, disable angular-cli analytics for ci environment
frontend-test: frontend-dep
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": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"codeCoverage": true,
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",

View File

@ -1,7 +1,5 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
// karma.conf.js
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
@ -9,18 +7,41 @@ module.exports = function (config) {
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('karma-coverage'),
require('@angular-devkit/build-angular/plugins/karma')
],
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
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, './coverage/fasten'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
jasmineHtmlReporter: {
suppressAll: true // removes the duplicated traces
},
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,
colors: true,
logLevel: config.LOG_INFO,
@ -28,5 +49,6 @@ module.exports = function (config) {
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true
});
};

View File

@ -64,6 +64,7 @@
"jasmine-spec-reporter": "~5.0.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "^2.2.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.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"
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:
version "3.0.0"
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"
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"
resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-3.1.5.tgz#cc9a6ab25cb25659810e4785ed9d9fb742578bae"
integrity sha512-nUsEMa9pBt/NOHqbcbeJEgqIlY/K7rVWUX6Lql2orY5e9roQOthbR3vtY4zzf2orPELg80fnxxk9zUyPlgwD1w==
@ -5211,6 +5231,18 @@ karma-coverage-istanbul-reporter@~3.0.2:
istanbul-reports "^3.0.2"
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:
version "1.7.0"
resolved "https://registry.yarnpkg.com/karma-jasmine-html-reporter/-/karma-jasmine-html-reporter-1.7.0.tgz#52c489a74d760934a1089bfa5ea4a8fcb84cc28b"