Skip to content

Commit

Permalink
Fix workflows, run Cookstyle (#610)
Browse files Browse the repository at this point in the history
- Use v0.1.1 of lint-unit
- Use the release-please workflow to releasing the Gem
- Run Chefstyle over the code base
- Correct incorrectly labeled protected/private singleton method
- Update owner to [email protected]
  This is a team address and we don't want people to be emailing old
  maintainers
  We would use a test-kitchen address but it doesn't have one

Signed-off-by: Dan Webb <[email protected]>
  • Loading branch information
damacus authored Nov 27, 2023
1 parent 2bb3437 commit 8502d05
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 69 deletions.
14 changes: 0 additions & 14 deletions .github/dependabot.yml

This file was deleted.

9 changes: 9 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name: "Test"

"on":
pull_request:

jobs:
lint-unit:
uses: test-kitchen/.github/.github/workflows/[email protected]
9 changes: 0 additions & 9 deletions .github/workflows/linters.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: release-please

"on":
push:
branches: [main]

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: ruby
package-name: kitchen-digitalocean
version-file: lib/kitchen/driver/ec2_version.rb
token: ${{ secrets.PORTER_GITHUB_TOKEN }}

- name: Checkout
uses: actions/checkout@v4
if: ${{ steps.release.outputs.release_created }}

- name: Build and publish to GitHub Package
uses: actionshub/publish-gem-to-github@main
if: ${{ steps.release.outputs.release_created }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
owner: ${{ secrets.OWNER }}

- name: Build and publish to RubyGems
uses: actionshub/publish-gem-to-rubygems@main
if: ${{ steps.release.outputs.release_created }}
with:
token: ${{ secrets.RUBYGEMS_API_KEY }}
1 change: 0 additions & 1 deletion .mdlrc

This file was deleted.

12 changes: 8 additions & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
---
AllCops:
TargetRubyVersion: 2.7
require:
- chefstyle

Lint/IneffectiveAccessModifier:
AllCops:
TargetRubyVersion: 3.1
Include:
- "**/*.rb"
Exclude:
- lib/kitchen/driver/aws/standard_platform.rb
- "vendor/**/*"
- "spec/**/*"
15 changes: 1 addition & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ instances. Use Amazon's cloud for your infrastructure testing!
## Requirements

There are **no** external system requirements for this driver. However you
will need access to an [AWS][aws_site] account. [IAM][iam_site] users should have, at a minimum, permission to manage the lifecycle of an EC2 instance along with modifying components specified in kitchen driver configs. Consider using a permissive managed IAM policy like ``arn:aws:iam::aws:policy/AmazonEC2FullAccess`` or tailor one specific to your security requirements.
will need access to an [AWS][aws_site] account. [IAM][iam_site] users should have, at a minimum, permission to manage the lifecycle of an EC2 instance along with modifying components specified in kitchen driver configs. Consider using a permissive managed IAM policy like ``arn:aws:iam::aws:policy/AmazonEC2FullAccess`` or tailor one specific to your security requirements.

## Configuration

Expand All @@ -52,23 +52,10 @@ example:
Apache 2.0 (see [LICENSE][license])


[author]: https://github.com/fnichol
[issues]: https://github.com/test-kitchen/kitchen-ec2/issues
[license]: https://github.com/test-kitchen/kitchen-ec2/blob/master/LICENSE
[repo]: https://github.com/test-kitchen/kitchen-ec2
[driver_usage]: https://github.com/test-kitchen/kitchen-ec2
[chef_omnibus_dl]: https://downloads.chef.io/chef
[amis_json]: https://github.com/test-kitchen/kitchen-ec2/blob/master/data/amis.json
[ami_docs]: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ComponentsAMIs.html
[aws_site]: http://aws.amazon.com/
[iam_site]: http://aws.amazon.com/iam
[credentials_docs]: https://aws.amazon.com/blogs/security/a-new-and-standardized-way-to-manage-credentials-in-the-aws-sdks/
[aws_sdk_gem]: https://docs.aws.amazon.com/sdkforruby/api/index.html
[group_docs]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html
[instance_docs]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html
[key_id_docs]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html
[kitchenci]: https://kitchen.ci/
[region_docs]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html
[subnet_docs]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-subnet.html
[ssh_over_ssm]: https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-getting-started-enable-ssh-connections.html
[vpc_docs]: https://docs.aws.amazon.com/AmazonVPC/latest/GettingStartedGuide/ExerciseOverview.html
4 changes: 2 additions & 2 deletions kitchen-ec2.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Gem::Specification.new do |gem|
gem.name = "kitchen-ec2"
gem.version = Kitchen::Driver::EC2_VERSION
gem.license = "Apache-2.0"
gem.authors = ["Fletcher Nichol"]
gem.email = ["[email protected]"]
gem.authors = ["Test Kitchen Team"]
gem.email = ["[email protected]"]
gem.description = "A Test Kitchen Driver for Amazon EC2"
gem.summary = gem.description
gem.homepage = "https://github.com/test-kitchen/kitchen-ec2"
Expand Down
8 changes: 4 additions & 4 deletions lib/kitchen/driver/aws/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ def initialize(
ssl_verify_peer = true
)
::Aws.config.update(
region: region,
region:,
profile: profile_name,
http_proxy: http_proxy,
ssl_verify_peer: ssl_verify_peer
http_proxy:,
ssl_verify_peer:
)
::Aws.config.update(retry_limit: retry_limit) unless retry_limit.nil?
::Aws.config.update(retry_limit:) unless retry_limit.nil?
end

# create a new AWS EC2 instance
Expand Down
8 changes: 4 additions & 4 deletions lib/kitchen/driver/aws/instance_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ def ec2_instance_data
# and Integers need to be represented as Strings
{ key: k, value: v.to_s }
end
instance_tag_spec = { resource_type: "instance", tags: tags }
volume_tag_spec = { resource_type: "volume", tags: tags }
instance_tag_spec = { resource_type: "instance", tags: }
volume_tag_spec = { resource_type: "volume", tags: }
i[:tag_specifications] = [instance_tag_spec, volume_tag_spec]
end

Expand All @@ -142,7 +142,7 @@ def ec2_instance_data
if i.key?(:placement)
i[:placement][:tenancy] = tenancy
else
i[:placement] = { tenancy: tenancy }
i[:placement] = { tenancy: }
end
end
unless config[:block_device_mappings].nil? || config[:block_device_mappings].empty?
Expand Down Expand Up @@ -186,7 +186,7 @@ def ec2_instance_data
if i.key?(:placement)
i[:placement][:tenancy] = tenancy
else
i[:placement] = { tenancy: tenancy }
i[:placement] = { tenancy: }
end
end
unless config[:instance_initiated_shutdown_behavior].nil? ||
Expand Down
30 changes: 15 additions & 15 deletions lib/kitchen/driver/aws/standard_platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def find_image(image_search)
end

# We prefer most recent first
images = driver.ec2.resource.images(filters: filters)
images = driver.ec2.resource.images(filters:)
images = sort_images(images)
show_returned_images(images)

Expand Down Expand Up @@ -162,6 +162,20 @@ def self.from_image(driver, image)
nil
end

def self.parse_platform_string(platform_string)
platform, version = platform_string.split("-", 2)

# If the right side is a valid architecture, use it as such
# i.e. debian-i386 or windows-server-2012r2-i386
if version && SUPPORTED_ARCHITECTURES.include?(version.split("-")[-1])
# server-2012r2-i386 -> server-2012r2, -, i386
version, _dash, architecture = version.rpartition("-")
version = nil if version == ""
end

[platform, version, architecture]
end

protected

#
Expand Down Expand Up @@ -197,20 +211,6 @@ def prefer(images, &block)

private

def self.parse_platform_string(platform_string)
platform, version = platform_string.split("-", 2)

# If the right side is a valid architecture, use it as such
# i.e. debian-i386 or windows-server-2012r2-i386
if version && SUPPORTED_ARCHITECTURES.include?(version.split("-")[-1])
# server-2012r2-i386 -> server-2012r2, -, i386
version, _dash, architecture = version.rpartition("-")
version = nil if version == ""
end

[platform, version, architecture]
end

def sort_images(images)
# P6: We prefer more recent images over older ones
images = images.sort_by(&:creation_date).reverse
Expand Down
4 changes: 2 additions & 2 deletions lib/kitchen/driver/ec2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ def submit_spot

instance_data[:instance_market_options] = {
market_type: "spot",
spot_options: spot_options,
spot_options:,
}

# The preferred way to create a spot instance is via request_spot_instances()
Expand Down Expand Up @@ -837,7 +837,7 @@ def create_security_group(state)
from_port: port,
to_port: port,
ip_ranges: Array(config[:security_group_cidr_ip]).map do |cidr_ip|
{ cidr_ip: cidr_ip }
{ cidr_ip: }
end,
}
end
Expand Down
8 changes: 8 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended",
":disableDependencyDashboard",
"schedule:automergeEarlyMondays"
]
}

0 comments on commit 8502d05

Please sign in to comment.