Skip to content

Commit 8d0b2bb

Browse files
CI: improve ci and SonarQube for kfs kalisio/development#6
1 parent 47a26c7 commit 8d0b2bb

4 files changed

Lines changed: 34 additions & 15 deletions

File tree

.github/workflows/main.yaml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,31 @@
11
name: ci
2-
on: [ push, workflow_dispatch ]
2+
on:
3+
push:
4+
workflow_dispatch:
5+
inputs:
6+
build_service:
7+
description: "Build service"
8+
default: false
9+
required: false
10+
type: boolean
11+
run_tests:
12+
description: "Run tests"
13+
default: false
14+
required: false
15+
type: boolean
16+
additional_tests:
17+
description: "Additional tests"
18+
default: false
19+
required: false
20+
type: boolean
321

422
jobs:
523
run_tests:
624
name: Run tests
7-
if: ${{ !contains(github.event.head_commit.message, 'skip tests') }}
25+
if: ${{
26+
github.event_name == 'workflow_dispatch' && inputs.run_tests ||
27+
github.event_name == 'push' && !contains(github.event.head_commit.message, 'skip tests')
28+
}}
829
runs-on: ubuntu-22.04
930
steps:
1031
- name: Checkout repo
@@ -20,14 +41,14 @@ jobs:
2041
- name: Run tests
2142
env:
2243
SOPS_AGE_KEY: ${{ secrets.SOPS_AGE_KEY }}
23-
run: bash ./scripts/run_tests.sh -r ${{ github.job }}
44+
run: bash ./scripts/run_tests.sh -s -r ${{ github.job }}
2445

2546
additional_tests:
2647
strategy:
2748
fail-fast: false
2849
matrix:
29-
node: [ 22 ]
30-
mongo: [ 7 ]
50+
node: [ 20, 22 ]
51+
mongo: [ 7, 8 ]
3152
name: Additional tests
3253
if: ${{ contains(github.event.head_commit.message, 'additional tests') }}
3354
runs-on: ubuntu-22.04

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
[![Latest Release](https://img.shields.io/github/v/tag/kalisio/kfs?sort=semver&label=latest)](https://github.com/kalisio/kfs/releases)
44
[![CI](https://github.com/kalisio/kfs/actions/workflows/main.yaml/badge.svg)](https://github.com/kalisio/kfs/actions/workflows/main.yaml)
5-
[![Code Climate](https://codeclimate.com/github/kalisio/kfs/badges/gpa.svg)](https://codeclimate.com/github/kalisio/kfs)
6-
[![Test Coverage](https://codeclimate.com/github/kalisio/kfs/badges/coverage.svg)](https://codeclimate.com/github/kalisio/kfs/coverage)
5+
[![Maintainability Issues](https://sonar.portal.kalisio.com/api/project_badges/measure?project=kalisio-kfs&metric=software_quality_maintainability_issues&token=sqb_3e3da8c91abe98896640284af9eb2a3672897d94)](https://sonar.portal.kalisio.com/dashboard?id=kalisio-kfs)
6+
[![Coverage](https://sonar.portal.kalisio.com/api/project_badges/measure?project=kalisio-kfs&metric=coverage&token=sqb_3e3da8c91abe98896640284af9eb2a3672897d94)](https://sonar.portal.kalisio.com/dashboard?id=kalisio-kfs)
77
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
88

99
**Kalisio Features Service**

scripts/init_runner.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ init_github_run_tests() {
1616
}
1717

1818
init_github_additional_tests() {
19-
install_reqs age sops nvm node22 mongo7
19+
install_reqs age sops nvm node20 node22 mongo7 mongo8
2020
}
2121

2222
init_github_build_service() {

scripts/run_tests.sh

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ WORKSPACE_DIR="$(dirname "$ROOT_DIR")"
1515
NODE_VER=20
1616
MONGO_VER=7
1717
CI_STEP_NAME="Run tests"
18-
CODE_COVERAGE=false
19-
while getopts "m:n:cr:" option; do
18+
RUN_SONAR=false
19+
while getopts "m:n:sr:" option; do
2020
case $option in
2121
m) # defines mongo version
2222
MONGO_VER=$OPTARG
2323
;;
2424
n) # defines node version
2525
NODE_VER=$OPTARG
2626
;;
27-
c) # publish code coverage
28-
CODE_COVERAGE=true
27+
s) # enable SonarQube analysis and publish code quality & coverage results
28+
RUN_SONAR=true
2929
;;
3030
r) # report outcome to slack
3131
load_env_files "$WORKSPACE_DIR/development/common/SLACK_WEBHOOK_SERVICES.enc.env"
@@ -45,6 +45,4 @@ done
4545
## Run tests
4646
##
4747

48-
run_lib_tests "$ROOT_DIR" "$CODE_COVERAGE" "$NODE_VER" "$MONGO_VER"
49-
50-
cd "$ROOT_DIR" && sonar-scanner
48+
run_lib_tests "$ROOT_DIR" "$RUN_SONAR" "$NODE_VER" "$MONGO_VER"

0 commit comments

Comments
 (0)