haven-cypress-integration 1.6.0 โ 1.6.2
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/bin/haven-cypress.js +6 -2
- package/index.js +7 -6
- package/package.json +2 -2
- package/templates/Dockerfile +10 -5
- package/templates/run-filtered.sh +36 -10
- package/templates/syncCypressResults.js +7 -4
package/bin/haven-cypress.js
CHANGED
|
@@ -19,13 +19,16 @@ Options:
|
|
|
19
19
|
--tag=name:version Docker image tag (default: haven-cypress-tests:latest)
|
|
20
20
|
--product=name Product name for ECR organization (required for --push)
|
|
21
21
|
--push Push image to ECR haven-test-images repository
|
|
22
|
-
--automationIds=ID1,ID2 Run specific test cases
|
|
22
|
+
--automationIds=ID1,ID2 Run specific test cases by automation ID
|
|
23
|
+
--customTags=tag1,tag2 Run tests with custom tags (smoke, regression, p1, etc.)
|
|
23
24
|
|
|
24
25
|
Examples:
|
|
25
26
|
npx haven-cypress build --product=BE
|
|
26
27
|
npx haven-cypress build --product=BE --push
|
|
27
28
|
npx haven-cypress build --product=BE --tag=v2.1.0 --push
|
|
28
29
|
npx haven-cypress run --automationIds=TC-AUTO-123,TC-AUTO-124
|
|
30
|
+
npx haven-cypress run --customTags=smoke,p1
|
|
31
|
+
npx haven-cypress run --automationIds=TC-AUTO-123 --customTags=smoke
|
|
29
32
|
|
|
30
33
|
Versioning:
|
|
31
34
|
--tag=latest โ ECR tag: BE-{package.json.version} or BE-1.0.{BUILD_NUMBER}
|
|
@@ -60,7 +63,8 @@ try {
|
|
|
60
63
|
|
|
61
64
|
case 'run':
|
|
62
65
|
const automationIds = options.automationIds || '';
|
|
63
|
-
|
|
66
|
+
const customTags = options.customTags || '';
|
|
67
|
+
integration.runTests(automationIds, customTags);
|
|
64
68
|
break;
|
|
65
69
|
|
|
66
70
|
default:
|
package/index.js
CHANGED
|
@@ -38,7 +38,7 @@ class HavenCypressIntegration {
|
|
|
38
38
|
|
|
39
39
|
// Build Docker image
|
|
40
40
|
console.log('๐๏ธ Building Docker image...');
|
|
41
|
-
execSync(`
|
|
41
|
+
execSync(`podman build -t ${tag} .`, {
|
|
42
42
|
cwd: buildDir,
|
|
43
43
|
stdio: 'inherit'
|
|
44
44
|
});
|
|
@@ -191,16 +191,16 @@ class HavenCypressIntegration {
|
|
|
191
191
|
|
|
192
192
|
// Login to ECR
|
|
193
193
|
console.log('๐ Logging in to ECR...');
|
|
194
|
-
const loginCmd = `aws ecr get-login-password --region ${region} |
|
|
194
|
+
const loginCmd = `aws ecr get-login-password --region ${region} | podman login --username AWS --password-stdin ${ecrUri}`;
|
|
195
195
|
execSync(loginCmd, { stdio: 'inherit' });
|
|
196
196
|
|
|
197
197
|
// Tag image for ECR
|
|
198
198
|
console.log(`๐ท๏ธ Tagging image: ${localTag} -> ${fullEcrUri}`);
|
|
199
|
-
execSync(`
|
|
199
|
+
execSync(`podman tag ${localTag} ${fullEcrUri}`, { stdio: 'inherit' });
|
|
200
200
|
|
|
201
201
|
// Push to ECR
|
|
202
202
|
console.log(`๐ค Pushing to ECR: ${fullEcrUri}`);
|
|
203
|
-
execSync(`
|
|
203
|
+
execSync(`podman push ${fullEcrUri}`, { stdio: 'inherit' });
|
|
204
204
|
|
|
205
205
|
console.log(`โ
Image pushed successfully!`);
|
|
206
206
|
console.log(`๐ ECR URI: ${fullEcrUri}`);
|
|
@@ -217,9 +217,10 @@ class HavenCypressIntegration {
|
|
|
217
217
|
* Run tests with Haven integration
|
|
218
218
|
* This is called by Haven when the container runs
|
|
219
219
|
*/
|
|
220
|
-
runTests(automationIds = '') {
|
|
220
|
+
runTests(automationIds = '', customTags = '') {
|
|
221
221
|
console.log('๐งช Running Haven-integrated Cypress tests...');
|
|
222
|
-
console.log(`๐ Automation IDs: ${automationIds || '
|
|
222
|
+
console.log(`๐ Automation IDs: ${automationIds || 'None'}`);
|
|
223
|
+
console.log(`๐ Custom Tags: ${customTags || 'None'}`);
|
|
223
224
|
|
|
224
225
|
// This will be handled by run-filtered.sh when container runs
|
|
225
226
|
// The library just provides the interface
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "haven-cypress-integration",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"description": "Seamless Cypress integration with HAVEN test case management",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -23,4 +23,4 @@
|
|
|
23
23
|
"engines": {
|
|
24
24
|
"node": ">=14.0.0"
|
|
25
25
|
}
|
|
26
|
-
}
|
|
26
|
+
}
|
package/templates/Dockerfile
CHANGED
|
@@ -5,15 +5,20 @@ WORKDIR /app
|
|
|
5
5
|
# Copy project files
|
|
6
6
|
COPY . .
|
|
7
7
|
|
|
8
|
-
# Install zip
|
|
8
|
+
# โ
Install zip and AWS CLI v2 via official method
|
|
9
9
|
RUN apt-get update && \
|
|
10
|
-
apt-get install -y
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
apt-get install -y \
|
|
11
|
+
zip \
|
|
12
|
+
unzip \
|
|
13
|
+
curl && \
|
|
14
|
+
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
|
|
15
|
+
unzip awscliv2.zip && \
|
|
16
|
+
./aws/install && \
|
|
17
|
+
rm -rf aws awscliv2.zip
|
|
13
18
|
|
|
14
19
|
# โ
Install Node deps (including dev dependencies for mochawesome)
|
|
15
20
|
RUN npm ci --include=dev
|
|
16
|
-
RUN npm install --no-save mochawesome mochawesome-merge mochawesome-report-generator
|
|
21
|
+
RUN npm install --no-save aws-sdk mochawesome mochawesome-merge mochawesome-report-generator
|
|
17
22
|
|
|
18
23
|
# โ
Ensure script is executable
|
|
19
24
|
COPY run-filtered.sh /app/run-filtered.sh
|
|
@@ -4,31 +4,56 @@ echo "๐ฅ RUN SCRIPT:"
|
|
|
4
4
|
echo "โ
ENTERED run-filtered.sh"
|
|
5
5
|
echo "โ๏ธ Raw args: $@"
|
|
6
6
|
|
|
7
|
-
# Extract automation IDs from CLI args
|
|
7
|
+
# Extract automation IDs and custom tags from CLI args
|
|
8
8
|
AUTOMATION_IDS=""
|
|
9
|
+
CUSTOM_TAGS=""
|
|
9
10
|
for arg in "$@"; do
|
|
10
11
|
case $arg in
|
|
11
12
|
--automationIds=*)
|
|
12
13
|
AUTOMATION_IDS="${arg#*=}"
|
|
13
14
|
shift
|
|
14
15
|
;;
|
|
16
|
+
--customTags=*)
|
|
17
|
+
CUSTOM_TAGS="${arg#*=}"
|
|
18
|
+
shift
|
|
19
|
+
;;
|
|
15
20
|
esac
|
|
16
21
|
done
|
|
17
22
|
|
|
18
23
|
echo "๐ Extracted automation IDs: ${AUTOMATION_IDS}"
|
|
24
|
+
echo "๐ Extracted custom tags: ${CUSTOM_TAGS}"
|
|
19
25
|
echo "๐ Current working directory: $(pwd)"
|
|
20
26
|
|
|
27
|
+
# Build grep arguments for Cypress
|
|
28
|
+
CYPRESS_GREP=""
|
|
29
|
+
GREP_TAGS=""
|
|
21
30
|
|
|
22
|
-
if [ -
|
|
23
|
-
echo "๐ No automation IDs provided. Running all tests..."
|
|
24
|
-
CYPRESS_GREP=""
|
|
25
|
-
else
|
|
31
|
+
if [ -n "$AUTOMATION_IDS" ]; then
|
|
26
32
|
# Strip quotes from arg, replace commas with spaces
|
|
27
33
|
RAW_IDS=$(echo "$AUTOMATION_IDS" | sed "s/^['\"]//;s/['\"]$//")
|
|
28
34
|
CLEANED_IDS="${RAW_IDS//,/ }"
|
|
35
|
+
GREP_TAGS="${CLEANED_IDS}"
|
|
36
|
+
echo "๐ Running Cypress with automation IDs: ${CLEANED_IDS}"
|
|
37
|
+
fi
|
|
38
|
+
|
|
39
|
+
if [ -n "$CUSTOM_TAGS" ]; then
|
|
40
|
+
# Strip quotes from arg, replace commas with spaces
|
|
41
|
+
RAW_TAGS=$(echo "$CUSTOM_TAGS" | sed "s/^['\"]//;s/['\"]$//")
|
|
42
|
+
CLEANED_TAGS="${RAW_TAGS//,/ }"
|
|
43
|
+
|
|
44
|
+
if [ -n "$GREP_TAGS" ]; then
|
|
45
|
+
GREP_TAGS="${GREP_TAGS} ${CLEANED_TAGS}"
|
|
46
|
+
else
|
|
47
|
+
GREP_TAGS="${CLEANED_TAGS}"
|
|
48
|
+
fi
|
|
49
|
+
echo "๐ Running Cypress with custom tags: ${CLEANED_TAGS}"
|
|
50
|
+
fi
|
|
29
51
|
|
|
30
|
-
|
|
31
|
-
CYPRESS_GREP="--env grepTags='${
|
|
52
|
+
if [ -n "$GREP_TAGS" ]; then
|
|
53
|
+
CYPRESS_GREP="--env grepTags='${GREP_TAGS}'"
|
|
54
|
+
echo "๐ก Final grep tags: ${GREP_TAGS}"
|
|
55
|
+
else
|
|
56
|
+
echo "๐ No tags provided. Running all tests..."
|
|
32
57
|
fi
|
|
33
58
|
|
|
34
59
|
# Set environment variables
|
|
@@ -37,6 +62,7 @@ PRODUCT_NAME=${PRODUCT_NAME:-unknown_product}
|
|
|
37
62
|
PLAN_ID=${PLAN_ID:-unknown_plan}
|
|
38
63
|
RUN_ID=${RUN_ID:-unknown_run}
|
|
39
64
|
BUCKET_NAME=${BUCKET_NAME:-your-default-bucket}
|
|
65
|
+
TEST_ENVIRONMENT=${TEST_ENVIRONMENT:-QA}
|
|
40
66
|
|
|
41
67
|
# Ensure results directory exists
|
|
42
68
|
mkdir -p results/mochawesome
|
|
@@ -45,14 +71,14 @@ echo "๐งน Cleaning mochawesome reports"
|
|
|
45
71
|
rm -rf results/mochawesome/*
|
|
46
72
|
|
|
47
73
|
# Run Cypress
|
|
48
|
-
echo "๐ Running Cypress
|
|
74
|
+
echo "๐ Running Cypress tests..."
|
|
49
75
|
echo "๐ก Final grep arg: $CYPRESS_GREP"
|
|
50
76
|
eval "npx cypress run \
|
|
51
77
|
--headless \
|
|
52
78
|
--browser chrome \
|
|
53
79
|
--reporter mochawesome \
|
|
54
80
|
--reporter-options 'reportDir=results/mochawesome,overwrite=false,html=false,json=true,timestamp=mmddyyyy_HHMMss' \
|
|
55
|
-
--env grepFilterSpecs=true,grepUntagged=false,grepEnabled=true \
|
|
81
|
+
--env grepFilterSpecs=true,grepUntagged=false,grepEnabled=true,TEST_ENVIRONMENT=${TEST_ENVIRONMENT} \
|
|
56
82
|
$CYPRESS_GREP \
|
|
57
83
|
> results/logs.txt 2>&1"
|
|
58
84
|
|
|
@@ -128,7 +154,7 @@ fi
|
|
|
128
154
|
|
|
129
155
|
# Run result sync
|
|
130
156
|
echo "๐ Running syncCypressResults.js"
|
|
131
|
-
PLAN_ID="${PLAN_ID}" RUN_ID="${RUN_ID}" node syncCypressResults.js >> results/logs.txt 2>&1 || echo "โ ๏ธ syncCypressResults.js failed"
|
|
157
|
+
PLAN_ID="${PLAN_ID}" RUN_ID="${RUN_ID}" TEST_ENVIRONMENT="${TEST_ENVIRONMENT}" node syncCypressResults.js >> results/logs.txt 2>&1 || echo "โ ๏ธ syncCypressResults.js failed"
|
|
132
158
|
|
|
133
159
|
# Final output
|
|
134
160
|
echo "๐ค Dumping results/logs.txt for runner capture:"
|
|
@@ -112,23 +112,25 @@ try {
|
|
|
112
112
|
|
|
113
113
|
const planId = process.env.PLAN_ID || "unknown";
|
|
114
114
|
const runId = process.env.RUN_ID || "unknown";
|
|
115
|
+
const testEnvironment = process.env.TEST_ENVIRONMENT || "QA";
|
|
115
116
|
|
|
116
117
|
if (!planId || !runId || isNaN(Number(planId)) || isNaN(Number(runId))) {
|
|
117
118
|
console.error("โ Invalid or missing PLAN_ID / RUN_ID");
|
|
118
119
|
process.exit(1);
|
|
119
120
|
}
|
|
120
121
|
|
|
121
|
-
await postResults(formatted, notFound, planId, runId);
|
|
122
|
-
await postSummary(formatted, notFound, planId, runId);
|
|
122
|
+
await postResults(formatted, notFound, planId, runId, testEnvironment);
|
|
123
|
+
await postSummary(formatted, notFound, planId, runId, testEnvironment);
|
|
123
124
|
})();
|
|
124
125
|
|
|
125
|
-
async function postResults(formattedResults, notFoundList, planId, runId) {
|
|
126
|
+
async function postResults(formattedResults, notFoundList, planId, runId, testEnvironment) {
|
|
126
127
|
const postUrl = baseUrl; // baseUrl already includes the complete endpoint
|
|
127
128
|
console.log(`๐ Posting to URL: ${postUrl}`);
|
|
128
129
|
|
|
129
130
|
const payload = {
|
|
130
131
|
planId,
|
|
131
132
|
runId,
|
|
133
|
+
environment: testEnvironment,
|
|
132
134
|
results: formattedResults,
|
|
133
135
|
not_found: notFoundList,
|
|
134
136
|
triggered_by: triggeredBy,
|
|
@@ -154,7 +156,7 @@ async function postResults(formattedResults, notFoundList, planId, runId) {
|
|
|
154
156
|
}
|
|
155
157
|
}
|
|
156
158
|
|
|
157
|
-
async function postSummary(results, notFound, planId, runId) {
|
|
159
|
+
async function postSummary(results, notFound, planId, runId, testEnvironment) {
|
|
158
160
|
// Replace test-results with test-run-summary in the baseUrl
|
|
159
161
|
const url = baseUrl.replace('/api/test-results', '/api/test-run-summary');
|
|
160
162
|
|
|
@@ -164,6 +166,7 @@ async function postSummary(results, notFound, planId, runId) {
|
|
|
164
166
|
const summaryPayload = {
|
|
165
167
|
runId,
|
|
166
168
|
planId,
|
|
169
|
+
environment: testEnvironment,
|
|
167
170
|
status: computeOverallStatus(results, notFound),
|
|
168
171
|
logs,
|
|
169
172
|
result: {
|