Skip to content

Commit 204c1b1

Browse files
Merge pull request #6 from eduardomourar/feature/eslint-plugin-prettier
Add ESLint Prettier plugin and coverage report
2 parents 0b53488 + eb4c02b commit 204c1b1

33 files changed

+1488
-1523
lines changed

.coveragerc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ branch = True
33

44
[report]
55
fail_under = 90
6+
show_missing = False

.eslintignore

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
build/*
2-
dist/*
3-
target/*
4-
.idea/*
5-
.vscode/*
6-
node_modules/*
7-
coverage/*
8-
python/*
1+
build/
2+
dist/
3+
target/
4+
.idea/
5+
.vscode/
6+
node_modules/
7+
coverage/
8+
python/

.eslintrc.js

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ module.exports = {
33
jest: true,
44
node: true,
55
},
6-
plugins: [
7-
'@typescript-eslint',
8-
'import',
9-
'prefer-arrow',
10-
],
6+
plugins: ['@typescript-eslint', 'prettier', 'import', 'prefer-arrow'],
117
parser: '@typescript-eslint/parser',
128
parserOptions: {
139
ecmaVersion: '2017',
@@ -17,6 +13,7 @@ module.exports = {
1713
extends: [
1814
'plugin:import/typescript',
1915
'plugin:@typescript-eslint/recommended',
16+
'plugin:prettier/recommended',
2017
],
2118
settings: {
2219
'import/parsers': {
@@ -26,25 +23,19 @@ module.exports = {
2623
node: {},
2724
typescript: {
2825
directory: './tsconfig.eslint.json',
29-
}
30-
}
26+
},
27+
},
3128
},
32-
ignorePatterns: ['*.js', '*.d.ts', 'node_modules/', '*.generated.ts'],
29+
ignorePatterns: ['*.d.ts', '*.generated.ts'],
3330
rules: {
3431
// Require use of the `import { foo } from 'bar';` form instead of `import foo = require('bar');`
3532
'@typescript-eslint/no-require-imports': ['error'],
36-
'@typescript-eslint/indent': ['error', 4],
3733

38-
// Style
39-
'quotes': ['error', 'single', { avoidEscape: true }],
40-
// ensures clean diffs,
41-
// see https://medium.com/@nikgraf/why-you-should-enforce-dangling-commas-for-multiline-statements-d034c98e36f8
42-
'comma-dangle': ['error', 'always-multiline'],
34+
'@typescript-eslint/ban-ts-ignore': ['warn'],
35+
'@typescript-eslint/no-empty-function': ['warn'],
36+
4337
// Require all imported dependencies are actually declared in package.json
4438
'import/no-extraneous-dependencies': ['error'],
4539
'import/no-unresolved': ['error'],
46-
47-
'@typescript-eslint/ban-ts-ignore': ['warn'],
48-
'@typescript-eslint/no-empty-function': ['warn'],
49-
}
50-
}
40+
},
41+
};

.github/workflows/cd.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
2-
name: Continuous Delivery (Release)
2+
# Continuous Delivery (Release)
3+
name: cd
34

45
on:
56
push:
@@ -8,7 +9,7 @@ on:
89

910
jobs:
1011
delivery-nodejs:
11-
name: Delivery to NPM
12+
name: Prepare for NPM
1213
runs-on: ubuntu-18.04
1314
steps:
1415
- uses: actions/checkout@v2
@@ -33,6 +34,7 @@ jobs:
3334
path: cfn-rpdk-${{ steps.tag_name.outputs.tag }}.tgz
3435

3536
delivery-python:
37+
name: Prepare for PyPI
3638
runs-on: ubuntu-18.04
3739
strategy:
3840
matrix:

.github/workflows/ci.yml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
2-
name: Continuous Integration
2+
# Continous Integration
3+
name: ci
34

45
on:
56
pull_request:
@@ -10,8 +11,14 @@ on:
1011
- master
1112

1213
jobs:
13-
test:
14+
build:
1415
runs-on: ubuntu-18.04
16+
env:
17+
SAM_CLI_TELEMETRY: "0"
18+
AWS_REGION: "us-east-1"
19+
AWS_DEFAULT_REGION: "us-east-1"
20+
AWS_ACCESS_KEY_ID: "AKIAIOSFODNN7EXAMPLE"
21+
AWS_SECRET_ACCESS_KEY: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
1522
steps:
1623
- uses: actions/checkout@v2
1724
- uses: actions/setup-python@v1
@@ -28,17 +35,23 @@ jobs:
2835
- name: Install Dependencies Node.js
2936
id: installation_nodejs
3037
run: |
31-
npm ci --optional
32-
- name: Run Tests
33-
id: testing
38+
npm ci --optional && npm run build
39+
- name: Run Unit Tests
40+
id: unit_testing
3441
run: |
3542
pre-commit run --all-files --verbose
43+
- name: Upload Coverage
44+
id: coverage
45+
run: |
46+
curl -s https://codecov.io/bash > codecov.sh
47+
bash codecov.sh -f coverage/py/coverage.xml -F unittests -n codecov-python
48+
bash codecov.sh -f coverage/ts/coverage-final.json -F unittests -n codecov-typescript
3649
- name: Upload Artifacts
3750
id: upload_artifacts
3851
uses: actions/upload-artifact@v1
3952
with:
40-
name: artifacts
41-
path: coverage
53+
name: coverage
54+
path: coverage/
4255
- name: Run Integration Tests
4356
id: integration_testing
4457
run: |
@@ -47,3 +60,6 @@ jobs:
4760
ls -la
4861
printf "AWS::Foo::Bar\n1\nn" | cfn init -vv
4962
ls -la
63+
cfn validate -vv && cfn generate -vv
64+
cfn submit --dry-run -vv
65+
sam local invoke --debug --event sam-tests/create.json TestEntrypoint

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ repos:
6767
- id: pytest-local
6868
name: pytest-local
6969
description: Run pytest in the local virtualenv
70-
entry: pytest --cov-report term-missing --cov-report html:coverage/python --cov=rpdk.typescript --doctest-modules tests/
70+
entry: pytest --cov=rpdk.typescript tests/
7171
language: system
7272
# ignore all files, run on hard-coded modules instead
7373
pass_filenames: false
7474
always_run: true
7575
- id: jest-local
7676
name: jest-local
7777
description: Run jest in the local environment
78-
entry: npm run test:ci
78+
entry: npx jest --ci --verbose
7979
language: system
8080
# ignore all files, run on hard-coded modules instead
8181
pass_filenames: false

README.md

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# DEVELOPER PREVIEW (COMMUNITY DRIVEN)
22

3+
[![License MIT](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT) [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/eduardomourar/cloudformation-cli-typescript-plugin/issues) [![Project Status: WIP – Initial development](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip)
4+
35
We're excited to share our progress with adding new languages to the CloudFormation CLI!
46
> This plugin is an early preview prepared by the community, and not ready for production use.
57
68
## AWS CloudFormation Resource Provider TypeScript Plugin
79

10+
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/eduardomourar/cloudformation-cli-typescript-plugin/ci) ![Codecov](https://img.shields.io/codecov/c/gh/eduardomourar/cloudformation-cli-typescript-plugin) ![GitHub release](https://img.shields.io/github/v/release/eduardomourar/cloudformation-cli-typescript-plugin?include_prereleases)
11+
[![Node.js version](https://img.shields.io/badge/dynamic/json?color=brightgreen&url=https://raw.githubusercontent.com/eduardomourar/cloudformation-cli-typescript-plugin/master/package.json&query=$.engines.node&label=nodejs)](https://nodejs.org/)
12+
813
The CloudFormation CLI (cfn) allows you to author your own resource providers that can be used by CloudFormation.
914

1015
This plugin library helps to provide TypeScript runtime bindings for the execution of your providers by CloudFormation.
@@ -51,26 +56,7 @@ with cross-platform Typescript packaging.
5156
>> y
5257
Initialized a new project in <>
5358
$ cfn submit --dry-run
54-
$ cat test.json
55-
{
56-
"credentials": {
57-
"accessKeyId": "",
58-
"secretAccessKey": "",
59-
"sessionToken": ""
60-
},
61-
"action": "CREATE",
62-
"request": {
63-
"clientRequestToken": "ecba020e-b2e6-4742-a7d0-8a06ae7c4b2b",
64-
"desiredResourceState": {
65-
"Title": "foo",
66-
"Description": "bar"
67-
},
68-
"previousResourceState": null,
69-
"logicalResourceIdentifier": null
70-
},
71-
"callbackContext": null
72-
}
73-
$ sam local invoke TestEntrypoint --event test.json
59+
$ sam local invoke --event sam-tests/create.json TestEntrypoint
7460
```
7561

7662
Development
@@ -94,7 +80,7 @@ pip3 install \
9480

9581
That ensures neither is accidentally installed from PyPI.
9682

97-
Linting and running unit tests is done via [pre-commit](https://pre-commit.com/), and so is performed automatically on commit after being installed (`pre-commit install`).
83+
Linting and running unit tests is done via [pre-commit](https://pre-commit.com/), and so is performed automatically on commit after being installed (`pre-commit install`). The continuous integration also runs these checks. Manual options are available so you don't have to commit:
9884

9985
```shell
10086
# run all hooks on all files, mirrors what the CI runs

jest.config.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
module.exports = {
2-
preset: 'ts-jest',
3-
testEnvironment: 'node',
4-
globals: {
5-
'ts-jest': {
6-
diagnostics: false, // Necessary to avoid typeschecking error in decorators
7-
}
8-
},
9-
testRegex: '\\.test.ts$',
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
globals: {
5+
'ts-jest': {
6+
diagnostics: false, // Necessary to avoid typeschecking error in decorators
7+
},
8+
},
9+
testRegex: '\\.test.ts$',
10+
coverageThreshold: {
11+
global: {
12+
branches: 80,
13+
statements: 90,
14+
},
15+
},
16+
coverageDirectory: 'coverage/ts',
17+
collectCoverage: true,
18+
coverageReporters: ['json', 'lcov', 'text'],
1019
};

0 commit comments

Comments
 (0)