diff --git a/.github/workflows/pr-ci.yml b/.github/workflows/pr-ci.yml index 5f49f4a..7a95668 100644 --- a/.github/workflows/pr-ci.yml +++ b/.github/workflows/pr-ci.yml @@ -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 }} @@ -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: @@ -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 . diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..c03ffb4 --- /dev/null +++ b/.golangci.yml @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 40e7395..743c5b5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -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: @@ -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/ @@ -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 diff --git a/.pylintrc b/.pylintrc index cb369db..51fb7a4 100644 --- a/.pylintrc +++ b/.pylintrc @@ -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 diff --git a/buildspec.yml b/buildspec.yml index e58a794..3caa5ce 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -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 diff --git a/cfn/logging/cloudwatchlogs.go b/cfn/logging/cloudwatchlogs.go index 5357a33..ddd78da 100644 --- a/cfn/logging/cloudwatchlogs.go +++ b/cfn/logging/cloudwatchlogs.go @@ -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)), }, diff --git a/cfn/logging/cloudwatchlogs_test.go b/cfn/logging/cloudwatchlogs_test.go index 4e8c817..ce5c435 100644 --- a/cfn/logging/cloudwatchlogs_test.go +++ b/cfn/logging/cloudwatchlogs_test.go @@ -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 }, @@ -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 }, @@ -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 }, @@ -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 }, diff --git a/cfn/metrics/publisher.go b/cfn/metrics/publisher.go index f88c1e8..bdf2bb5 100644 --- a/cfn/metrics/publisher.go +++ b/cfn/metrics/publisher.go @@ -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), diff --git a/cfn/scheduler/scheduler_notag.go b/cfn/scheduler/scheduler_notag.go index 744132f..cd0b909 100644 --- a/cfn/scheduler/scheduler_notag.go +++ b/cfn/scheduler/scheduler_notag.go @@ -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)), diff --git a/python/rpdk/go/codegen.py b/python/rpdk/go/codegen.py index 89eb859..ea79249 100644 --- a/python/rpdk/go/codegen.py +++ b/python/rpdk/go/codegen.py @@ -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") diff --git a/setup.py b/setup.py index 97f3e5e..a878c50 100644 --- a/setup.py +++ b/setup.py @@ -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"], @@ -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", )