-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #367 from guardian/aa-publish
chore: add an integration test project
- Loading branch information
Showing
22 changed files
with
246 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
cdk.out | ||
.eslintrc.js | ||
jest.config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module.exports = { | ||
root: true, | ||
env: { | ||
node: true, | ||
jest: true, | ||
}, | ||
extends: ["@guardian/eslint-config-typescript"], | ||
parserOptions: { | ||
ecmaVersion: 2020, | ||
tsconfigRootDir: __dirname, | ||
sourceType: "module", | ||
project: ["./tsconfig.eslint.json"], | ||
}, | ||
plugins: ["@typescript-eslint"], | ||
rules: { | ||
"@typescript-eslint/no-inferrable-types": 0, | ||
"import/no-namespace": 2, | ||
}, | ||
ignorePatterns: ["**/*.js", "node_modules"], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Output directory for generated cloudformation. | ||
cdk.out | ||
|
||
# Ignore package-lock.json to avoid the following error when reinstalling dependencies: | ||
# npm ERR! notarget No matching version found for [email protected]. | ||
# This is because we're installing @guardian/cdk from file, which is in turn installing eslint-plugin-custom-rules from file. | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../.nvmrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"printWidth": 120 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Integration Test | ||
|
||
This is a really simple integration test for the @guardian/cdk library. | ||
|
||
The purpose of this is to ensure: | ||
- the library can be installed into a project | ||
- a stack can be synthed without error | ||
|
||
This is in reaction to [#356](https://github.com/guardian/cdk/pull/356) and [#365](https://github.com/guardian/cdk/pull/365) which broke the package. | ||
The integration test helps increase confidence in any future changes to the library, _before_ publishing them. | ||
That is, the feedback loop is shortened. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import "source-map-support/register"; | ||
import { App } from "@aws-cdk/core"; | ||
import { IntegrationTestStack } from "../src/integration-test-stack"; | ||
|
||
const app = new App(); | ||
new IntegrationTestStack(app, "Cdk", { stack: "integration-test" }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"app": "npx ts-node bin/cdk.ts", | ||
"profile": "does-not-exist", | ||
"context": { | ||
"@aws-cdk/core:enableStackNameDuplicates": "true", | ||
"aws-cdk:enableDiffNoFail": "true", | ||
"@aws-cdk/core:stackRelativeExports": "true" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
testMatch: ["<rootDir>/src/**/*.test.ts"], | ||
transform: { | ||
"^.+\\.tsx?$": "ts-jest", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"name": "@guardian/cdk-integration-test", | ||
"version": "1.0.0", | ||
"description": "Integration tests for @guardian/cdk", | ||
"bin": { | ||
"cdk": "bin/cdk.js" | ||
}, | ||
"scripts": { | ||
"build": "tsc --noEmit", | ||
"watch": "tsc -w", | ||
"test": "jest --runInBand --detectOpenHandles", | ||
"test:dev": "jest --runInBand --detectOpenHandles --watch", | ||
"format": "prettier --write \"{src,bin}/**/*.ts\"", | ||
"cdk": "cdk", | ||
"lint": "eslint src/** bin/** --ext .ts --no-error-on-unmatched-pattern", | ||
"generate": "cdk synth --path-metadata false --version-reporting false" | ||
}, | ||
"devDependencies": { | ||
"@guardian/eslint-config-typescript": "^0.5.0", | ||
"@types/jest": "^26.0.22", | ||
"@types/node": "14.14.37", | ||
"@typescript-eslint/eslint-plugin": "^4.19.0", | ||
"@typescript-eslint/parser": "^4.19.0", | ||
"aws-cdk": "1.94.1", | ||
"eslint": "^7.23.0", | ||
"eslint-config-prettier": "^8.1.0", | ||
"eslint-plugin-custom-rules": "file:../eslint", | ||
"eslint-plugin-eslint-comments": "^3.2.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-prettier": "^3.3.1", | ||
"jest": "^26.4.2", | ||
"prettier": "^2.2.1", | ||
"ts-jest": "^26.5.4", | ||
"ts-node": "^9.1.1", | ||
"typescript": "~4.2.3" | ||
}, | ||
"dependencies": { | ||
"@guardian/cdk": "file:.." | ||
}, | ||
"private": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
npm run build | ||
npm run generate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
# Ignore package-lock.json to avoid the following error when reinstalling dependencies: | ||
# npm ERR! notarget No matching version found for [email protected]. | ||
# This is because we're installing @guardian/cdk from file, which is in turn installing eslint-plugin-custom-rules from file. | ||
npm install --no-package-lock | ||
|
||
npm run build | ||
npm run lint | ||
npm run test | ||
npm run generate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
npm run lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
# Ignore package-lock.json to avoid the following error when reinstalling dependencies: | ||
# npm ERR! notarget No matching version found for [email protected]. | ||
# This is because we're installing @guardian/cdk from file, which is in turn installing eslint-plugin-custom-rules from file. | ||
npm install --no-package-lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
npm run test:dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
npm run lint | ||
npm run test | ||
npm run generate |
17 changes: 17 additions & 0 deletions
17
integration-test/src/__snapshots__/integration-test-stack.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`The Cdk stack matches the snapshot 1`] = ` | ||
Object { | ||
"Parameters": Object { | ||
"Stage": Object { | ||
"AllowedValues": Array [ | ||
"CODE", | ||
"PROD", | ||
], | ||
"Default": "CODE", | ||
"Description": "Stage name", | ||
"Type": "String", | ||
}, | ||
}, | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import "@aws-cdk/assert/jest"; | ||
import { SynthUtils } from "@aws-cdk/assert"; | ||
import { App } from "@aws-cdk/core"; | ||
import { IntegrationTestStack } from "./integration-test-stack"; | ||
|
||
describe("The Cdk stack", () => { | ||
it("matches the snapshot", () => { | ||
const app = new App(); | ||
const stack = new IntegrationTestStack(app, "cdk", { stack: "integration-test" }); | ||
expect(SynthUtils.toCloudFormation(stack)).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type { App } from "@aws-cdk/core"; | ||
import type { GuStackProps } from "@guardian/cdk/lib/constructs/core"; | ||
import { GuStack } from "@guardian/cdk/lib/constructs/core"; | ||
|
||
export class IntegrationTestStack extends GuStack { | ||
constructor(scope: App, id: string, props: GuStackProps) { | ||
super(scope, id, props); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"include": [ | ||
"src/**/*", "bin/**/*" | ||
], | ||
"exclude": ["node_modules"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"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": [ | ||
"src/**/*", "bin/**/*" | ||
], | ||
"exclude": [ | ||
"node_modules", | ||
"cdk.out", | ||
"src/**/*.test.ts", | ||
"src/**/__snapshots__/**" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters