Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 14 additions & 18 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
# Continuous Delivery (Release)
name: cd

Expand All @@ -12,8 +11,8 @@ jobs:
name: Prepare for NPM
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
Expand All @@ -28,47 +27,44 @@ jobs:
npm pack
- name: Upload NPM Artifacts
id: upload_npm
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: package-npm
path: cfn-rpdk-${{ env.VERSION }}.tgz

delivery-python:
name: Prepare for PyPI
runs-on: ubuntu-latest
strategy:
matrix:
python: [3.8]
steps:
- uses: actions/checkout@v3
- name: Setup Python ${{ matrix.python }}
uses: actions/setup-python@v4
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
python-version: "3.12"
- name: Install Dependencies and Package Project
id: installing
run: |
python -m pip install --upgrade pip setuptools wheel
python3 setup.py sdist bdist_wheel
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: dist-py${{ matrix.python }}
name: dist-python
path: dist

delivery-github:
name: Delivery to GitHub
needs: [delivery-nodejs, delivery-python]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Download NPM Artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: package-npm
- name: Download Python 3.8 Artifacts
uses: actions/download-artifact@v3
- name: Download Python Artifacts
uses: actions/download-artifact@v4
with:
name: dist-py3.8
name: dist-python
path: dist/
- name: List Artifacts
run: |
Expand Down
47 changes: 28 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
# Continous Integration
name: ci

Expand All @@ -8,17 +7,34 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: 3.9
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- name: Install Dependencies
run: |
pip install --upgrade pip setuptools
pip install pre-commit
pip install .
npm ci --include=optional
npm run build
- name: Run Linting
run: |
pre-commit run --all-files --verbose
os_build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-12 # Later versions of ARM-based macOS runners fail because the hypervisor framework required for Docker is not supported
python: [ "3.8", "3.9", "3.10", "3.11"]
- macos-13
python: [ "3.10", "3.11", "3.12"]
node: [ 20 ]
env:
SAM_CLI_TELEMETRY: "0"
Expand All @@ -30,14 +46,14 @@ jobs:
PIP_LOG_FILE: /tmp/pip.log
HOMEBREW_NO_AUTO_UPDATE: 1
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Update Homebrew and save docker version
if: runner.os == 'macOS'
run: |
brew tap homebrew/core
cat "$(brew --repository)/Library/Taps/homebrew/homebrew-core/Formula/d/docker.rb" > .github/brew-formulae
- name: Configure Homebrew docker cache files
uses: actions/cache@v3
uses: actions/cache@v4
if: runner.os == 'macOS'
with:
path: |
Expand All @@ -51,18 +67,12 @@ jobs:
run: |
brew install docker --cask
brew install colima
# Docker engine is no longer available because of licensing
# Alternative Colima is part of the github macOS runner
# SAM v1.47.0+ needed for colima support, unable to use Python 3.6
colima start
# Ensure colima is configured for later user
echo "DOCKER_HOST=unix://$HOME/.colima/default/docker.sock" >> $GITHUB_ENV
# Verify Docker
docker ps
docker --version
# Verify colima
colima status
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: 'pip'
Expand All @@ -73,18 +83,17 @@ jobs:
pip install --upgrade pip
pip install --upgrade setuptools wheel aws-sam-cli -r https://raw.githubusercontent.com/aws-cloudformation/cloudformation-cli/master/requirements.txt
pip install .
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'npm'
- name: Install Dependencies Node.js
id: install_nodejs
# Touch needed because of https://github.com/aws/aws-cli/issues/2639
run: |
npm ci --include=optional
find ./node_modules/* -mtime +10950 -exec touch {} \;
npm run build
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit/
key: ${{ matrix.os }}-${{ env.pythonLocation }}${{ hashFiles('.pre-commit-config.yaml') }}
Expand All @@ -100,9 +109,9 @@ jobs:
bash codecov.sh -f coverage/ts/coverage-final.json -F unittests -n codecov-typescript
- name: Upload Coverage Artifacts
id: upload_coverage
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage
name: coverage-${{ matrix.os }}-py${{ matrix.python }}
path: coverage/
- name: Run Integration Tests
id: integration_testing
Expand Down Expand Up @@ -140,7 +149,7 @@ jobs:
- name: Upload Debug Artifacts
id: upload_logs
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: debug-logs
name: debug-logs-${{ matrix.os }}-py${{ matrix.python }}
path: ${{ env.LOG_PATH }}
25 changes: 25 additions & 0 deletions .github/workflows/pypi-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This workflow will release project to PyPI
name: CloudFormation CLI TypeScript Plugin Release
on:
release:
types: [published]
jobs:
build:
if: endsWith(github.ref, '-plugin')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install dependencies
run: |
pip install --upgrade wheel twine
- name: Package project
run: |
python setup.py sdist bdist_wheel
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_KEY_CLOUDFORMATION_CLI_TYPESCRIPT_PLUGIN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,5 @@ node_modules/
coverage/

*.iml
# Kiro IDE
.kiro/
17 changes: 8 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ repos:
- id: check-merge-conflict
# - id: check-yaml # have jinja yml templates so skipping this
- repo: https://github.com/pycqa/flake8
rev: "5.0.4"
rev: "7.1.2"
hooks:
- id: flake8
additional_dependencies:
Expand All @@ -45,19 +45,18 @@ repos:
- id: python-check-mock-methods
- id: python-no-log-warn
- repo: https://github.com/PyCQA/bandit
rev: 1.7.1
rev: 1.8.3
hooks:
- id: bandit
files: "^python/"
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.26.0
- repo: local
hooks:
- id: eslint
args: [--fix]
types: []
files: (.*.js$|.*.ts$)
additional_dependencies:
- eslint@8.21.0
name: eslint
description: Run eslint from local node_modules
entry: npx eslint --fix
language: system
files: \.(js|ts)$
- repo: local
hooks:
- id: pylint-local
Expand Down
2 changes: 1 addition & 1 deletion python/rpdk/typescript/templates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"dependencies": {
"{{lib_name}}": "{{lib_path}}",
"class-transformer": "0.3.1"
"class-transformer": "0.5.1"
},
"devDependencies": {
"@types/node": "^20.0.0",
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def find_version(*file_paths):
# package_data -> use MANIFEST.in instead
include_package_data=True,
zip_safe=True,
python_requires=">=3.8",
python_requires=">=3.10",
install_requires=[
"cloudformation-cli>=0.1.14",
"zipfile38>=0.0.3,<0.2",
Expand Down
71 changes: 37 additions & 34 deletions src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
} from 'class-transformer';

export type Optional<T> = T | undefined | null;
export type Dict<T = any> = Record<string, T>;

Check warning on line 18 in src/interface.ts

View workflow job for this annotation

GitHub Actions / os_build (ubuntu-latest, 3.11, 20)

Unexpected any. Specify a different type

Check warning on line 18 in src/interface.ts

View workflow job for this annotation

GitHub Actions / os_build (ubuntu-latest, 3.12, 20)

Unexpected any. Specify a different type

Check warning on line 18 in src/interface.ts

View workflow job for this annotation

GitHub Actions / os_build (ubuntu-latest, 3.10, 20)

Unexpected any. Specify a different type
export type Constructor<T = {}> = new (...args: any[]) => T;
export type integer = bigint;

Expand Down Expand Up @@ -66,9 +66,7 @@
(...args: R): T;
}

// @ts-ignore
// eslint-disable-next-line
interface Integer extends BigInt {
interface Integer {
/**
* Defines the default JSON representation of
* Integer (BigInt) to be a number.
Expand All @@ -78,11 +76,12 @@
/** Returns the primitive value of the specified object. */
valueOf(): integer;

