36 lines
1.7 KiB
JavaScript
36 lines
1.7 KiB
JavaScript
import assert from 'node:assert/strict'
|
|
import { readFile } from 'node:fs/promises'
|
|
import test from 'node:test'
|
|
|
|
const pipeline = (await readFile(new URL('../Jenkinsfile.service', import.meta.url), 'utf8'))
|
|
.replaceAll('\r\n', '\n')
|
|
const deployScript = (await readFile(new URL('../deploy/scripts/deploy-services.sh', import.meta.url), 'utf8'))
|
|
.replaceAll('\r\n', '\n')
|
|
const ciMavenSettings = (await readFile(new URL('../deploy/maven/settings-ci.xml', import.meta.url), 'utf8'))
|
|
.replaceAll('\r\n', '\n')
|
|
|
|
test('test deployments compile packages without rerunning the full unit test suite', () => {
|
|
assert.match(pipeline, /params\.ENVIRONMENT == 'test' \|\| params\.SKIP_TESTS/)
|
|
assert.match(pipeline, /skipTestExecution \? '-DskipTests' : ''/)
|
|
assert.match(pipeline, /-pl \$\{env\.RESOLVED_SERVICE\} -am clean package/)
|
|
assert.doesNotMatch(pipeline, /-Dmaven\.test\.skip=true/)
|
|
})
|
|
|
|
test('production deployments cannot skip tests', () => {
|
|
assert.match(pipeline, /params\.ENVIRONMENT == 'production' && params\.SKIP_TESTS/)
|
|
assert.match(pipeline, /error\('生产环境禁止跳过测试'\)/)
|
|
})
|
|
|
|
test('Java builds use the shared builder pool and deploy on the target environment node', () => {
|
|
assert.match(pipeline, /agent \{ label 'java-builder' \}/)
|
|
assert.match(pipeline, /params\.ENVIRONMENT == 'development' \? 'java-dev' : 'master'/)
|
|
assert.match(pipeline, /docker push \$\{image\}/)
|
|
assert.match(deployScript, /pull \$SERVICES/)
|
|
})
|
|
|
|
test('shared builders use a reachable public Maven mirror instead of the retired private proxy', () => {
|
|
assert.match(pipeline, /MAVEN_SETTINGS = 'deploy\/maven\/settings-ci\.xml'/)
|
|
assert.match(ciMavenSettings, /https:\/\/maven\.aliyun\.com\/repository\/public/)
|
|
assert.doesNotMatch(ciMavenSettings, /:18081/)
|
|
})
|