ci: streamline test environment deployments
This commit is contained in:
+8
-1
@@ -110,7 +110,14 @@ pipeline {
|
||||
stage('Maven 测试与打包') {
|
||||
steps {
|
||||
script {
|
||||
String testOption = params.SKIP_TESTS ? '-DskipTests' : ''
|
||||
if (params.ENVIRONMENT == 'production' && params.SKIP_TESTS) {
|
||||
error('生产环境禁止跳过测试')
|
||||
}
|
||||
boolean skipTestExecution = params.ENVIRONMENT == 'test' || params.SKIP_TESTS
|
||||
String testOption = skipTestExecution ? '-DskipTests' : ''
|
||||
if (params.ENVIRONMENT == 'test') {
|
||||
echo '测试环境快速部署:编译主代码和测试代码,但不重复执行单元测试;完整测试由提交门禁和预发布执行'
|
||||
}
|
||||
sh "mvn --settings ${env.MAVEN_SETTINGS} --batch-mode --errors -pl ${env.RESOLVED_SERVICE} -am clean package ${testOption}"
|
||||
}
|
||||
}
|
||||
|
||||
+7
-2
@@ -43,14 +43,19 @@ class FulfillmentTaskControllerContractTest {
|
||||
void shouldDocumentFourReadOnlyEndpointsInOpenApi() throws Exception {
|
||||
String openapi = new ClassPathResource("openapi/firstleg-v1.yaml")
|
||||
.getContentAsString(StandardCharsets.UTF_8);
|
||||
assertThat(openapi)
|
||||
int taskPathsStart = openapi.indexOf(" /api/platform/v1/first-leg/tasks:");
|
||||
int nextResourceStart = openapi.indexOf(" /api/platform/v1/containers:", taskPathsStart);
|
||||
assertThat(taskPathsStart).isGreaterThanOrEqualTo(0);
|
||||
assertThat(nextResourceStart).isGreaterThan(taskPathsStart);
|
||||
assertThat(openapi).contains("仅响应体 code 为字符串 \"200\" 时表示成功");
|
||||
String taskPaths = openapi.substring(taskPathsStart, nextResourceStart);
|
||||
assertThat(taskPaths)
|
||||
.contains("/api/platform/v1/first-leg/tasks:")
|
||||
.contains("/api/platform/v1/first-leg/tasks/{taskId}:")
|
||||
.contains("/api/platform/v1/first-leg/tasks/by-order/{orderId}:")
|
||||
.contains("/api/platform/v1/first-leg/tasks/{taskId}/assignment-history:")
|
||||
.contains("platform:firstleg:task:list")
|
||||
.contains("platform:firstleg:assignment:history")
|
||||
.contains("仅响应体 code 为字符串 \"200\" 时表示成功")
|
||||
.doesNotContain("'404':")
|
||||
.doesNotContain("'409':");
|
||||
}
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ class InboundCartonLabelSqlContractTest {
|
||||
|
||||
assertThat(schema).contains("CREATE TABLE IF NOT EXISTS fl_inbound_carton_label")
|
||||
.contains("UNIQUE KEY uk_carton_label_box_code (tenant_id, box_code)")
|
||||
.contains("UNIQUE KEY uk_carton_label_index (tenant_id, inbound_id, carton_index)")
|
||||
.contains("UNIQUE KEY uk_carton_label_index (tenant_id, inbound_id, label_version, carton_index)")
|
||||
.contains("inbound_detail_id BIGINT UNSIGNED NOT NULL");
|
||||
assertThat(migration).contains("CREATE TABLE IF NOT EXISTS fl_inbound_carton_label")
|
||||
.contains("固定二维码内容:入仓码#总箱数-箱下标")
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
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')
|
||||
|
||||
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\('生产环境禁止跳过测试'\)/)
|
||||
})
|
||||
Reference in New Issue
Block a user