Skip to content

Commit 0b53488

Browse files
committed
update unit tests for python code
1 parent 2f10e59 commit 0b53488

39 files changed

+2028
-451
lines changed

.coveragerc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
branch = True
33

44
[report]
5-
fail_under = 100
5+
fail_under = 90

.eslintignore

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

.eslintrc.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
module.exports = {
2+
env: {
3+
jest: true,
4+
node: true,
5+
},
6+
plugins: [
7+
'@typescript-eslint',
8+
'import',
9+
'prefer-arrow',
10+
],
11+
parser: '@typescript-eslint/parser',
12+
parserOptions: {
13+
ecmaVersion: '2017',
14+
sourceType: 'module',
15+
project: './tsconfig.eslint.json',
16+
},
17+
extends: [
18+
'plugin:import/typescript',
19+
'plugin:@typescript-eslint/recommended',
20+
],
21+
settings: {
22+
'import/parsers': {
23+
'@typescript-eslint/parser': ['.ts', '.tsx'],
24+
},
25+
'import/resolver': {
26+
node: {},
27+
typescript: {
28+
directory: './tsconfig.eslint.json',
29+
}
30+
}
31+
},
32+
ignorePatterns: ['*.js', '*.d.ts', 'node_modules/', '*.generated.ts'],
33+
rules: {
34+
// Require use of the `import { foo } from 'bar';` form instead of `import foo = require('bar');`
35+
'@typescript-eslint/no-require-imports': ['error'],
36+
'@typescript-eslint/indent': ['error', 4],
37+
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'],
43+
// Require all imported dependencies are actually declared in package.json
44+
'import/no-extraneous-dependencies': ['error'],
45+
'import/no-unresolved': ['error'],
46+
47+
'@typescript-eslint/ban-ts-ignore': ['warn'],
48+
'@typescript-eslint/no-empty-function': ['warn'],
49+
}
50+
}

