Files
baiyue-firstleg/scripts/test-environment-pipeline-contract.test.mjs
T

37 lines
1.8 KiB
JavaScript
Raw Normal View History

2026-08-13 17:40:55 +08:00
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')
2026-08-20 12:49:54 +08:00
const directDeployScript = (await readFile(new URL('../deploy/scripts/deploy-built-service.sh', import.meta.url), 'utf8'))
2026-08-20 10:22:51 +08:00
.replaceAll('\r\n', '\n')
2026-08-20 10:28:45 +08:00
const ciMavenSettings = (await readFile(new URL('../deploy/maven/settings-ci.xml', import.meta.url), 'utf8'))
.replaceAll('\r\n', '\n')
2026-08-13 17:40:55 +08:00
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\('生产环境禁止跳过测试'\)/)
})
2026-08-20 10:22:51 +08:00
test('Java builds use the shared builder pool and deploy on the target environment node', () => {
assert.match(pipeline, /agent \{ label 'java-builder' \}/)
2026-08-20 12:34:10 +08:00
assert.match(pipeline, /\['development', 'test'\]\.contains\(params\.ENVIRONMENT\)/)
2026-08-20 12:49:54 +08:00
assert.match(pipeline, /deploy-built-service\.sh/)
assert.match(directDeployScript, /docker save "\$IMAGE" \| gzip -1 \| run_ssh/)
assert.match(directDeployScript, /--pull never/)
2026-08-20 10:22:51 +08:00
})
2026-08-20 10:28:45 +08:00
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/)
})