Skip to content

Commit

Permalink
Merge pull request #6 from eduardomourar/feature/eslint-plugin-prettier
Browse files Browse the repository at this point in the history
Add ESLint Prettier plugin and coverage report
  • Loading branch information
eduardomourar authored Apr 27, 2020
2 parents 0b53488 + eb4c02b commit 204c1b1
Show file tree
Hide file tree
Showing 33 changed files with 1,488 additions and 1,523 deletions.
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ branch = True

[report]
fail_under = 90
show_missing = False
16 changes: 8 additions & 8 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
build/*
dist/*
target/*
.idea/*
.vscode/*
node_modules/*
coverage/*
python/*
build/
dist/
target/
.idea/
.vscode/
node_modules/
coverage/
python/
29 changes: 10 additions & 19 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ module.exports = {
jest: true,
node: true,
},
plugins: [
'@typescript-eslint',
'import',
'prefer-arrow',
],
plugins: ['@typescript-eslint', 'prettier', 'import', 'prefer-arrow'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: '2017',
Expand All @@ -17,6 +13,7 @@ module.exports = {
extends: [
'plugin:import/typescript',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
settings: {
'import/parsers': {
Expand All @@ -26,25 +23,19 @@ module.exports = {
node: {},
typescript: {
directory: './tsconfig.eslint.json',
}
}
},
},
},
ignorePatterns: ['*.js', '*.d.ts', 'node_modules/', '*.generated.ts'],
ignorePatterns: ['*.d.ts', '*.generated.ts'],
rules: {
// Require use of the `import { foo } from 'bar';` form instead of `import foo = require('bar');`
'@typescript-eslint/no-require-imports': ['error'],
'@typescript-eslint/indent': ['error', 4],

// Style
'quotes': ['error', 'single', { avoidEscape: true }],
// ensures clean diffs,
// see https://medium.com/@nikgraf/why-you-should-enforce-dangling-commas-for-multiline-statements-d034c98e36f8
'comma-dangle': ['error', 'always-multiline'],
'@typescript-eslint/ban-ts-ignore': ['warn'],
'@typescript-eslint/no-empty-function': ['warn'],

// Require all imported dependencies are actually declared in package.json
'import/no-extraneous-dependencies': ['error'],
'import/no-unresolved': ['error'],

'@typescript-eslint/ban-ts-ignore': ['warn'],
'@typescript-eslint/no-empty-function': ['warn'],
}
}
},
};
6 changes: 4 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
name: Continuous Delivery (Release)
# Continuous Delivery (Release)
name: cd

on:
push:
Expand All @@ -8,7 +9,7 @@ on:

jobs:
delivery-nodejs:
name: Delivery to NPM
name: Prepare for NPM
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
Expand All @@ -33,6 +34,7 @@ jobs:
path: cfn-rpdk-${{ steps.tag_name.outputs.tag }}.tgz

delivery-python:
name: Prepare for PyPI
runs-on: ubuntu-18.04
strategy:
matrix:
Expand Down
30 changes: 23 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
name: Continuous Integration
# Continous Integration
name: ci

on:
pull_request:
Expand All @@ -10,8 +11,14 @@ on:
- master

jobs:
test:
build:
runs-on: ubuntu-18.04
env:
SAM_CLI_TELEMETRY: "0"
AWS_REGION: "us-east-1"
AWS_DEFAULT_REGION: "us-east-1"
AWS_ACCESS_KEY_ID: "AKIAIOSFODNN7EXAMPLE"
AWS_SECRET_ACCESS_KEY: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
Expand All @@ -28,17 +35,23 @@ jobs:
- name: Install Dependencies Node.js
id: installation_nodejs
run: |
npm ci --optional
- name: Run Tests
id: testing
npm ci --optional && npm run build
- name: Run Unit Tests
id: unit_testing
run: |
pre-commit run --all-files --verbose
- name: Upload Coverage
id: coverage
run: |
curl -s https://codecov.io/bash > codecov.sh
bash codecov.sh -f coverage/py/coverage.xml -F unittests -n codecov-python
bash codecov.sh -f coverage/ts/coverage-final.json -F unittests -n codecov-typescript
- name: Upload Artifacts
id: upload_artifacts
uses: actions/upload-artifact@v1
with:
name: artifacts
path: coverage
name: coverage
path: coverage/
- name: Run Integration Tests
id: integration_testing
run: |
Expand All @@ -47,3 +60,6 @@ jobs:
ls -la
printf "AWS::Foo::Bar\n1\nn" | cfn init -vv
ls -la
cfn validate -vv && cfn generate -vv
cfn submit --dry-run -vv
sam local invoke --debug --event sam-tests/create.json TestEntrypoint
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ repos:
- id: pytest-local
name: pytest-local
description: Run pytest in the local virtualenv
entry: pytest --cov-report term-missing --cov-report html:coverage/python --cov=rpdk.typescript --doctest-modules tests/
entry: pytest --cov=rpdk.typescript tests/
language: system
# ignore all files, run on hard-coded modules instead
pass_filenames: false
always_run: true
- id: jest-local
name: jest-local
description: Run jest in the local environment
entry: npm run test:ci
entry: npx jest --ci --verbose
language: system
# ignore all files, run on hard-coded modules instead
pass_filenames: false
Expand Down
28 changes: 7 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# DEVELOPER PREVIEW (COMMUNITY DRIVEN)

[![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)

We're excited to share our progress with adding new languages to the CloudFormation CLI!
> This plugin is an early preview prepared by the community, and not ready for production use.
## AWS CloudFormation Resource Provider TypeScript Plugin

![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)
[![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/)

The CloudFormation CLI (cfn) allows you to author your own resource providers that can be used by CloudFormation.

This plugin library helps to provide TypeScript runtime bindings for the execution of your providers by CloudFormation.
Expand Down Expand Up @@ -51,26 +56,7 @@ with cross-platform Typescript packaging.
>> y
Initialized a new project in <>
$ cfn submit --dry-run
$ cat test.json
{
"credentials": {
"accessKeyId": "",
"secretAccessKey": "",
"sessionToken": ""
},
"action": "CREATE",
"request": {
"clientRequestToken": "ecba020e-b2e6-4742-a7d0-8a06ae7c4b2b",
"desiredResourceState": {
"Title": "foo",
"Description": "bar"
},
"previousResourceState": null,
"logicalResourceIdentifier": null
},
"callbackContext": null
}
$ sam local invoke TestEntrypoint --event test.json
$ sam local invoke --event sam-tests/create.json TestEntrypoint
```

Development
Expand All @@ -94,7 +80,7 @@ pip3 install \

That ensures neither is accidentally installed from PyPI.

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`).
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:

```shell
# run all hooks on all files, mirrors what the CI runs
Expand Down
25 changes: 17 additions & 8 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
globals: {
'ts-jest': {
diagnostics: false, // Necessary to avoid typeschecking error in decorators
}
},
testRegex: '\\.test.ts$',
preset: 'ts-jest',
testEnvironment: 'node',
globals: {
'ts-jest': {
diagnostics: false, // Necessary to avoid typeschecking error in decorators
},
},
testRegex: '\\.test.ts$',
coverageThreshold: {
global: {
branches: 80,
statements: 90,
},
},
coverageDirectory: 'coverage/ts',
collectCoverage: true,
coverageReporters: ['json', 'lcov', 'text'],
};
Loading

0 comments on commit 204c1b1

Please sign in to comment.