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

Revert "Feat/cb2-11225 Update cvs-svc-defects backend repo to use ser… #194

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 3 additions & 4 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ on:

jobs:
build-test:
runs-on: X64
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
Expand All @@ -30,7 +30,6 @@ jobs:
- name: Setup local dynamo
run: npm run tools-setup
- name: Build and test
timeout-minutes: 20
run: npm run prepush
env:
AWS_ACCESS_KEY_ID: foo
Expand Down
6,942 changes: 3,392 additions & 3,550 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
"url": "https://github.com/dvsa/cvs-svc-defects.git"
},
"scripts": {
"start": "BRANCH=local SLS_DEBUG=* serverless offline start --noPrependStageInUrl",
"start": "BRANCH=local SLS_DEBUG=* serverless offline start",
"tools-setup": "sls dynamodb install",
"test": "npm run test:unit:coverage",
"test:unit": "BRANCH=local SLS_DEBUG=* jest --testMatch=\"**/*.unitTest.ts\"",
"test:unit:coverage": "npm run test:unit -- --coverage --runInBand",
"test:integration": "BRANCH=local jest --testMatch=\"**/*.intTest.ts\" --detectOpenHandles",
"test:integration": "BRANCH=local jest --testMatch=\"**/*.intTest.ts\"",
"test-i": "AWS_SDK_JS_SUPPRESS_MAINTENANCE_MODE_MESSAGE=1 npm run test:integration -- --runInBand --globalSetup='./scripts/setUp.ts' --globalTeardown='./scripts/tearDown.ts'",
"build": "node_modules/typescript/bin/tsc --rootDir ./ --outDir .build --sourceMap false && npm run build:copy",
"build:copy": "find src -type f \\( -name \"*.yml\" -or -name \"*.json\" \\) | cpio -pdm .build && find tests -type f \\( -name \"*.yml\" -or -name \"*.json\" \\) | cpio -pdm .build",
Expand All @@ -29,6 +29,7 @@
"audit": "npm audit --prod",
"predeploy": "npm install && npm run prepush",
"package": "mkdir ${ZIP_NAME} && cp package.json package-lock.json ${ZIP_NAME}/ && cp -r .build/src/* ${ZIP_NAME}/ && cd ${ZIP_NAME} && npm ci --omit=dev --ignore-scripts && rm package.json package-lock.json && zip -qr ../${ZIP_NAME}.zip .",
"postinstall": "patch-package",
"precommit": "npm run security-checks && npm run audit && npm run lint && npm run format",
"commit-msg": "commitlint --edit $1",
"prepare": "husky install"
Expand Down Expand Up @@ -56,8 +57,10 @@
"jest-sonar-reporter": "^2.0.0",
"lambda-tester": "^4.0.1",
"lodash": "^4.17.21",
"patch-package": "^6.5.1",
"prettier": "3.0.3",
"serverless": "^2.43.1",
"serverless-dynamodb-local": "0.2.40",
"serverless-offline": "^5.12.0",
"serverless-plugin-tracing": "^2.0.0",
"serverless-plugin-typescript": "^2.1.4",
Expand All @@ -77,8 +80,7 @@
"js-yaml": "3.14.1",
"node-yaml": "4.0.1",
"path-parser": "^6.1.0",
"reflect-metadata": "^0.1.13",
"serverless-dynamodb": "0.2.50"
"reflect-metadata": "^0.1.13"
},
"jestSonar": {
"reportPath": ".reports",
Expand Down
34 changes: 34 additions & 0 deletions patches/dynamodb-localhost+0.0.9.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
diff --git a/node_modules/dynamodb-localhost/dynamodb/config.json b/node_modules/dynamodb-localhost/dynamodb/config.json
index dc7d7a3..a4420cb 100644
--- a/node_modules/dynamodb-localhost/dynamodb/config.json
+++ b/node_modules/dynamodb-localhost/dynamodb/config.json
@@ -1,6 +1,6 @@
{
"setup": {
- "download_url": "http://s3-us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.tar.gz",
+ "download_url": "https://s3-us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_2023-06-09.tar.gz",
"install_path": "bin",
"jar": "DynamoDBLocal.jar"
},
diff --git a/node_modules/dynamodb-localhost/dynamodb/installer.js b/node_modules/dynamodb-localhost/dynamodb/installer.js
index c2789c7..874c1c2 100644
--- a/node_modules/dynamodb-localhost/dynamodb/installer.js
+++ b/node_modules/dynamodb-localhost/dynamodb/installer.js
@@ -3,7 +3,7 @@
var tar = require("tar"),
zlib = require("zlib"),
path = require("path"),
- http = require("http"),
+ https = require("https"),
fs = require("fs"),
ProgressBar = require("progress"),
utils = require("./utils");
@@ -12,7 +12,7 @@ var download = function(downloadUrl, installPath, callback) {
console.log(
`Started downloading dynamodb-local from ${downloadUrl} into ${installPath}. Process may take few minutes.`
);
- http
+ https
.get(downloadUrl, function(response) {
var len = parseInt(response.headers["content-length"], 10),
bar = new ProgressBar(
2 changes: 1 addition & 1 deletion scripts/getDBPid.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lsof -i:8003 | awk '{print $2}' | tail -1
lsof -i:8003 | awk '{print $2}' | grep -v '^PID'
8 changes: 2 additions & 6 deletions scripts/setUp.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { exec } from "child_process";
import { spawn } from "child_process";

// We hook to serverless offline when firing its process
const SERVER_OK = `Offline [HTTP] listening on http://localhost:3001`;
Expand Down Expand Up @@ -33,11 +33,7 @@ const setupServer = (process: any) => {
});
};

const server = exec("npm run start &", (error) => {
if (error) {
console.error(`error starting server: ${error}`);
}
});
const server = spawn("npm", ["run", "start"], {});

module.exports = async () => {
console.log(`\nSetting up Integration tests...\n\n`);
Expand Down
6 changes: 3 additions & 3 deletions scripts/tearDown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { killTestSetup } from "./destroyServices";

module.exports = async () => {
console.log(`
Integration tests ✅
...Tearing down tests...
`);
Integration tests ✅
...Tearing down tests...
`);
// Serverless runs containers and pid's are not managed the same way in the CI/CD pipeline
// We are not using the pid of our instance to kill the task
// instead created sh commands to manually kill the webserver and dynamoDB instances which work equally in the pipeline
Expand Down
10 changes: 2 additions & 8 deletions serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ service: cvs-svc-defect
# from 3.0 warnings will be thrown as errors
configValidationMode: warn
plugins:
- serverless-dynamodb
- serverless-dynamodb-local
- serverless-plugin-typescript
- serverless-plugin-tracing
- serverless-offline
Expand All @@ -13,8 +13,6 @@ provider:
runtime: nodejs18.x
tracing:
apiGateway: true
region: eu-west-1
stage: dev
iam:
role:
statements:
Expand All @@ -27,16 +25,12 @@ provider:

functions:
getDefects:
environment:
BRANCH: local
handler: src/handler.handler
events:
- http:
path: defects
method: get
getRequiredStandards:
environment:
BRANCH: local
handler: src/handler.handler
events:
- http:
Expand All @@ -46,7 +40,7 @@ functions:
custom:
serverless-offline:
port: 3001
serverless-dynamodb:
dynamodb:
stages:
- dev
- test
Expand Down
8 changes: 1 addition & 7 deletions src/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ functions:
proxy: null
function: getRequiredStandards
event: apigateway

invoke:
local:
params:
Expand Down Expand Up @@ -62,10 +63,3 @@ dynamodb:
serverless:
basePath: /${BRANCH}
port: 3001
Resources:
Schedule:
Type: AWS::Scheduler::Schedule
Properties:
ScheduleExpression: rate(1 minute)
FlexibleTimeWindow:
Mode: "OFF"
Loading