Skip to content

Commit

Permalink
Development process fixups (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
plumdog authored Nov 1, 2022
1 parent 16920db commit 4d5f05e
Show file tree
Hide file tree
Showing 16 changed files with 8,095 additions and 104 deletions.
26 changes: 26 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = {
root: true,
// Specifies the ESLint parser
parser: '@typescript-eslint/parser',
extends: [
// Uses the recommended rules from @typescript-eslint/eslint-plugin
'plugin:@typescript-eslint/recommended',
// Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
'prettier/@typescript-eslint',
// Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors.
// Make sure this is always the last configuration in the extends array.
'plugin:prettier/recommended',
],
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
ecmaFeatures: {
jsx: true, // Allows for the parsing of JSX
},
},
rules: {
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
},
settings: {},
};
21 changes: 21 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Node.js Package
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- '[0-9]+.[0-9]+.[0-9]+'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v1
with:
node-version: '12.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm run compile
- run: cd build && npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
26 changes: 26 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "Run linting and tests"

on: push

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run compile
# Test the construct
- run: npm run lint-check
- run: npm run test
# Test the provider
- run: (cd ./provider && npm run lint-check)
- run: (cd ./provider && npm run test)
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
node_modules
lib

build/
coverage/
lib/
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12
28 changes: 28 additions & 0 deletions changelog_template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
### Changelog

{{#each releases}}
{{#if href}}
###{{#unless major}}#{{/unless}} [{{title}}]({{href}})
{{else}}
#### {{title}}
{{/if}}

{{#if tag}}
> {{niceDate}}
{{/if}}

{{#if summary}}
{{summary}}
{{/if}}

{{#each merges}}
- {{message}}{{#if href}} [`#{{id}}`]({{href}}){{/if}}
{{/each}}
{{#each fixes}}
- {{commit.subject}}{{#each fixes}}{{#if href}} [`#{{id}}`]({{href}}){{/if}}{{/each}}
{{/each}}
{{#each commits}}
- {{#if breaking}}**Breaking change:** {{/if}}{{subject}}{{#if href}} [`{{shorthash}}`]({{href}}){{/if}}
{{/each}}

{{/each}}
12 changes: 4 additions & 8 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class AllowConnectionsToECSServiceFromNetworkLoadBalancerProvider extends
const x = (stack.node.tryFindChild(id) as AllowConnectionsToECSServiceFromNetworkLoadBalancerProvider) || new AllowConnectionsToECSServiceFromNetworkLoadBalancerProvider(stack, id);
return x.provider;
}

constructor(scope: cdk.Construct, id: string) {
super(scope, id);
this.provider = new customResource.Provider(this, 'allow-connections-to-ecs-service-from-network-load-balancer', {
Expand All @@ -28,11 +28,7 @@ export class AllowConnectionsToECSServiceFromNetworkLoadBalancerProvider extends
initialPolicy: [
new iam.PolicyStatement({
resources: ['*'],
actions: [
'ec2:AuthorizeSecurityGroupIngress',
'ec2:RevokeSecurityGroupIngress',
'ec2:DescribeNetworkInterfaces',
],
actions: ['ec2:AuthorizeSecurityGroupIngress', 'ec2:RevokeSecurityGroupIngress', 'ec2:DescribeNetworkInterfaces'],
}),
],
}),
Expand All @@ -56,7 +52,7 @@ export class AllowConnectionsToECSServiceFromNetworkLoadBalancer extends cdk.Con
throw new Error('No service specified');
}
if (!props.loadBalancer) {
throw new Error("No load balancer specified");
throw new Error('No load balancer specified');
}
this.service = props.service;
this.loadBalancer = props.loadBalancer;
Expand All @@ -66,7 +62,7 @@ export class AllowConnectionsToECSServiceFromNetworkLoadBalancer extends cdk.Con
properties: {
ServiceSecurityGroupId: this.service.connections.securityGroups[0].securityGroupId,
LoadBalancerArn: this.loadBalancer.loadBalancerArn,
}
},
});
}
}
21 changes: 14 additions & 7 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
module.exports = {
"roots": [
"<rootDir>/test"
],
testMatch: [ '**/*.test.ts'],
"transform": {
"^.+\\.tsx?$": "ts-jest"
roots: ['<rootDir>/test'],
testMatch: ['**/*.test.ts'],
transform: {
'^.+\\.ts$': 'ts-jest',
},
}
collectCoverage: true,
coverageThreshold: {
global: {
statements: 0,
branches: 0,
functions: 0,
lines: 0,
},
},
};
Loading

0 comments on commit 4d5f05e

Please sign in to comment.