Skip to content

Commit

Permalink
Merge pull request #285 from labzero/develop
Browse files Browse the repository at this point in the history
Merge to master
  • Loading branch information
JeffreyATW authored Apr 28, 2023
2 parents 464751b + e6720ef commit 64fa6c8
Show file tree
Hide file tree
Showing 346 changed files with 12,895 additions and 12,467 deletions.
122 changes: 87 additions & 35 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,47 @@
# JOB DEFINITIONS
version: 2
version: 2.1
orbs:
node: circleci/[email protected]
commands:
aws-deploy:
parameters:
build_container_repository:
type: env_var_name
default: BUILD_CONTAINER_REPOSITORY
ecs_cluster:
type: string
default: ""
migration_task:
type: string
default: ""
service_name:
type: string
default: ""
task_family:
type: string
default: ""
steps:
- run:
name: Deploy
command: |
aws configure set default.region us-west-2
CLEAN_BRANCH=`echo ${CIRCLE_BRANCH} | sed 's/\//-/g'`
DOCKER_TAG=${<< parameters.build_container_repository >>}:${CIRCLE_SHA1}
CURRENT_TASK=`aws ecs list-task-definitions --status ACTIVE --family-prefix << parameters.task_family >> --sort DESC | jq -r '.taskDefinitionArns[0]'`
TASK_JSON=`aws ecs describe-task-definition --task-definition ${CURRENT_TASK} | jq --arg DOCKER_TAG "$DOCKER_TAG" '.taskDefinition.containerDefinitions[0].image = $DOCKER_TAG | {containerDefinitions: .taskDefinition.containerDefinitions, family: .taskDefinition.family}'`
aws ecs register-task-definition --cli-input-json "${TASK_JSON}" > /dev/null
CURRENT_MIGRATION_TASK=`aws ecs list-task-definitions --status ACTIVE --family-prefix << parameters.migration_task >> --sort DESC | jq -r '.taskDefinitionArns[0]'`
MIGRATION_TASK_JSON=`aws ecs describe-task-definition --task-definition ${CURRENT_MIGRATION_TASK} | jq --arg DOCKER_TAG "$DOCKER_TAG" '.taskDefinition.containerDefinitions[0].image = $DOCKER_TAG | {containerDefinitions: .taskDefinition.containerDefinitions, family: .taskDefinition.family}'`
aws ecs register-task-definition --cli-input-json "${MIGRATION_TASK_JSON}" > /dev/null
aws ecs run-task --cluster << parameters.ecs_cluster >> --task-definition << parameters.migration_task >>
NEW_TASK=`aws ecs list-task-definitions --status ACTIVE --family-prefix << parameters.task_family >> --sort DESC | jq -r '.taskDefinitionArns[0]'`
aws ecs update-service --service << parameters.service_name >> --cluster << parameters.ecs_cluster >> --task-definition ${NEW_TASK}
jobs:
test:
docker:
# image for running tests
- image: cypress/browsers:node16.14.0-chrome99-ff97
- image: cypress/browsers:node18.12.0-chrome103-ff107
environment:
- DB_NAME=lunch_test
- DB_USER=lunch_test
Expand Down Expand Up @@ -68,9 +105,9 @@ jobs:
echo 127.0.0.1 integration-test.local.lunch.pink | tee -a /etc/hosts
# build the app
- run:
name: build-release
command: NODE_ENV=test npm run build
# - run:
# name: build-release
# command: NODE_ENV=test npm run build

- run:
name: integration-tests
Expand All @@ -89,68 +126,83 @@ jobs:

build:
docker:
- image: ${BUILD_IMAGE}
- image: cimg/aws:2023.01

working_directory: ~/repo
# working_directory: ~/repo

steps:
- checkout

- setup_remote_docker:
version: 20.10.11
docker_layer_caching: true

- run:
name: dotenv
command: touch .env && touch .env.prod

# Download and cache dependencies
- restore_cache:
keys:
- v1-build-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-build-dependencies-
# # Download and cache dependencies
# - restore_cache:
# keys:
# - v1-build-dependencies-{{ checksum "package.json" }}
# # fallback to using the latest cache if no exact match is found
# - v1-build-dependencies-

# install deps
- run:
name: yarn-install
command: yarn install
# # install deps
# - run:
# name: yarn-install
# command: yarn install

- save_cache:
paths:
- node_modules
key: v1-build-dependencies-{{ checksum "package.json" }}
# - save_cache:
# paths:
# - node_modules
# key: v1-build-dependencies-{{ checksum "package.json" }}

- node/install-packages:
pkg-manager: yarn

# build the release
- run:
name: build-release
command: npm run build -- --release --verbose

- setup_remote_docker
# - setup_remote_docker

# build and push a docker image (script is defined in the custom build image)
# build and push a docker image
- run:
name: build-docker-image
command: ../buildImage.sh
command: |
CLEAN_BRANCH=`echo $CIRCLE_BRANCH | sed 's/\//-/g'`
DOCKER_TAG=${BUILD_CONTAINER_REPOSITORY}:${CIRCLE_SHA1}
docker build --tag ${DOCKER_TAG} .
aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin ${CONTAINER_REGISTRY}
docker push ${DOCKER_TAG}
deploy-staging:
docker:
- image: ${BUILD_IMAGE}
- image: cimg/aws:2023.01