toString(radix?: number): string;

readonly [Symbol.toStringTag]: 'Integer';
}

// @ts-ignore
interface IntegerConstructor extends BigIntConstructor {
interface IntegerConstructor {
(value?: bigint | integer | boolean | number | string): bigint;
readonly prototype: Integer;
/**
Expand All @@ -96,36 +95,40 @@
/**
* Wrapper with additional JSON serialization for bigint type
*/
// @ts-ignore
export const Integer: IntegerConstructor = new Proxy(BigInt, {
// @ts-ignore
apply(
target: IntegerConstructor,
_thisArg: unknown,
argArray?: unknown[]
): integer {
target.prototype.toJSON = function (): number {
return Number(this.valueOf());
};
const isSafeInteger = (value: bigint): boolean => {
if (
value &&
(value < BigInt(Number.MIN_SAFE_INTEGER) ||
value > BigInt(Number.MAX_SAFE_INTEGER))
) {
return false;
export const Integer: IntegerConstructor = new Proxy(
BigInt as unknown as IntegerConstructor,
{
apply(
target: IntegerConstructor,
_thisArg: unknown,
argArray: unknown[]
): integer {
target.prototype.toJSON = function (): number {
return Number(this.valueOf());
};
const isSafeInteger = (value: bigint): boolean => {
if (
value &&
(value < BigInt(Number.MIN_SAFE_INTEGER) ||
value > BigInt(Number.MAX_SAFE_INTEGER))
) {
return false;
}
return true;
};
target.isSafeInteger = isSafeInteger;
const value = target(
...(argArray as [bigint | integer | boolean | number | string])
);
if (value && !isSafeInteger(value)) {
throw new RangeError(
`Value is not a safe integer: ${value.toString()}`
);
}
return true;
};
target.isSafeInteger = isSafeInteger;
// @ts-expect-error argArray is unknown
const value = target(...argArray);
if (value && !isSafeInteger(value)) {
throw new RangeError(`Value is not a safe integer: ${value.toString()}`);
}
return value;
},
}) as IntegerConstructor;
return value;
},
}
) as IntegerConstructor;

export enum Action {
Create = 'CREATE',
Expand Down
8 changes: 4 additions & 4 deletions tests/lib/log-delivery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1271,11 +1271,11 @@ describe('when delivering logs', () => {
loggerProxy.addLogPublisher(s3Logger);

loggerProxy.log('count: [%d]', 5.12);
loggerProxy.log('timestamp: [%s]', new Date('2020-01-01'));
loggerProxy.log('timestamp: [%s]', new Date('2020-01-01').toISOString());

loggerProxy.log('timestamp: [%s]', new Date('2020-01-02'));
loggerProxy.log('timestamp: [%s]', new Date('2020-01-03'));
loggerProxy.log('timestamp: [%s]', new Date('2020-01-04'));
loggerProxy.log('timestamp: [%s]', new Date('2020-01-02').toISOString());
loggerProxy.log('timestamp: [%s]', new Date('2020-01-03').toISOString());
loggerProxy.log('timestamp: [%s]', new Date('2020-01-04').toISOString());
expect(inspect.defaultOptions.depth).toBe(8);
await loggerProxy.waitCompletion();

Expand Down
Loading