.github/workflows/cd.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
name: Continuous Delivery (Release)
3+
4+
on:
5+
push:
6+
tags:
7+
- 'v*'
8+
9+
jobs:
10+
delivery-nodejs:
11+
name: Delivery to NPM
12+
runs-on: ubuntu-18.04
13+
steps:
14+
- uses: actions/checkout@v2
15+
- uses: actions/setup-node@v1
16+
with:
17+
node-version: 12
18+
registry-url: https://registry.npmjs.org/
19+
- uses: olegtarasov/get-tag@v2
20+
id: tag_name
21+
with:
22+
tagRegex: 'v(.*)'
23+
- name: Install Dependencies and Package Project
24+
id: installing
25+
run: |
26+
npm ci --optional
27+
npm pack
28+
- name: Upload NPM Artifacts
29+
id: upload_npm
30+
uses: actions/upload-artifact@v1
31+
with:
32+
name: package-npm
33+
path: cfn-rpdk-${{ steps.tag_name.outputs.tag }}.tgz
34+
35+
delivery-python:
36+
runs-on: ubuntu-18.04
37+
strategy:
38+
matrix:
39+
python: [3.6]
40+
steps:
41+
- uses: actions/checkout@v2
42+
- name: Setup Python ${{ matrix.python }}
43+
uses: actions/setup-python@v1
44+
with:
45+
python-version: ${{ matrix.python }}
46+
- name: Install Dependencies and Package Project
47+
id: installing
48+
run: |
49+
python -m pip install --upgrade pip setuptools wheel
50+
python3 setup.py sdist bdist_wheel
51+
- uses: actions/upload-artifact@v1
52+
with:
53+
name: dist-py${{ matrix.python }}
54+
path: dist
55+
56+
delivery-github:
57+
name: Delivery to GitHub
58+
needs: [delivery-nodejs, delivery-python]
59+
runs-on: ubuntu-18.04
60+
steps:
61+
- uses: actions/checkout@v2
62+
- name: Download NPM Artifacts
63+
uses: actions/download-artifact@v1
64+
with:
65+
name: package-npm
66+
- name: Download Python 3.6 Artifacts
67+
uses: actions/download-artifact@v1
68+
with:
69+
name: dist-py3.6
70+
path: dist/
71+
- name: List Artifacts
72+
run: |
73+
echo ::set-env name=ARTIFACTS::$(echo package-npm/* && echo dist/*)
74+
- name: GitHub Release
75+
id: releasing
76+
uses: docker://antonyurchenko/git-release:v3.1.2
77+
env:
78+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79+
DRAFT_RELEASE: 'false'
80+
PRE_RELEASE: 'true'
81+
CHANGELOG_FILE: 'CHANGELOG.md'
82+
ALLOW_EMPTY_CHANGELOG: 'false'
83+
ALLOW_TAG_PREFIX: 'true'
84+
with:
85+
args: |
86+
${{ env.ARTIFACTS }}

.github/workflows/ci.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
name: Continuous Integration
3+
4+
on:
5+
pull_request:
6+
branches:
7+
- master
8+
push:
9+
branches:
10+
- master
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-18.04
15+
steps:
16+
- uses: actions/checkout@v2
17+
- uses: actions/setup-python@v1
18+
with:
19+
python-version: 3.7
20+
- name: Install Dependencies Python
21+
id: installation_python
22+
run: |
23+
pip install --upgrade pip setuptools wheel aws-sam-cli -r https://raw.githubusercontent.com/aws-cloudformation/cloudformation-cli/master/requirements.txt
24+
pip install .
25+
- uses: actions/setup-node@v1
26+
with:
27+
node-version: 12
28+
- name: Install Dependencies Node.js
29+
id: installation_nodejs
30+
run: |
31+
npm ci --optional
32+
- name: Run Tests
33+
id: testing
34+
run: |
35+
pre-commit run --all-files --verbose
36+
- name: Upload Artifacts
37+
id: upload_artifacts
38+
uses: actions/upload-artifact@v1
39+
with:
40+
name: artifacts
41+
path: coverage
42+
- name: Run Integration Tests
43+
id: integration_testing
44+
run: |
45+
DIR=$(mktemp -d)
46+
cd "$DIR"
47+
ls -la
48+
printf "AWS::Foo::Bar\n1\nn" | cfn init -vv
49+
ls -la

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ dmypy.json
127127
.idea/
128128
.vscode/
129129
*.tar.gz
130+
*.tgz
130131

131132
# We want to allow the tests/lib folder
132133
!tests/lib

.pre-commit-config.yaml

Lines changed: 81 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,82 @@
11
repos:
2-
- repo: https://github.com/pre-commit/mirrors-isort
3-
rev: v4.3.17
4-
hooks:
5-
- id: isort
6-
# language_version: python3.6
7-
- repo: https://github.com/ambv/black
8-
rev: stable
9-
hooks:
10-
- id: black
11-
# language_version: python3.6
12-
- repo: https://github.com/pre-commit/pre-commit-hooks
13-
rev: v2.0.0
14-
hooks:
15-
- id: check-case-conflict
16-
- id: end-of-file-fixer
17-
- id: mixed-line-ending
18-
args:
19-
- --fix=lf
20-
- id: trailing-whitespace
21-
- id: flake8
22-
additional_dependencies:
23-
- flake8-bugbear>=19.3.0
24-
- flake8-builtins>=1.4.1
25-
- flake8-commas>=2.0.0
26-
- flake8-comprehensions>=2.1.0
27-
- flake8-debugger>=3.1.0
28-
- flake8-pep3101>=1.2.1
29-
# language_version: python3.6
30-
- id: pretty-format-json
31-
args:
32-
- --autofix
33-
- --indent=4
34-
- --no-sort-keys
35-
- id: check-merge-conflict
36-
- id: check-yaml
37-
- repo: https://github.com/pre-commit/pygrep-hooks
38-
rev: v1.3.0
39-
hooks:
40-
- id: python-check-blanket-noqa
41-
- id: python-check-mock-methods
42-
- id: python-no-log-warn
43-
- repo: https://github.com/PyCQA/bandit
44-
rev: f5a6f0ca62 # TODO: update once a release > 1.5.1 hits with this change in
45-
hooks:
46-
- id: bandit
47-
files: "^python/"
48-
- repo: local
49-
hooks:
50-
- id: pylint-local
51-
name: pylint-local
52-
description: Run pylint in the local virtualenv
53-
entry: pylint "setup.py" "python/" "tests/"
54-
language: system
55-
# ignore all files, run on hard-coded modules instead
56-
pass_filenames: false
57-
always_run: true
58-
- id: pytest-local
59-
name: pytest-local
60-
description: Run pytest in the local virtualenv
61-
entry: pytest --cov=rpdk.typescript --doctest-modules tests/
62-
language: system
63-
# ignore all files, run on hard-coded modules instead
64-
pass_filenames: false
65-
always_run: true
2+
- repo: https://github.com/pre-commit/mirrors-isort
3+
rev: v4.3.17
4+
hooks:
5+
- id: isort
6+
# language_version: python3.6
7+
- repo: https://github.com/ambv/black
8+
rev: stable
9+
hooks:
10+
- id: black
11+
# language_version: python3.6
12+
- repo: https://github.com/pre-commit/pre-commit-hooks
13+
rev: v2.0.0
14+
hooks:
15+
- id: check-case-conflict
16+
- id: end-of-file-fixer
17+
- id: mixed-line-ending
18+
args:
19+
- --fix=lf
20+
- id: trailing-whitespace
21+
- id: flake8
22+
additional_dependencies:
23+
- flake8-bugbear>=19.3.0
24+
- flake8-builtins>=1.4.1
25+
- flake8-commas>=2.0.0
26+
- flake8-comprehensions>=2.1.0
27+
- flake8-debugger>=3.1.0
28+
- flake8-pep3101>=1.2.1
29+
# language_version: python3.6
30+
- id: pretty-format-json
31+
args:
32+
- --autofix
33+
- --indent=4
34+
- --no-sort-keys
35+
- id: check-merge-conflict
36+
- id: check-yaml
37+
- repo: https://github.com/pre-commit/pygrep-hooks
38+
rev: v1.3.0
39+
hooks:
40+
- id: python-check-blanket-noqa
41+
- id: python-check-mock-methods
42+
- id: python-no-log-warn
43+
- repo: https://github.com/PyCQA/bandit
44+
rev: 1.6.2
45+
hooks:
46+
- id: bandit
47+
files: "^python/"
48+
- repo: https://github.com/pre-commit/mirrors-eslint
49+
rev: v6.8.0
50+
hooks:
51+
- id: eslint
52+
args: [--fix]
53+
types: []
54+
files: (.*.js$|.*.ts$)
55+
additional_dependencies:
56+
- eslint@6.8.0
57+
- repo: local
58+
hooks:
59+
- id: pylint-local
60+
name: pylint-local
61+
description: Run pylint in the local virtualenv
62+
entry: pylint "setup.py" "python/" "tests/"
63+
language: system
64+
# ignore all files, run on hard-coded modules instead
65+
pass_filenames: false
66+
always_run: true
67+
- id: pytest-local
68+
name: pytest-local
69+
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/
71+
language: system
72+
# ignore all files, run on hard-coded modules instead
73+
pass_filenames: false
74+
always_run: true
75+
- id: jest-local
76+
name: jest-local
77+
description: Run jest in the local environment
78+
entry: npm run test:ci
79+
language: system
80+
# ignore all files, run on hard-coded modules instead
81+
pass_filenames: false
82+
always_run: true

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## [0.1.0] - 2020-04-24
2+
### Added
3+
- [Support Library] Schedule CloudWatch Events for re-invocation during long process
4+
- [Support Library] Publish metrics to CloudWatch
5+
6+
### Changed
7+
- [Support Library] Fix CloudWatch log delivery
8+
9+
## [0.0.1] - 2020-04-14
10+
### Added
11+
- [CLI Plugin] Initial version in line with Python plugin
12+
- [CLI Plugin] Build using SAM CLI (both locally or with docker support)
13+
- [Support Library] Callback in order to report progress to CloudFormation
14+
- [Support Library] Mechanism for log delivery to CloudWatch
15+
- [Support Library] Base Model class as well as Progress Event class

MANIFEST.in

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
include README.md
22
include LICENSE
3+
include Pipfile
4+
include Pipfile.lock
35

46
graft python/rpdk/typescript
7+
graft tests/plugin
58

69
# last rule wins, put excludes last
7-
global-exclude __pycache__ *.py[co] .DS_Store
10+
global-exclude __pycache__ *.py[cod] .DS_Store

0 commit comments

Comments
 (0)