working_directory: ~/repo
# working_directory: ~/repo

steps:
# update ECS task and service with image build above (script is defined in custom build image)
- run:
name: update-service
command: ../deployStaging.sh
- aws-deploy:
task_family: lunch-staging
ecs_cluster: Lunch-Staging
service_name: lunch-staging
migration_task: staging_lunch_migrate

deploy-production:
docker:
- image: ${BUILD_IMAGE}
- image: cimg/aws:2023.01

working_directory: ~/repo
# working_directory: ~/repo

steps:
- run:
name: update_service
command: ../deployProduction.sh
- aws-deploy:
task_family: lunch
ecs_cluster: Lunch
service_name: lunch
migration_task: lunch_migrate

# WORKFLOW DEFINITIONS
workflows:
Expand Down
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Dockerfile
node_modules
tmp
temp
postgres-data
20 changes: 0 additions & 20 deletions .editorconfig

This file was deleted.

2 changes: 1 addition & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SUPERUSER_EMAIL=
# Credentials for your Google Developer app
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_CLIENT_APIKEY= # optional
GOOGLE_CLIENT_APIKEY=
GOOGLE_SERVER_APIKEY=

# Google Analytics ID
Expand Down
27 changes: 23 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@
// ESLint configuration
// http://eslint.org/docs/user-guide/configuring
module.exports = {
parser: 'babel-eslint',
parser: '@typescript-eslint/parser',

extends: [
'airbnb',
'plugin:flowtype/recommended',
'plugin:css-modules/recommended',
'plugin:@typescript-eslint/recommended'
],

plugins: [
'flowtype',
'css-modules',
'@typescript-eslint',
'import'
],

globals: {
Expand All @@ -31,16 +32,18 @@ module.exports = {
browser: true,
},

root: true,

rules: {
// `js` and `jsx` are common extensions
// `mjs` is for `universal-router` only, for now
'import/extensions': [
'error',
'always',
{
js: 'never',
jsx: 'never',
mjs: 'never',
ts: 'never',
},
],

Expand Down Expand Up @@ -77,6 +80,7 @@ module.exports = {
'key-spacing': 0,
'no-confusing-arrow': 0,
'react/jsx-quotes': 0,
'react/jsx-props-no-spreading': 0,
'max-len': 0,
'jsx-quotes': [
2,
Expand All @@ -88,15 +92,30 @@ module.exports = {

'react/forbid-prop-types': 'off',
'react/destructuring-assignment': 'off',
'react/function-component-definition': ['error', {
namedComponents: 'arrow-function',
unnamedComponents: 'arrow-function'
}],
'react/static-property-placement': 'off',
'import/no-relative-packages': 'off',
'import/no-import-module-exports': 'off'
},

settings: {
// Allow absolute paths in imports, e.g. import Button from 'components/Button'
// https://github.com/benmosher/eslint-plugin-import/tree/master/resolvers
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
moduleDirectory: ['node_modules', 'src'],
},
typescript: {
alwaysTryTypes: true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
extensions: ['.ts', '.tsx'],
}
},
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
},
};
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@ cypress/videos/
deploy.sh
test-results.xml
screenshots
Dockerfile.bak

#Docker postgres-data
postgres-data
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm test && npx lint-staged
6 changes: 6 additions & 0 deletions .mocharc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
extension: ['ts'],
require: ['./test/setup'],
exit: true,
file: './test/mocha-setup',
};
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18.14.0
14 changes: 7 additions & 7 deletions .stylelintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
* LICENSE.txt file in the root directory of this source tree.
*/

const lowerKebabCase = /^[a-z][a-zA-Z0-9]+$/;

// stylelint configuration
// https://stylelint.io/user-guide/configuration/
module.exports = {

// The standard config based on a handful of CSS style guides
// https://github.com/stylelint/stylelint-config-standard
extends: 'stylelint-config-standard',
extends: 'stylelint-config-standard-scss',

plugins: [
// stylelint plugin to sort CSS rules content with specified order
Expand All @@ -22,13 +24,10 @@ module.exports = {
],

rules: {
'at-rule-no-unknown': [
true,
{
ignoreAtRules: ['include', 'mixin'],
},
],
'at-rule-no-unknown': null,
'scss/at-rule-no-unknown': true,
'declaration-empty-line-before': null,
'keyframes-name-pattern': lowerKebabCase,
'number-leading-zero': 'never',
'property-no-unknown': [true, {
ignoreProperties: [
Expand All @@ -38,6 +37,7 @@ module.exports = {
'overflow-anchor'
],
}],
'selector-class-pattern': lowerKebabCase,

'selector-pseudo-class-no-unknown': [
true,
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16.17.0
FROM node:18.14.0

# Set a working directory
WORKDIR /usr/src/app
Expand Down
12 changes: 12 additions & 0 deletions Dockerfile.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:18.14.0

# Set a working directory
WORKDIR /app

# Install dependencies based on the preferred package manager
COPY package.json yarn.lock ./
RUN yarn --frozen-lockfile

COPY . .

CMD [ "npm", "start" ]
Loading

0 comments on commit 64fa6c8

Please sign in to comment.