Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lifecycle python support #231

Closed
Closed
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
6 changes: 3 additions & 3 deletions .github/workflows/pr-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python: [3.7, 3.8, 3.9]
python: ["3.8", "3.9", "3.10", "3.11"]
defaults:
run:
working-directory: ${{ env.GOPATH }}/src/github.com/${{ github.repository }}
Expand All @@ -28,7 +28,7 @@ jobs:
path: ${{ env.GOPATH }}/src/github.com/${{ github.repository }}
- uses: actions/setup-go@v3
with:
go-version: '>=1.19.0'
go-version: '>=1.21.0'
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v2
with:
Expand All @@ -41,7 +41,7 @@ jobs:
go install github.com/go-critic/go-critic/cmd/gocritic@latest
go install golang.org/x/tools/cmd/goimports@latest
go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.1
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2
- name: Install plugin
run: |
pip install .
Expand Down
16 changes: 16 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
linters:
# Disable all linters.
# Default: false
disable-all: true
# Enable specific linter
# https://golangci-lint.run/usage/linters/#enabled-by-default
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused
- gofmt
- goimports
- gocritic
36 changes: 19 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.5.0
hooks:
- id: check-case-conflict
- id: end-of-file-fixer
Expand All @@ -25,7 +25,7 @@ repos:
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: '5.0.4'
rev: '6.1.0'
hooks:
- id: flake8
additional_dependencies:
Expand All @@ -35,16 +35,15 @@ repos:
- flake8-comprehensions>=2.1.0
- flake8-debugger>=3.1.0
- flake8-pep3101>=1.2.1
# language_version: python3.6
exclude: templates/
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
rev: v1.10.0
hooks:
- id: python-check-blanket-noqa
- id: python-check-mock-methods
- id: python-no-log-warn
- repo: https://github.com/PyCQA/bandit
rev: "1.7.4"
rev: "1.7.5"
hooks:
- id: bandit
files: ^python/
Expand Down Expand Up @@ -74,16 +73,19 @@ repos:
# ignore all files, run on hard-coded modules instead
pass_filenames: false
always_run: true
- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.5.1
- id: go-unit-tests
name: go unit tests
entry: go test ./...
pass_filenames: false
types: [go]
language: system
- id: go-build-mod
name: go build mod
entry: go build ./...
pass_filenames: false
types: [go]
language: system
- repo: https://github.com/golangci/golangci-lint
rev: v1.55.2
hooks:
- id: go-fmt
# - id: go-vet
- id: go-imports
- id: go-cyclo
args: [-over=20]
- id: golangci-lint
- id: go-critic
- id: go-unit-tests
- id: go-build
- id: go-mod-tidy
- id: golangci-lint-full
1 change: 0 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ persistent=yes
disable=
missing-docstring, # not everything needs a docstring
fixme, # work in progress
bad-continuation, # clashes with black
too-few-public-methods, # triggers when inheriting
ungrouped-imports, # clashes with isort
duplicate-code, # broken, setup.py
Expand Down
2 changes: 1 addition & 1 deletion buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 0.2
phases:
install:
runtime-versions:
python: 3.7
python: 3.8
golang: 1.12
commands:
- pip install pre-commit
Expand Down
2 changes: 1 addition & 1 deletion cfn/logging/cloudwatchlogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (p *cloudWatchLogsProvider) Write(b []byte) (int, error) {
LogStreamName: aws.String(p.logStreamName),

LogEvents: []*cloudwatchlogs.InputLogEvent{
&cloudwatchlogs.InputLogEvent{
{
Message: aws.String(string(b)),
Timestamp: aws.Int64(time.Now().UnixNano() / int64(time.Millisecond)),
},
Expand Down
8 changes: 4 additions & 4 deletions cfn/logging/cloudwatchlogs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestCloudWatchLogProvider(t *testing.T) {
DescribeLogGroupsFn: func(input *cloudwatchlogs.DescribeLogGroupsInput) (*cloudwatchlogs.DescribeLogGroupsOutput, error) {
return &cloudwatchlogs.DescribeLogGroupsOutput{
LogGroups: []*cloudwatchlogs.LogGroup{
&cloudwatchlogs.LogGroup{LogGroupName: input.LogGroupNamePrefix},
{LogGroupName: input.LogGroupNamePrefix},
},
}, nil
},
Expand Down Expand Up @@ -102,7 +102,7 @@ func TestCloudWatchLogProvider(t *testing.T) {
DescribeLogGroupsFn: func(input *cloudwatchlogs.DescribeLogGroupsInput) (*cloudwatchlogs.DescribeLogGroupsOutput, error) {
return &cloudwatchlogs.DescribeLogGroupsOutput{
LogGroups: []*cloudwatchlogs.LogGroup{
&cloudwatchlogs.LogGroup{LogGroupName: input.LogGroupNamePrefix},
{LogGroupName: input.LogGroupNamePrefix},
},
}, nil
},
Expand Down Expand Up @@ -144,7 +144,7 @@ func TestCloudWatchLogProvider(t *testing.T) {
DescribeLogGroupsFn: func(input *cloudwatchlogs.DescribeLogGroupsInput) (*cloudwatchlogs.DescribeLogGroupsOutput, error) {
return &cloudwatchlogs.DescribeLogGroupsOutput{
LogGroups: []*cloudwatchlogs.LogGroup{
&cloudwatchlogs.LogGroup{LogGroupName: input.LogGroupNamePrefix},
{LogGroupName: input.LogGroupNamePrefix},
},
}, nil
},
Expand Down Expand Up @@ -188,7 +188,7 @@ func TestCloudWatchLogGroupExists(t *testing.T) {
DescribeLogGroupsFn: func(input *cloudwatchlogs.DescribeLogGroupsInput) (*cloudwatchlogs.DescribeLogGroupsOutput, error) {
return &cloudwatchlogs.DescribeLogGroupsOutput{
LogGroups: []*cloudwatchlogs.LogGroup{
&cloudwatchlogs.LogGroup{LogGroupName: input.LogGroupNamePrefix},
{LogGroupName: input.LogGroupNamePrefix},
},
}, nil
},
Expand Down
2 changes: 1 addition & 1 deletion cfn/metrics/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (p *Publisher) publishMetric(metricName string, data map[string]string, uni
d = append(d, dim)
}
md := []*cloudwatch.MetricDatum{
&cloudwatch.MetricDatum{
{
MetricName: aws.String(metricName),
Unit: aws.String(unit),
Value: aws.Float64(value),
Expand Down
2 changes: 1 addition & 1 deletion cfn/scheduler/scheduler_notag.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (s *Scheduler) Reschedule(lambdaCtx context.Context, secsFromNow int64, cal
_, perr := s.client.PutTargets(&cloudwatchevents.PutTargetsInput{
Rule: aws.String(invocationIDS.Handler),
Targets: []*cloudwatchevents.Target{
&cloudwatchevents.Target{
{
Arn: aws.String(lc.InvokedFunctionArn),
Id: aws.String(invocationIDS.Target),
Input: aws.String(string(callbackRequest)),
Expand Down
2 changes: 1 addition & 1 deletion python/rpdk/go/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def init_handlers(self, project: Project, src):
contents = template.render()
project.safewrite(path, contents)

# pylint: disable=unused-argument,no-self-use
# pylint: disable=unused-argument
def _get_generated_root(self, project: Project):
LOG.debug("Init started")

Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def find_version(*file_paths):
include_package_data=True,
zip_safe=True,
install_requires=["cloudformation-cli>=0.1.14", "semver>=2.9.0"],
python_requires=">=3.6",
python_requires=">=3.8",
entry_points={
"rpdk.v1.languages": ["go = rpdk.go.codegen:GoLanguagePlugin"],
"rpdk.v1.parsers": ["go = rpdk.go.parser:setup_subparser"],
Expand All @@ -51,9 +51,10 @@ def find_version(*file_paths):
"Topic :: Software Development :: Code Generators",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
],
keywords="Amazon Web Services AWS CloudFormation",
)
Loading