feat: split Install/UnitTest stages, add game.js tests with 100% coverage
21 tests covering win/loss/draw/score/reset. lcov report fed to SonarQube. Pipeline: Install → Unit Test → Scan Code Quality → Build & Push. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
51
Jenkinsfile
vendored
51
Jenkinsfile
vendored
@@ -3,12 +3,26 @@
|
||||
import vn.fireflylab.pipeline.BranchStrategy
|
||||
|
||||
// ── Stage functions ────────────────────────────────────────────────
|
||||
def executeInstallTest() {
|
||||
stage('Install & Test') {
|
||||
def executeInstall() {
|
||||
stage('Install') {
|
||||
container('node') { runNodeInstall() }
|
||||
}
|
||||
}
|
||||
|
||||
def executeUnitTest() {
|
||||
stage('Unit Test') {
|
||||
container('node') { runNodeTest() }
|
||||
}
|
||||
}
|
||||
|
||||
def executeScanCodeQuality() {
|
||||
stage('Scan Code Quality') {
|
||||
container('sonar') {
|
||||
scanCodeQuality(projectKey: 'tictactoe')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def executeBuildPush() {
|
||||
stage('Build & Push') {
|
||||
container('docker') {
|
||||
@@ -19,14 +33,6 @@ def executeBuildPush() {
|
||||
}
|
||||
}
|
||||
|
||||
def executeScanCodeQuality() {
|
||||
stage('Scan Code Quality') {
|
||||
container('sonar') {
|
||||
scanCodeQuality(projectKey: 'tictactoe')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def executeBumpChart() {
|
||||
stage('Bump Helm Chart') {
|
||||
container('tools') {
|
||||
@@ -40,41 +46,54 @@ def executeBumpChart() {
|
||||
}
|
||||
|
||||
// ── Pipeline ───────────────────────────────────────────────────────
|
||||
// PR-* → install + test
|
||||
// feature/* → install + test + scan + build + push
|
||||
// develop → install + test + scan + build + push
|
||||
// main → install + test + scan + build + push
|
||||
// release/x.y.z → install + test + scan + build + push
|
||||
// hotfix/* → install + test + scan + build + push
|
||||
|
||||
podTemplate(yaml: homelabK8sAgent(withTools: true, withSonar: true)) {
|
||||
node(POD_LABEL) {
|
||||
withEnv(['DOCKER_HOST=tcp://localhost:2375']) {
|
||||
checkout scm
|
||||
|
||||
BranchStrategy.prStrategy(env.BRANCH_NAME) {
|
||||
executeInstallTest()
|
||||
executeInstall()
|
||||
executeUnitTest()
|
||||
}
|
||||
|
||||
BranchStrategy.featureStrategy(env.BRANCH_NAME) {
|
||||
executeInstallTest()
|
||||
executeInstall()
|
||||
executeUnitTest()
|
||||
executeScanCodeQuality()
|
||||
executeBuildPush()
|
||||
}
|
||||
|
||||
BranchStrategy.developStrategy(env.BRANCH_NAME) {
|
||||
executeInstallTest()
|
||||
executeInstall()
|
||||
executeUnitTest()
|
||||
executeScanCodeQuality()
|
||||
executeBuildPush()
|
||||
}
|
||||
|
||||
BranchStrategy.mainStrategy(env.BRANCH_NAME) {
|
||||
executeInstallTest()
|
||||
executeInstall()
|
||||
executeUnitTest()
|
||||
executeScanCodeQuality()
|
||||
executeBuildPush()
|
||||
}
|
||||
|
||||
BranchStrategy.releaseStrategy(env.BRANCH_NAME) {
|
||||
executeInstallTest()
|
||||
executeInstall()
|
||||
executeUnitTest()
|
||||
executeScanCodeQuality()
|
||||
executeBuildPush()
|
||||
}
|
||||
|
||||
BranchStrategy.hotfixStrategy(env.BRANCH_NAME) {
|
||||
executeInstallTest()
|
||||
executeInstall()
|
||||
executeUnitTest()
|
||||
executeScanCodeQuality()
|
||||
executeBuildPush()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user