Skip to content

Commit

Permalink
Updated path for package.json for yarn install step
Browse files Browse the repository at this point in the history
  • Loading branch information
LAKSHMIRPILLAI committed Sep 29, 2023
1 parent 64a96c0 commit bfdf697
Show file tree
Hide file tree
Showing 11 changed files with 1,006 additions and 738 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
node-version-file: 'support-lambdas/support-post-deployment-tests/.nvmrc'
cache: "yarn"
cache-dependency-path: |
support-lambdas/support-post-deployment-tests/yarn.lock
- run: |
yarn install
yarn build
yarn package
yarn postbuild
working-directory: support-lambdas/support-post-deployment-tests
- name: CDK synth
run: |
yarn install
Expand Down
5 changes: 3 additions & 2 deletions support-lambdas/support-post-deployment-tests/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "example-typecript-lambda",
"name": "support-frontend-post-deployments-tests-lambda",
"version": "1.0.0",
"private": true,
"scripts": {
"test": "npm run test --workspaces --if-present",
"lint": "eslint packages/** --ext .ts --no-error-on-unmatched-pattern",
"format": "prettier --write packages/**/*.ts",
"build": "npm run build --workspaces --if-present"
"build": "npm run build --workspaces --if-present",
"postbuild":"npm run postbuild --workspaces --if-present"
},
"workspaces": [
"packages/*"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import 'source-map-support/register';
import { GuRootExperimental } from '@guardian/cdk/lib/experimental/constructs';
import { LoggingLevel,SupportFrontendPostDeploymentTestsLambda } from '../lib/support-frontend-post-deployment-tests-lambda';
import {
LoggingLevel,
SupportFrontendPostDeploymentTestsLambda,
} from '../lib/support-frontend-post-deployment-tests-lambda';

/**
* GuRootExperimental will generate a `riff-raff.yaml` configuration file to deploy this project with Riff-Raff.
Expand All @@ -9,50 +12,58 @@ import { LoggingLevel,SupportFrontendPostDeploymentTestsLambda } from '../lib/su
*/
const app = new GuRootExperimental();

new SupportFrontendPostDeploymentTestsLambda(app, 'SupportFrontendPostDeploymentTestsLambda-CODE', {
/**
* This becomes the value of the STACK tag on provisioned resources.
*
* It is also used by Riff-Raff to determine the AWS account to deploy into.
*
* @see https://riffraff.gutools.co.uk/deployinfo/data?key=credentials%3Aaws-cfn-role
*/
stack: 'membership',

/**
* This becomes the value of the STAGE tag on provisioned resources.
*/
stage: 'CODE',

env: {
new SupportFrontendPostDeploymentTestsLambda(
app,
'SupportFrontendPostDeploymentTestsLambda-CODE',
{
/**
* Which AWS region should this service be deployed into?
* This becomes the value of the STACK tag on provisioned resources.
*
* It is also used by Riff-Raff to determine the AWS account to deploy into.
*
* @see https://riffraff.gutools.co.uk/deployinfo/data?key=credentials%3Aaws-cfn-role
*/
region: 'eu-west-1',
},
stack: 'membership',

},LoggingLevel.DEBUG);
/**
* This becomes the value of the STAGE tag on provisioned resources.
*/
stage: 'CODE',

new SupportFrontendPostDeploymentTestsLambda(app, 'SupportFrontendPostDeploymentTestsLambda-PROD', {
/**
* This becomes the value of the STACK tag on provisioned resources.
*
* It is also used by Riff-Raff to determine the AWS account to deploy into.
*
* @see https://riffraff.gutools.co.uk/deployinfo/data?key=credentials%3Aaws-cfn-role
*/
stack: 'membership',
env: {
/**
* Which AWS region should this service be deployed into?
*/
region: 'eu-west-1',
},
},
LoggingLevel.DEBUG,
);

/**
* This becomes the value of the STAGE tag on provisioned resources.
*/
stage: 'PROD',
new SupportFrontendPostDeploymentTestsLambda(
app,
'SupportFrontendPostDeploymentTestsLambda-PROD',
{
/**
* This becomes the value of the STACK tag on provisioned resources.
*
* It is also used by Riff-Raff to determine the AWS account to deploy into.
*
* @see https://riffraff.gutools.co.uk/deployinfo/data?key=credentials%3Aaws-cfn-role
*/
stack: 'membership',

env: {
/**
* Which AWS region should this service be deployed into?
*/
region: 'eu-west-1',
},
},LoggingLevel.INFO);
/**
* This becomes the value of the STAGE tag on provisioned resources.
*/
stage: 'PROD',

env: {
/**
* Which AWS region should this service be deployed into?
*/
region: 'eu-west-1',
},
},
LoggingLevel.INFO,
);
Original file line number Diff line number Diff line change
@@ -1,28 +1,40 @@
import { App } from 'aws-cdk-lib';
import { Template } from 'aws-cdk-lib/assertions';
import { SupportFrontendPostDeploymentTestsLambda } from './support-frontend-post-deployment-tests-lambda';
import {
LoggingLevel,
SupportFrontendPostDeploymentTestsLambda,
} from './support-frontend-post-deployment-tests-lambda';

describe('The SupportFrontendPostDeploymentTestsLambda stack', () => {
it('matches the snapshot', () => {
const app = new App();
const codeStack = new SupportFrontendPostDeploymentTestsLambda(app, "SupportFrontendPostDeploymentTestsLambda-CODE", {
stack: "support",
stage: "CODE",
env: {
region: 'eu-west-1',
},
});
const prodStack = new SupportFrontendPostDeploymentTestsLambda(app, "SupportFrontendPostDeploymentTestsLambda-PROD", {
stack: "support",
stage: "PROD",
env: {
region: 'eu-west-1',
},
});

expect(Template.fromStack(codeStack).toJSON()).toMatchSnapshot();
expect(Template.fromStack(prodStack).toJSON()).toMatchSnapshot();
const app = new App();
const codeStack = new SupportFrontendPostDeploymentTestsLambda(
app,
'SupportFrontendPostDeploymentTestsLambda-CODE',
{
stack: 'support',
stage: 'CODE',
env: {
region: 'eu-west-1',
},
},
LoggingLevel.DEBUG,
);
const prodStack = new SupportFrontendPostDeploymentTestsLambda(
app,
'SupportFrontendPostDeploymentTestsLambda-PROD',
{
stack: 'support',
stage: 'PROD',
env: {
region: 'eu-west-1',
},
},
LoggingLevel.INFO,
);

expect(Template.fromStack(codeStack).toJSON()).toMatchSnapshot();
expect(Template.fromStack(prodStack).toJSON()).toMatchSnapshot();

/**
* Snapshot testing helps to understand exactly what impact a CDK change will have on the provisioned infrastructure.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,47 @@ import { Runtime } from 'aws-cdk-lib/aws-lambda';
const APP_NAME = 'support-frontend-post-deployment-tests-lambda';

export enum LoggingLevel {
SILLY,
TRACE,
DEBUG,
INFO,
WARN,
ERROR,
FATAL,
SILLY,
TRACE,
DEBUG,
INFO,
WARN,
ERROR,
FATAL,
}

export class SupportFrontendPostDeploymentTestsLambda extends GuStack {
constructor(
scope: App,
id: string,
props: GuStackProps,
loggingLevel: number = LoggingLevel.WARN,
) {
super(scope, id, props);
constructor(
scope: App,
id: string,
props: GuStackProps,
loggingLevel: number = LoggingLevel.WARN,
) {
super(scope, id, props);

const otherConfig = {
app: APP_NAME,
runtime: Runtime.NODEJS_18_X,
fileName: `${APP_NAME}.zip`,
timeout: Duration.millis(45000),
};
const otherConfig = {
app: APP_NAME,
runtime: Runtime.NODEJS_18_X,
fileName: `${APP_NAME}.zip`,
timeout: Duration.millis(45000),
environment: {
Bucket: `membership-dist`,
Stage: this.stage,
LoggingLevel: loggingLevel.toString(),
},
};

new GuScheduledLambda(this, APP_NAME, {
handler: 'dist/lambda/index.handler',
rules: [
{
schedule: Schedule.cron({ hour: '10', minute: '00', weekDay: '2' }),
},
],
monitoringConfiguration: {
noMonitoring: true,
},
...otherConfig,
});
}
new GuScheduledLambda(this, APP_NAME, {
handler: 'dist/lambda/index.handler',
rules: [
{
schedule: Schedule.cron({ hour: '10', minute: '00', weekDay: '2' }),
},
],
monitoringConfiguration: {
noMonitoring: true,
},
...otherConfig,
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,33 @@
"name": "cdk",
"version": "0.0.0",
"private": true,
"bin": {
"cdk": "bin/cdk.js"
},
"scripts": {
"build": "tsc",
"test": "jest --detectOpenHandles --config ../../jest.config.js --selectProjects cdk",
"format": "prettier --write \"{lib,bin}/**/*.ts\"",
"cdk": "cdk",
"synth": "cdk synth --path-metadata false --version-reporting false",
"diff": "cdk diff --path-metadata false --version-reporting false"
"diff": "cdk diff --path-metadata false --version-reporting false",
"lint": "eslint lib/** bin/** --ext .ts --no-error-on-unmatched-pattern"
},
"devDependencies": {
"@guardian/cdk": "50.10.13",
"@guardian/eslint-config-typescript": "1.0.11",
"@guardian/prettier": "2.1.5",
"@types/jest": "^29.5.5",
"@types/node": "20.5.9",
"aws-cdk": "2.90.0",
"aws-cdk-lib": "2.90.0",
"constructs": "10.2.69",
"source-map-support": "^0.5.20"
"source-map-support": "^0.5.20",
"eslint": "^8.48.0",
"jest": "^29.6.4",
"prettier": "^2.8.8",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "~4.9.5"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "./tsconfig.json",
"include": ["lib/**/*", "bin/**/*"],
"exclude": ["node_modules"]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
{
"extends": "../../tsconfig.json",
"ts-node": {
"compilerOptions": {
"module": "CommonJS"
}
},
"compilerOptions": {
"target": "ES2020",
"module": "ES2020",
"moduleResolution": "node",
"lib": ["ES2020"],
"declaration": true,
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"esModuleInterop": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": false,
"inlineSourceMap": true,
"inlineSources": true,
"experimentalDecorators": true,
"strictPropertyInitialization": false,
"typeRoots": ["./node_modules/@types"],
"outDir": "dist"
},
"include": ["lib/**/*", "bin/**/*"],
"exclude": ["node_modules", "cdk.out", "dist"]
"exclude": ["node_modules", "cdk.out", "dist",
"lib/**/__snapshots__/**"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ const { bsLocal } = require('./browserstack.config');
const { promisify } = require('util');
const sleep = promisify(setTimeout);
module.exports = async () => {
// Stop the Local instance after your test run is completed, i.e after driver.quit
let localStopped = false;
// Stop the Local instance after your test run is completed, i.e after driver.quit
let localStopped = false;

if (bsLocal && bsLocal.isRunning()) {
bsLocal.stop(() => {
localStopped = true;
console.log('Stopped BrowserStackLocal');
});
while (!localStopped) {
await sleep(1000);
}
}
}
if (bsLocal && bsLocal.isRunning()) {
bsLocal.stop(() => {
localStopped = true;
console.log('Stopped BrowserStackLocal');
});
while (!localStopped) {
await sleep(1000);
}
}
};
Loading

0 comments on commit bfdf697

Please sign in to comment.