Skip to content

Commit

Permalink
chore: move files out of src/ (#300)
Browse files Browse the repository at this point in the history
* chore: remove outdated koa2-oauth-server and bump to node 16

* chore: change

* chore: bump audit

* chore: changes

* chore: ci

* chore: move files out of src/

* chore: path fixes

* chore: path fixes

* chore: path
  • Loading branch information
kleyow authored Apr 19, 2022
1 parent ef42058 commit b80f943
Show file tree
Hide file tree
Showing 160 changed files with 849 additions and 321 deletions.
52 changes: 25 additions & 27 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,12 @@ defaults_license_scanner: &defaults_license_scanner
defaults_npm_auth: &defaults_npm_auth
name: Update NPM registry auth token
command: cd src; echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc

defaults_npm_publish_release: &defaults_npm_publish_release
name: Publish NPM $RELEASE_TAG artifact
command: |
source $BASH_ENV
cd src
echo "Publishing tag $RELEASE_TAG"
npm publish --tag $RELEASE_TAG --access public
Expand Down Expand Up @@ -89,14 +88,14 @@ jobs:
command: cd $(npm root -g)/npm
- run:
name: Update NPM install (using `npm ci`)
command: cd src && npm ci
command: npm ci
- run:
name: Delete build dependencies
command: apk del build-dependencies
- save_cache:
key: dependency-cache-v3-{{ checksum "src/package-lock.json" }}
key: dependency-cache-v3-{{ checksum "package-lock.json" }}
paths:
- src/node_modules
- node_modules

test-unit:
executor: default-docker
Expand All @@ -106,14 +105,14 @@ jobs:
command: *defaults_Dependencies
- checkout
- restore_cache:
key: dependency-cache-v3-{{ checksum "src/package-lock.json" }}
key: dependency-cache-v3-{{ checksum "package-lock.json" }}
- run:
name: Execute unit tests
command: cd src && npm run test
command: npm run test
- store_test_results:
path: /home/circleci/project/src/
path: /home/circleci/project/
- store_artifacts:
path: /home/circleci/project/src/junit.xml
path: /home/circleci/project/junit.xml

test-integration:
executor: default-machine
Expand All @@ -126,7 +125,7 @@ jobs:
chmod +x ~/docker-compose
sudo mv ~/docker-compose /usr/local/bin/docker-compose
- restore_cache:
key: dependency-cache-v3-{{ checksum "src/package-lock.json" }}
key: dependency-cache-v3-{{ checksum "package-lock.json" }}
- run:
name: Set up NVM
command: |
Expand All @@ -152,14 +151,13 @@ jobs:
name: Execute integration tests
command: |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
cd src
npm ci
npm run test:int
- run:
name: prepare test/results
command: |
mkdir -p test/results
mv src/junit.xml test/results
mv junit.xml test/results
- store_artifacts:
path: ./test/results
- store_test_results:
Expand All @@ -173,10 +171,10 @@ jobs:
command: *defaults_Dependencies
- checkout
- restore_cache:
key: dependency-cache-v3-{{ checksum "src/package-lock.json" }}
key: dependency-cache-v3-{{ checksum "package-lock.json" }}
- run:
name: Execute unit tests
command: cd src && npm run build:openapi && npm run validate:api
command: npm run build:openapi && npm run validate:api

lint:
executor: default-docker
Expand All @@ -186,13 +184,13 @@ jobs:
command: *defaults_Dependencies
- checkout
- restore_cache:
key: dependency-cache-v3-{{ checksum "src/package-lock.json" }}
key: dependency-cache-v3-{{ checksum "package-lock.json" }}
- run:
name: Create dir for lint results
command: cd src && mkdir -p /lintresults
command: mkdir -p /lintresults
- run:
name: Execute linting
command: cd src && (npm run lint > /lintresults/results.txt)
command: (npm run lint > /lintresults/results.txt)
- store_artifacts:
path: /lintresults

Expand All @@ -204,13 +202,13 @@ jobs:
command: *defaults_Dependencies
- checkout
- restore_cache:
key: dependency-cache-v3-{{ checksum "src/package-lock.json" }}
key: dependency-cache-v3-{{ checksum "package-lock.json" }}
- run:
name: Create dir for test results
command: mkdir -p ./audit/results
- run:
name: Check for new npm vulnerabilities
command: cd src && npm run audit:check --silent -- --json > ../audit/results/auditResults.json
command: npm run audit:check --silent -- --json > ./audit/results/auditResults.json
- store_artifacts:
path: ./audit/results

Expand All @@ -224,10 +222,10 @@ jobs:
- run:
<<: *defaults_license_scanner
- restore_cache:
key: dependency-cache-v3-{{ checksum "src/package-lock.json" }}
key: dependency-cache-v3-{{ checksum "package-lock.json" }}
- run:
name: Prune non-production packages before running license-scanner
command: cd src && npm prune --production
command: npm prune --production
- run:
name: Run the license-scanner
command: cd /tmp/license-scanner && pathToRepo=$CIRCLE_WORKING_DIRECTORY make run
Expand Down Expand Up @@ -326,7 +324,7 @@ jobs:
command: *defaults_Dependencies
- checkout
- restore_cache:
key: dependency-cache-v3-{{ checksum "src/package-lock.json" }}
key: dependency-cache-v3-{{ checksum "package-lock.json" }}
- run:
name: Configure git
command: |
Expand All @@ -341,7 +339,7 @@ jobs:
ssh-keyscan github.com >> ~/.ssh/known_hosts
- run:
name: Generate changelog and bump package version
command: cd src && npm run release
command: npm run release
- run:
name: Push the release
command: git push --follow-tags origin ${CIRCLE_BRANCH}
Expand All @@ -365,9 +363,9 @@ jobs:
# Note: this is rather imperfect, but will do for now
name: Format the changelog into the github release body and get release tag
command: |
git diff --no-indent-heuristic master~1 HEAD src/CHANGELOG.md | sed -n '/^+[^+]/ s/^+//p' > /tmp/changes
git diff --no-indent-heuristic master~1 HEAD CHANGELOG.md | sed -n '/^+[^+]/ s/^+//p' > /tmp/changes
echo 'export RELEASE_CHANGES=`cat /tmp/changes`' >> $BASH_ENV
echo 'export RELEASE_TAG=`cat src/package-lock.json | jq -r .version`' >> $BASH_ENV
echo 'export RELEASE_TAG=`cat package-lock.json | jq -r .version`' >> $BASH_ENV
- run:
name: check the release changes
command: |
Expand All @@ -377,7 +375,7 @@ jobs:
tag: v${RELEASE_TAG}
title: v${RELEASE_TAG} Release
description: ${RELEASE_CHANGES}
file-path: src/CHANGELOG.md
file-path: CHANGELOG.md
- slack/status:
webhook: "$SLACK_WEBHOOK_ANNOUNCEMENT"
success_message: '*"${CIRCLE_PROJECT_REPONAME}"* - Release \`"v${RELEASE_TAG}"\` \nhttps://github.com/mojaloop/"${CIRCLE_PROJECT_REPONAME}"/releases/tag/"v${RELEASE_TAG}"'
Expand Down Expand Up @@ -415,7 +413,7 @@ jobs:
name: Install general dependencies
command: *defaults_Dependencies
- restore_cache:
key: dependency-cache-v3-{{ checksum "src/package-lock.json" }}
key: dependency-cache-v3-{{ checksum "package-lock.json" }}
- run:
name: setup environment vars for LATEST release
command: |
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ WORKDIR /src
# This is super-ugly, but it means we don't have to re-run npm install every time any of the source
# files change- only when any dependencies change- which is a superior developer experience when
# relying on docker-compose.
COPY ./src/package.json .
COPY ./src/package-lock.json .
COPY ./package.json .
COPY ./package-lock.json .
RUN npm ci --only=production
FROM node:16-alpine

Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
- mojaloop-net
build:
context: .
env_file: ./src/test/config/integration.env
env_file: ./test/config/integration.env
ports:
- "4000:4000"
- "4001:4001"
Expand Down Expand Up @@ -64,4 +64,4 @@ services:
# - AUTH_ENABLED=FALSE
# command:
# - sh
# - /usr/share/nginx/start.sh
# - /usr/share/nginx/start.sh
5 changes: 4 additions & 1 deletion src/jest.config.js → jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ module.exports = {
lines: 90
}
},
clearMocks: true
clearMocks: true,
moduleNameMapper: {
"^~/(.*)$": "<rootDir>/src/$1"
}
};
Loading

0 comments on commit b80f943

Please sign in to comment.