Skip to content

Commit

Permalink
Initial public commit, Version 0.9.0.
Browse files Browse the repository at this point in the history
Co-authored-by: Anilkumar Kodi <[email protected]>
Co-authored-by: Enrico Piccin <[email protected]>
Co-authored-by: Mario Grimaldi <[email protected]>
Co-authored-by: Matteo Cajani <[email protected]>
Co-authored-by: Sandeep Bhardwaj <[email protected]>
Co-authored-by: Sara Michelazzo <[email protected]>
Co-authored-by: Senthilraja Ramamoorthy <[email protected]>
Co-authored-by: Srilatha K Y <[email protected]>
  • Loading branch information
9 people committed Jun 26, 2019
1 parent 5b33d39 commit dff7ea5
Show file tree
Hide file tree
Showing 186 changed files with 25,416 additions and 0 deletions.
126 changes: 126 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
version: 2.1
only_tagged_versions: &only_tagged_versions
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
commands:
add_missing_dependencies:
steps:
- run:
name: Add curl, git and make
command: |
apt-get update
apt-get install -y curl git make jq
- run:
name: Install Docker client
command: |
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
rm -Rf get-docker.sh
docker --version
- run:
name: Install Docker Compose
command: |
curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version
run_common_initial_steps:
steps:
- setup_remote_docker:
version: 18.06.0-ce
# Inactive for now... needs to be whitelisted (and/or OS), see https://circleci.com/docs/2.0/docker-layer-caching/
docker_layer_caching: true
- add_missing_dependencies
- checkout
- restore_cache:
keys:
- dependencies-{{ arch }}-{{ .Branch }}-{{ checksum "package.json" }}
- run:
name: Copy current dir to remote docker
# mount hack for cicleci: https://circleci.com/docs/2.0/building-docker-images/#mounting-folders
command: |
/bin/bash .make/utils/execute-in-docker.sh -s "${CIRCLE_PROJECT_REPONAME}" -o "--no-start"
docker cp . $(docker-compose ps -q ${CIRCLE_PROJECT_REPONAME}):/usr/src/app/
- run:
name: Copy ~/.ssh dir to remote docker
command: docker cp ~/.ssh $(docker-compose ps -q ${CIRCLE_PROJECT_REPONAME}):/root/
- run:
name: Install
command: make install
- run:
name: Copy node_modules dir from remote docker
# return node_modules hack for cicleci: https://circleci.com/docs/2.0/building-docker-images/#mounting-folders
command: docker cp $(docker-compose ps -q ${CIRCLE_PROJECT_REPONAME}):/usr/src/app/node_modules/ ./node_modules/
- save_cache:
paths:
- node_modules
key: dependencies-{{ arch }}-{{ .Branch }}-{{ checksum "package.json" }}
defaults: &defaults
docker:
- image: ubuntu:18.04
jobs:
test:
<<: *defaults
steps:
- run_common_initial_steps
- run:
name: Lint
command: make lint
- run:
name: Unit tests
# TODO temp hack that sets backend service url since unit tests as of now are no actual unit tests
command: BACKEND_SERVICE_URL="${AWS_SERVICE_URL}" make unit_tests
- run:
name: Verify build for production
command: BACKEND_SERVICE_URL="${AWS_SERVICE_URL}" make build
release:
<<: *defaults
steps:
- run_common_initial_steps
- run:
name: Semantic release
command: make semantic_release
publish:
<<: *defaults
steps:
- run_common_initial_steps
- run:
name: Publish to Docker Hub
command: |
TAG_BASE="byoritaly/${CIRCLE_PROJECT_REPONAME}:"
IMAGE_TAG=${TAG_BASE}$(cat package.json | jq -r .version)
TAGS=( $IMAGE_TAG )
if [ "$(git rev-parse HEAD)" == "$(git rev-parse master)" ]; then TAGS=( "${TAGS[@]}" "${TAG_BASE}latest" ); fi
docker login -u ${DOCKER_HUB_USER_ID} -p ${DOCKER_HUB_PWD}
for TAG in "${TAGS[@]}"; do
docker build -t ${TAG} .
docker push ${TAG}
done
docker logout
workflows:
version: 2.1
# This runs on non-tag pushes
untagged:
jobs:
- test:
context: byor
- release:
context: byor
requires:
- test
filters:
branches:
only: master
# This only runs on deploy tags and not branches
tagged:
jobs:
- test:
<<: *only_tagged_versions
context: byor
- publish:
<<: *only_tagged_versions
context: byor
requires:
- test
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
npm-debug.log
.git
dist
Dockerfile
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = off
trim_trailing_whitespace = false
36 changes: 36 additions & 0 deletions .github/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Actual behavior**
What actually happens

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]


**Reproduces how often**
What percentage of the time does it reproduce?

**Additional context**
Add any other context about the problem here.
11 changes: 11 additions & 0 deletions .github/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
6 changes: 6 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Thank you for your contribution to the byor-voting-web-app repo.
Before submitting this PR, please make sure:

- [ ] Your code builds clean without any errors or warnings
- [ ] You are using approved terminology
- [ ] You have added unit tests
44 changes: 44 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp
/out-tsc

# dependencies
/node_modules

