Skip to content

Js lab 3 #165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 25 commits into
base: feat/cicd-lab
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
54eac51
ci: add commitlint
MazueraAlvaro Jun 9, 2023
0a54caf
fix: fix merge
MazueraAlvaro Jun 9, 2023
78be904
chore: angular file to gitignore
MazueraAlvaro Jun 10, 2023
703785c
chore(release): 0.0.0
MazueraAlvaro Jun 10, 2023
d0f1092
chore: add standard-version
MazueraAlvaro Jun 10, 2023
49f43b2
chore: add pre-push husky hook
MazueraAlvaro Jun 10, 2023
548a328
ci: add cicd local scripts and config
MazueraAlvaro Jun 11, 2023
df59613
ci: add gitlab-ci file
MazueraAlvaro Jun 11, 2023
841dcaa
ci: add install dependencies stage
MazueraAlvaro Jun 11, 2023
acd637c
ci: add install dependencies stage
MazueraAlvaro Jun 11, 2023
3704767
ci: add image node 18 alpine
MazueraAlvaro Jun 11, 2023
a7a40d5
ci: add build job
MazueraAlvaro Jun 11, 2023
8c4267a
ci: add artifacts path node_modules
MazueraAlvaro Jun 11, 2023
d3e32c3
ci: add cache path node_modules
MazueraAlvaro Jun 11, 2023
f240156
ci: refactor install dependencies and build in one job
MazueraAlvaro Jun 11, 2023
fc34ea5
ci: add node_options
MazueraAlvaro Jun 11, 2023
414b735
ci: modify cache node_modules
MazueraAlvaro Jun 11, 2023
7cb0432
ci: modify cache node_modules
MazueraAlvaro Jun 11, 2023
b90dc09
ci: modify ng command
MazueraAlvaro Jun 11, 2023
3766d24
ci: modify ng command
MazueraAlvaro Jun 11, 2023
c106997
ci: modify gitñab-ci
MazueraAlvaro Jun 11, 2023
f3fe72d
ci: fix gitlab-ci
MazueraAlvaro Jun 11, 2023
5b78464
ci: fix gitlab-ci
MazueraAlvaro Jun 11, 2023
dce4bed
ci: fix gitlab-ci
MazueraAlvaro Jun 11, 2023
382fa16
ci: remove ls from gitlab-ci
MazueraAlvaro Jun 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ testem.log
# System Files
.DS_Store
Thumbs.db
.scannerwork
.angular

# SAM assests
template-export.yml
59 changes: 59 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
stages:
- dependencies
- build
- test

install_dependencies:
stage: dependencies
image: "node:18-alpine"
script:
- export NODE_OPTIONS=--openssl-legacy-provider
- npm ci
cache:
key:
files:
- package-lock.json
paths:
- node_modules

build:
image: "node:18-alpine"
stage: build
script:
- npm run build
cache:
key:
files:
- package-lock.json
paths:
- node_modules
policy: pull

unit-tests:
stage: test
script:
- npm run test:coverage
cache:
key:
files:
- package-lock.json
paths:
- node_modules
policy: pull

linting:
stage: test
script:
- npm run lint
cache:
key:
files:
- package-lock.json
paths:
- node_modules
policy: pull

audit:
stage: test
script:
- npm audit
1 change: 1 addition & 0 deletions .husky/commit-msg
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/sh

npx --no-install commitlint --edit "$1"
npx --no -- commitlint --edit ${1}
Empty file modified .husky/pre-commit
100644 → 100755
Empty file.
5 changes: 5 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

npm run lint:format
npm run test:coverage
npm audit
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Changelog

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## 0.0.0 (2023-06-10)

### Features

