-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathe2e.sh
executable file
·64 lines (46 loc) · 1.47 KB
/
e2e.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
# Exit immediately if a command exits with a non-zero status
set -e
# Function to perform cleanup
cleanup() {
echo "Cleaning up..."
# Remove generated folders and files
rm -rf e2e-tests e2e-tests.zip site_import.zip site_import "$CODE_VERSION" "$CODE_VERSION.zip"
}
# Trap EXIT signal to run cleanup when the script exits, regardless of success or failure
trap cleanup EXIT
# Load environment variables from .env file
if [ -f .env ]; then
echo "Loading environment variables from .env file"
export $(grep -v '^#' .env | xargs)
fi
# Ensure CODE_VERSION is set
if [ -z "$CODE_VERSION" ]; then
echo "ERROR: CODE_VERSION is not set. Please define it in your .env file or export it in your shell."
exit 1
fi
echo "Using CODE_VERSION: $CODE_VERSION"
echo "Linting JavaScript..."
npm run lint:js
echo "Running unit tests..."
npm run test:unit
echo "Compiling JavaScript..."
npm run compile:js --silent
echo "Compiling SCSS..."
npm run compile:scss --silent
echo "Preparing code for deployment..."
mkdir -p "$CODE_VERSION"
cp -R cartridges/* "$CODE_VERSION"/
echo "Zipping the cartridges directory..."
zip -rq "${CODE_VERSION}.zip" "$CODE_VERSION"
echo "Deploying code..."
node scripts/deployCode.js
echo "Importing site preferences..."
node scripts/importPreferences.js
echo "Running SFCC job..."
node scripts/runSFCCJob.js
echo "Running index tests..."
npm run test:variationindex
echo "Running frontend tests..."
npx cypress run
echo "E2E tests completed successfully."