# profiling files
chrome-profiler-events.json
speed-measure-plugin.json

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# System Files
.DS_Store
Thumbs.db
commands.txt
37 changes: 37 additions & 0 deletions .make/cd/deploy_aws.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
set -e;

if [ -z "${CI}" ]; then
read -e -p "Please enter the target bucket [dev]: " inBucket;
read -e -p "Please enter your AWS access key id: " keyid;
read -e -p "Please enter your AWS secret access key (input hidden)" -s secretkey;
echo ""
read -e -p "Please enter your AWS region [us-east-1]: " inAwsRegion;
else
inBucket="${AWS_SERVICE_STAGE}"
keyid="${AWS_ACCESS_KEY_ID}"
secretkey="${AWS_SECRET_ACCESS_KEY}"
inAwsRegion="${AWS_REGION}"
fi

bucket="${inBucket:-dev}"
awsRegion="${inAwsRegion:-us-east-1}"

echo "Deploying to bucket: ${bucket} and region: ${awsRegion}"

credentials_file="/root/.aws/credentials"
read -d '' final_command << EOF || true
mkdir -p $(dirname ${credentials_file});
touch ${credentials_file};
echo '[default]' > ${credentials_file};
echo 'aws_access_key_id=${keyid}' >> ${credentials_file};
echo 'aws_secret_access_key=${secretkey}' >> ${credentials_file};
aws s3 rm s3://${bucket}/ --recursive
aws s3 cp dist/ng-build-your-own-radar s3://${bucket}/ --recursive
EOF

/bin/bash .make/utils/execute-in-docker.sh \
-d "run" \
-c "/bin/bash -c \"${final_command}\"" \
-s "byor-app" \
-o "--rm"
13 changes: 13 additions & 0 deletions .make/cd/semantic_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -e;

if [ -z "${CI}" ]; then
echo "Aborting since this command should be executed from CI/CD pipelines only"
exit 1;
fi

/bin/bash .make/utils/execute-in-docker.sh \
-d "run" \
-c "npm run semantic-release" \
-s "byor-app" \
-o "--rm"
9 changes: 9 additions & 0 deletions .make/ci/all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -e;

export CI="true"

make install
make lint
make unit_tests
BACKEND_SERVICE_URL=http://localhost:3000/ RADAR_SERVICE_URL=https://radar.thoughtworks.com/ make build
14 changes: 14 additions & 0 deletions .make/ci/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -e;

BACKEND_SERVICE_URL=$(/bin/bash ./.make/utils/get-backend-service-url.sh)
RADAR_SERVICE_URL=$(/bin/bash ./.make/utils/get-radar-service-url.sh)

echo "Taget backend service: ${BACKEND_SERVICE_URL}"
echo "Taget radar service: ${RADAR_SERVICE_URL}"

BACKEND_SERVICE_URL="${BACKEND_SERVICE_URL}" RADAR_SERVICE_URL="${RADAR_SERVICE_URL}" /bin/bash .make/utils/execute-in-docker.sh \
-d "run" \
-c "npm run build" \
-s "byor-app" \
-o "--rm"
7 changes: 7 additions & 0 deletions .make/ci/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -e;

/bin/bash .make/utils/execute-in-docker.sh \
-c "npm install" \
-s "byor-app" \
-o "--build --exit-code-from byor-app"
19 changes: 19 additions & 0 deletions .make/ci/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
set -e;

fix=""
if [ -z "${CI}" ]; then
read -e -p "Do you want to automatically try to fix lint errors? [y/N] " input_fix;
if [[ ${input_fix} == y ]]; then
fix=":fix"
fi
fi

full_command="npm run lint${fix}"
echo "About to execute: ${full_command}"

/bin/bash .make/utils/execute-in-docker.sh \
-d "run" \
-c "${full_command}" \
-s "byor-app" \
-o "--rm"
28 changes: 28 additions & 0 deletions .make/ci/tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
set -e;
if [ -z $BACKEND_SERVICE_URL ]; then
export BACKEND_SERVICE_URL=http://host.docker.internal:3000/
fi


watch=""
if [ -z "${CI}" ]; then
read -e -p "Do you want to run tests in watch mode? [Y/n] " input_watch;
if [[ ! ${input_watch} == n ]]; then
watch=":watch"
fi
fi

full_command="npm run ${test_script}${watch}"
echo "About to execute: ${full_command}"

case "${test_script}" in
test)
/bin/bash .make/utils/execute-in-docker.sh \
-c "${full_command}" \
-s "byor-app" \
-o "--exit-code-from byor-app";;
*)
echo "ERROR: ${test_script} is not supported"
exit 1;;
esac
14 changes: 14 additions & 0 deletions .make/development/check_for_secrets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -e;

echo "About to run secret disclosure checks with Talisman..."
docker run \
-it \
--rm \
-v "$PWD:/usr/src" \
-v /usr/src/node_modules/ \
-v /usr/src/.git/ \
-v /usr/src/dist \
byoritaly/talisman-checks-runner:0.4.6 \
/bin/bash -c "git init &> /dev/null && talisman --pattern \"**\""
echo "...no secrets found, ok!"
Loading

0 comments on commit dff7ea5

Please sign in to comment.