Skip to content
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

chore: replace local module with shared folder #1144

Merged
merged 15 commits into from May 27, 2021
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 17 additions & 4 deletions .travis.yml
Expand Up @@ -17,8 +17,10 @@ jobs:
- cd $TRAVIS_BUILD_DIR/backend
- npx lockfile-lint --type npm --path package-lock.json -o "https:" -o "file:" --allowed-hosts npm
install:
- npm ci
- cd $TRAVIS_BUILD_DIR/shared && npm ci
- cd $TRAVIS_BUILD_DIR/backend && npm ci
script:
- npm run build
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you help explain why we didn't need the build step previously but have included it now? I guess its to build the shared module, but where was the backend being built previously

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep - this is to build the shared module. Previously there was not need to separate build the backend because npm test handles it. However, ts-jest does not automatically compile project references.

- npm run lint-no-fix
- npm run test
before_deploy:
Expand Down Expand Up @@ -73,8 +75,10 @@ jobs:
- cd $TRAVIS_BUILD_DIR/worker
- npx lockfile-lint --type npm --path package-lock.json -o "https:" -o "file:" --allowed-hosts npm
install:
- npm ci
- cd $TRAVIS_BUILD_DIR/shared && npm ci
- cd $TRAVIS_BUILD_DIR/worker && npm ci
script:
- npm run build
- npm run lint-no-fix
before_deploy:
- cd $TRAVIS_BUILD_DIR/worker && ./before-deploy.sh
Expand All @@ -93,15 +97,24 @@ jobs:
condition: "$DEPLOY_WORKER = true"
- name: frontend
before_install:
- cd $TRAVIS_BUILD_DIR/shared && npm install
- cd $TRAVIS_BUILD_DIR/frontend
install:
- npm install
script:
- CI=false npm run build
- npm run test
- npx lockfile-lint --type npm --path package-lock.json -o "https:" -o "file:" --allowed-hosts npm
- npm run compile
- npm run lint-no-fix
- CI=false npm run build
- name: shared
before_install:
- cd $TRAVIS_BUILD_DIR/shared
install:
- npm install
script:
- npm run build
- npm run test
- npx lockfile-lint --type npm --path package-lock.json -o "https:" -o "file:" --allowed-hosts npm
- name: serverless-unsubscribe-digest
before_install:
- cd $TRAVIS_BUILD_DIR/serverless/unsubscribe-digest
Expand Down
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -191,6 +191,10 @@ env:
$ git checkout develop
$ git checkout -b release-v1.7.0

# Bump shared module version
$ cd ../ && cd shared/
$ npm version minor

# Bump frontend version
$ cd frontend/
$ npm version minor
Expand Down
4 changes: 2 additions & 2 deletions amplify.yml
Expand Up @@ -23,8 +23,8 @@ frontend:
export REACT_APP_BACKEND_URL=${BACKEND_URL_STAGING} &&
export REACT_APP_SENTRY_ENVIRONMENT="staging";
fi
- cd frontend
- npm ci
- cd shared && npm ci && cd ..
- cd frontend && npm ci
- export REACT_APP_SENTRY_RELEASE=$(npm run --silent get-sentry-release)
build:
commands:
Expand Down
3 changes: 2 additions & 1 deletion backend/Dockerfile
Expand Up @@ -12,7 +12,8 @@ RUN aws configure set default.region ap-southeast-1

WORKDIR /usr/home/postmangovsg

COPY modules ../modules
COPY shared ../shared
RUN cd ../shared && npm ci && cd ../postmangovsg

COPY ./package* ./
RUN npm ci
Expand Down
2 changes: 1 addition & 1 deletion backend/before-deploy.sh
@@ -1,7 +1,7 @@
#!/bin/bash

# Copy local module
cp -R ../modules ./
cp -R ../shared ./
# Replace the secret id according to the right branch
# Using '#' as a delimiter for SED instead of '/'
# '/' will clash with secret id names, eg: 'staging/eb/postmangovsg-staging-40ffadb'
Expand Down
1 change: 1 addition & 0 deletions backend/jest.config.js
Expand Up @@ -8,6 +8,7 @@ module.exports = {
'@email/(.*)': '<rootDir>/src/email/$1',
'@telegram/(.*)': '<rootDir>/src/telegram/$1',
'@test-utils/(.*)': '<rootDir>/src/test-utils/$1',
'@shared/(.*)': '<rootDir>/../shared/src/$1',
},
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
Expand Down