- add API endpoints config and feature flags for endpoints ([c2a2235](https://github.com/EPAM-JS-Competency-center/shop-angular-cloudfront/commit/c2a2235b5c456b3007ea003206c64b15aa168fa2))
- add basic header ([356c51b](https://github.com/EPAM-JS-Competency-center/shop-angular-cloudfront/commit/356c51bf03126b0fa8473b962064cf2915abff3c))
- add basic representation of mock products ([00c5ec7](https://github.com/EPAM-JS-Competency-center/shop-angular-cloudfront/commit/00c5ec7b1766e11e8c41091421547cb782177031))
- add cart count interactions ([a5797f2](https://github.com/EPAM-JS-Competency-center/shop-angular-cloudfront/commit/a5797f2646d700dcadebf7b635d4efa3e80773c5))
- add manage products page placeholder ([5f6ab34](https://github.com/EPAM-JS-Competency-center/shop-angular-cloudfront/commit/5f6ab349a39c9c32d4e0cc1016fac0ea63125194))
- add the missing product edit module ([#25](https://github.com/EPAM-JS-Competency-center/shop-angular-cloudfront/issues/25)) ([52ceb01](https://github.com/EPAM-JS-Competency-center/shop-angular-cloudfront/commit/52ceb014f0df6279fe895167728944f866c2f38b))
- checkout flow ([226c62c](https://github.com/EPAM-JS-Competency-center/shop-angular-cloudfront/commit/226c62cd1a3e32d01f5f308eeb342ab294352671))
- ci/cd lab ([786c91d](https://github.com/EPAM-JS-Competency-center/shop-angular-cloudfront/commit/786c91d5c8ab66fadc3bd2603761f26a55857405))
- cicd lab ([48f5a14](https://github.com/EPAM-JS-Competency-center/shop-angular-cloudfront/commit/48f5a14de21761fee7412f423981cfbe6a66066e))
- cicd lab ([7250d86](https://github.com/EPAM-JS-Competency-center/shop-angular-cloudfront/commit/7250d86e155458ac657a26d8b06b800b872cf788))
- cicd lab ([26a8473](https://github.com/EPAM-JS-Competency-center/shop-angular-cloudfront/commit/26a8473bb0720d3b5aee890810c8ee63367a32e4))
- extract order summary into a dedicated component ([3fb0cc3](https://github.com/EPAM-JS-Competency-center/shop-angular-cloudfront/commit/3fb0cc37bcf13e8ec845f8999b46d4530af20420))
- placeholder for manage orders page ([e6007cd](https://github.com/EPAM-JS-Competency-center/shop-angular-cloudfront/commit/e6007cd065bbd09422c88371325a816af64c1bab))
- serverless lab ([7509548](https://github.com/EPAM-JS-Competency-center/shop-angular-cloudfront/commit/7509548d0d6285c45313fabf47c6497fcae27068))
- serverless lab ([91a9e8c](https://github.com/EPAM-JS-Competency-center/shop-angular-cloudfront/commit/91a9e8c85c7ae88d1f17b71da9728942be29afaf))
- serverless lab ([2f73bcc](https://github.com/EPAM-JS-Competency-center/shop-angular-cloudfront/commit/2f73bcc8cd6238b7a02f59606d8b89bfb53ce1aa))
- serverless lab ([7a6d07f](https://github.com/EPAM-JS-Competency-center/shop-angular-cloudfront/commit/7a6d07fe25d502dddf0b43f983b3d55b6b09caf3))
- serverless lab ([f48798d](https://github.com/EPAM-JS-Competency-center/shop-angular-cloudfront/commit/f48798d126df47a0d9b04b04e8e5bbdeebb6d262))
- show error notification when HTTP error response received ([75730d5](https://github.com/EPAM-JS-Competency-center/shop-angular-cloudfront/commit/75730d5b621349ce427de8fe081edce91a7b9785))
- SQS/SQS lab ([69bf1a7](https://github.com/EPAM-JS-Competency-center/shop-angular-cloudfront/commit/69bf1a70dc4168a834c232469e2781739a31e931))
- upload CSV file ([547a74a](https://github.com/EPAM-JS-Competency-center/shop-angular-cloudfront/commit/547a74ab81788290e928074d5d9b8be7ff039992))

### Bug Fixes

- fix merge ([0a54caf](https://github.com/EPAM-JS-Competency-center/shop-angular-cloudfront/commit/0a54caf190e5c870d90f0a7222f7da4dadf6fc5f))
33 changes: 33 additions & 0 deletions build-client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

#Avoid Angular cli asking for collecting analytics
export NG_CLI_ANALYTICS="false"

declare distDir='dist'
declare zipFile='client-app.zip'

if ! [ -x "$(command -v zip)" ]
then
echo "Error: The app cannot be built, zip is not installed"
echo 'Please install zip and try again.'
exit 1
fi

echo "Installing app dependencies"
npm install

if [ -f "$distDir/$zipFile" ]
then
echo "Removing existing zip file"
rm -f $distDir/$zipFile
fi

echo "Building app"
export ENV_CONFIGURATION=""
npm run build -- --configuration=$ENV_CONFIGURATION

cd $distDir
echo "Compressing dist app"
zip -qr "$zipFile" *

echo "App built succesfully"
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = function (config) {
coverageReporter: {
dir: require("path").join(__dirname, "./coverage/app"),
subdir: ".",
reporters: [{ type: "html" }, { type: "text-summary" }],
reporters: [{ type: "html" }, { type: "text-summary" }, { type: "lcov" }],
},
reporters: ["spec"],
port: 9876,
Expand Down
29 changes: 29 additions & 0 deletions local_ci_cd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

FE_LOCAL_DIR=$(pwd)
FE_REMOTE_DIR=/var/www/shop
SSH_ALIAS=ubuntu-sshuser

#Run code quality tools
echo "Running code quality tools"
sh quality-check.sh
echo "Code quality tools finished"

#Run code quality tools
echo "Running buiding app process"
sh build-client.sh
echo "Build finished"


if ssh $SSH_ALIAS "[ ! -d $FE_REMOTE_DIR ]"; then
echo "Creating dir $FE_REMOTE_DIR"
ssh -t $SSH_ALIAS "sudo bash -c 'mkdir -p $FE_REMOTE_DIR && chown -R sshuser:sshuser $FE_REMOTE_DIR'"
else
echo "Removing previous app"
ssh $SSH_ALIAS "sudo -S rm -r $FE_REMOTE_DIR/*"
fi

echo "Building and Deploying app"
scp -Cr client-app.zip certs nginx.conf $SSH_ALIAS:$FE_REMOTE_DIR
ssh $SSH_ALIAS "sudo -S unzip $FE_REMOTE_DIR/client-app.zip"
echo "App built and deployed"
Loading