haven-cypress-integration 1.1.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -8
- package/bin/haven-cypress.js +8 -3
- package/index.js +17 -3
- package/package.json +1 -1
- package/templates/syncCypressResults.js +16 -4
package/README.md
CHANGED
|
@@ -64,19 +64,33 @@ npx haven-cypress run --automationIds=TC-AUTO-123,TC-AUTO-124
|
|
|
64
64
|
```
|
|
65
65
|
|
|
66
66
|
### ECR Image Organization
|
|
67
|
-
Images are organized in the `haven-test-images` ECR repository with product-based
|
|
67
|
+
Images are organized in the `haven-test-images` ECR repository with product-based versioning:
|
|
68
68
|
```
|
|
69
69
|
Repository: haven-test-images
|
|
70
|
-
├── BE-latest
|
|
71
|
-
├── BE-
|
|
72
|
-
├──
|
|
73
|
-
└──
|
|
70
|
+
├── BE-v1.0.123456 (latest with build number)
|
|
71
|
+
├── BE-v2.1.0 (semantic version)
|
|
72
|
+
├── payments-v1.0.789012
|
|
73
|
+
└── auth-v3.0.0
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
-
**Tag Format**: `{PRODUCT}-{VERSION}
|
|
76
|
+
**Tag Format**: `{PRODUCT}-{VERSION}`
|
|
77
77
|
- **Product**: Organizes images by product/team
|
|
78
|
-
- **Version**: `
|
|
79
|
-
|
|
78
|
+
- **Version**: Semantic versioning (e.g., `v2.1.0`) or build numbers (e.g., `v1.0.123456`)
|
|
79
|
+
|
|
80
|
+
### Versioning Examples
|
|
81
|
+
```bash
|
|
82
|
+
# Build with auto-generated build number
|
|
83
|
+
npx haven-cypress build --product=BE --push
|
|
84
|
+
→ ECR tag: BE-v1.0.123456
|
|
85
|
+
|
|
86
|
+
# Build with semantic version
|
|
87
|
+
npx haven-cypress build --product=BE --tag=v2.1.0 --push
|
|
88
|
+
→ ECR tag: BE-v2.1.0
|
|
89
|
+
|
|
90
|
+
# Build with custom build number (CI/CD)
|
|
91
|
+
BUILD_NUMBER=456 npx haven-cypress build --product=BE --push
|
|
92
|
+
→ ECR tag: BE-v1.0.456
|
|
93
|
+
```
|
|
80
94
|
|
|
81
95
|
## What's Included
|
|
82
96
|
|
package/bin/haven-cypress.js
CHANGED
|
@@ -22,10 +22,15 @@ Options:
|
|
|
22
22
|
--automationIds=ID1,ID2 Run specific test cases
|
|
23
23
|
|
|
24
24
|
Examples:
|
|
25
|
-
npx haven-cypress build --product=
|
|
26
|
-
npx haven-cypress build --product=
|
|
27
|
-
npx haven-cypress build --product=
|
|
25
|
+
npx haven-cypress build --product=BE
|
|
26
|
+
npx haven-cypress build --product=BE --push
|
|
27
|
+
npx haven-cypress build --product=BE --tag=v2.1.0 --push
|
|
28
28
|
npx haven-cypress run --automationIds=TC-AUTO-123,TC-AUTO-124
|
|
29
|
+
|
|
30
|
+
Versioning:
|
|
31
|
+
--tag=latest → ECR tag: BE-v1.0.{BUILD_NUMBER}
|
|
32
|
+
--tag=v2.1.0 → ECR tag: BE-v2.1.0
|
|
33
|
+
BUILD_NUMBER env → Custom build number (default: timestamp)
|
|
29
34
|
`);
|
|
30
35
|
process.exit(1);
|
|
31
36
|
}
|
package/index.js
CHANGED
|
@@ -151,8 +151,21 @@ class HavenCypressIntegration {
|
|
|
151
151
|
// ECR repository and image details
|
|
152
152
|
const ecrRepo = 'haven-test-images';
|
|
153
153
|
const ecrUri = `${accountId}.dkr.ecr.${region}.amazonaws.com/${ecrRepo}`;
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
|
|
155
|
+
// Extract version from local tag or use 'latest'
|
|
156
|
+
const localVersion = localTag.split(':')[1] || 'latest';
|
|
157
|
+
|
|
158
|
+
// Generate ECR tag with product and version
|
|
159
|
+
let ecrTag;
|
|
160
|
+
if (localVersion === 'latest') {
|
|
161
|
+
// For 'latest', use build number format: product-v1.0.BUILD_NUMBER
|
|
162
|
+
const buildNumber = process.env.BUILD_NUMBER || Date.now().toString().slice(-6);
|
|
163
|
+
ecrTag = `${product}-v1.0.${buildNumber}`;
|
|
164
|
+
} else {
|
|
165
|
+
// For custom versions, use: product-VERSION
|
|
166
|
+
ecrTag = `${product}-${localVersion}`;
|
|
167
|
+
}
|
|
168
|
+
|
|
156
169
|
const fullEcrUri = `${ecrUri}:${ecrTag}`;
|
|
157
170
|
|
|
158
171
|
console.log(`🏷️ ECR tag: ${ecrTag}`);
|
|
@@ -172,7 +185,8 @@ class HavenCypressIntegration {
|
|
|
172
185
|
|
|
173
186
|
console.log(`✅ Image pushed successfully!`);
|
|
174
187
|
console.log(`📍 ECR URI: ${fullEcrUri}`);
|
|
175
|
-
console.log(`🗂️ Product
|
|
188
|
+
console.log(`🗂️ Product: ${product}`);
|
|
189
|
+
console.log(`🏷️ Version: ${ecrTag}`);
|
|
176
190
|
|
|
177
191
|
} catch (error) {
|
|
178
192
|
console.error(`❌ Failed to push to ECR: ${error.message}`);
|
package/package.json
CHANGED
|
@@ -13,8 +13,19 @@ const bucketName = process.env.S3_BUCKET || "your-bucket-name";
|
|
|
13
13
|
// Paths
|
|
14
14
|
const automationCasesPath = "/shared/automation-cases.json";
|
|
15
15
|
const postBaseUrlPath = "/shared/result-post-url.txt";
|
|
16
|
+
const triggeredByPath = "/shared/triggered-by.txt";
|
|
16
17
|
const baseUrl = fs.readFileSync(postBaseUrlPath, "utf-8").trim();
|
|
17
18
|
|
|
19
|
+
// Read triggered_by value
|
|
20
|
+
let triggeredBy = null;
|
|
21
|
+
try {
|
|
22
|
+
if (fs.existsSync(triggeredByPath)) {
|
|
23
|
+
triggeredBy = fs.readFileSync(triggeredByPath, "utf-8").trim();
|
|
24
|
+
}
|
|
25
|
+
} catch (err) {
|
|
26
|
+
console.warn("⚠️ Could not read triggered-by.txt:", err.message);
|
|
27
|
+
}
|
|
28
|
+
|
|
18
29
|
(async () => {
|
|
19
30
|
let automationIds = null;
|
|
20
31
|
const formatted = [];
|
|
@@ -69,8 +80,8 @@ const baseUrl = fs.readFileSync(postBaseUrlPath, "utf-8").trim();
|
|
|
69
80
|
typeof test.fullTitle === "string"
|
|
70
81
|
? test.fullTitle
|
|
71
82
|
: Array.isArray(test.title)
|
|
72
|
-
|
|
73
|
-
|
|
83
|
+
? test.title.join(" ")
|
|
84
|
+
: test.title;
|
|
74
85
|
|
|
75
86
|
const allTags = [...(titleCombined.match(/@[\w-]+/g) || [])];
|
|
76
87
|
|
|
@@ -78,8 +89,8 @@ const baseUrl = fs.readFileSync(postBaseUrlPath, "utf-8").trim();
|
|
|
78
89
|
test.state === "passed" || test.pass === true
|
|
79
90
|
? "pass"
|
|
80
91
|
: test.pending === true
|
|
81
|
-
|
|
82
|
-
|
|
92
|
+
? "skipped"
|
|
93
|
+
: "fail";
|
|
83
94
|
|
|
84
95
|
if (!automationIds) {
|
|
85
96
|
allTags
|
|
@@ -125,6 +136,7 @@ async function postResults(formattedResults, notFoundList, planId, runId) {
|
|
|
125
136
|
runId,
|
|
126
137
|
results: formattedResults,
|
|
127
138
|
not_found: notFoundList,
|
|
139
|
+
triggered_by: triggeredBy,
|
|
128
140
|
};
|
|
129
141
|
|
|
130
142
|
console.log(
|