From 8f7764ec0ca6a983047ab3f0dd6f559d5caf4ac9 Mon Sep 17 00:00:00 2001 From: Vitaly Nesteruk Date: Thu, 27 Apr 2023 14:22:41 +0300 Subject: [PATCH] DOF: complete module 4 lab 1 --- lab_1/scripts/build-client.sh | 23 +++++++++++++++++++++ lab_1/scripts/quality-check.sh | 19 +++++++++++++++++ lab_1/scripts/update-pipeline-definition.sh | 16 ++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 lab_1/scripts/build-client.sh create mode 100644 lab_1/scripts/quality-check.sh create mode 100644 lab_1/scripts/update-pipeline-definition.sh diff --git a/lab_1/scripts/build-client.sh b/lab_1/scripts/build-client.sh new file mode 100644 index 0000000..1716dd2 --- /dev/null +++ b/lab_1/scripts/build-client.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +repository="https://github.com/EPAM-JS-Competency-center/shop-angular-cloudfront.git" +localFolder="/Users/$USER/Desktop/DOF/EPAM-JS-Competency-center" +compressedClientApp="/Users/$USER/Desktop/DOF/EPAM-JS-Competency-center/dist/client-app.zip" +dist="/Users/$USER/Desktop/DOF/EPAM-JS-Competency-center/dist/" + +ENV_CONFIGURATION='' + +git clone "$repository" "$localFolder" + +cd "$localFolder" || exit + +npm install +npm run-script build --configuration="$ENV_CONFIGURATION" + +if [ -f "$compressedClientApp" ]; then + echo "Compressed client app already exists"; + rm -i "$compressedClientApp" + echo "Compressed client app was deleted"; +fi + +zip -r client-app.zip "$dist" diff --git a/lab_1/scripts/quality-check.sh b/lab_1/scripts/quality-check.sh new file mode 100644 index 0000000..4e3e994 --- /dev/null +++ b/lab_1/scripts/quality-check.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +cd ~/Desktop/Devops-fundamentals/EPAM-JS-Competency-center/ || exit + +echo "Running linting..." +npm run lint + +echo "Running unit tests..." +npm run test + +echo "Running npm audit..." +npm audit + +if [ $? -eq 0 ]; then + echo "Code quality checks passed!" +else + echo "Code quality checks failed. Please check the logs for more information." + exit 1 +fi diff --git a/lab_1/scripts/update-pipeline-definition.sh b/lab_1/scripts/update-pipeline-definition.sh new file mode 100644 index 0000000..1eeba72 --- /dev/null +++ b/lab_1/scripts/update-pipeline-definition.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +lab1Dir="/Users/$USER/Desktop/DOF/devops-fundamentals-course/lab_1" +defaultBranchName="main" + +echo -n "Enter a source branch to use (default: $defaultBranchName): " +read -r branchName +branchName=${branchName:-$defaultBranchName} + +cd "$lab1Dir" || exit + +cp "$lab1Dir"/pipeline.json "$lab1Dir"/pipeline-"$(date +'%m-%d-%Y')".json + +jq 'del(.metadata)' pipeline-"$(date +'%m-%d-%Y')".json > tmp.$$.json && mv tmp.$$.json pipeline-"$(date +'%m-%d-%Y')".json +jq '.pipeline.version = .pipeline.version + 1' pipeline-"$(date +'%m-%d-%Y')".json > tmp.$$.json && mv tmp.$$.json pipeline-"$(date +'%m-%d-%Y')".json +jq --arg branchName "$branchName" '.pipeline.stages[0].actions[0].configuration.Branch = $branchName' pipeline-"$(date +'%m-%d-%Y')".json > tmp.$$.json && mv tmp.$$.json pipeline-"$(date +'%m-%d-%Y')".json