diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index adfa3d6..0000000 --- a/.dockerignore +++ /dev/null @@ -1,4 +0,0 @@ -.git -*.gem -Gemfile* -pkg/ diff --git a/CHANGES.md b/CHANGES.md index 80c47c4..4981275 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,12 @@ # CHANGES +## 1.8.0 (2022-08-23) + +* Feature: Add support for ruby 3.1 +* Dev: Upgrade dev setup and base docker image to ruby 3.1 +* Dev: Replace docker-compose dev setup with normal docker +* Dev: Add helpers to easily test all supported ruby versions locally + ## 1.7.2 (2021-12-24) * Upgrade dev setup and base docker image to ruby 3.0 diff --git a/Dockerfile b/Dockerfile index 33a59ac..92bcbc7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:3.0-alpine@sha256:9afcc885895358e84929c19ea53cb62ecc50daf93dcbd45de469f2e668d96e9a as build +FROM ruby:3.1-alpine@sha256:499a310e8fab835ad47ab6251302aba1fd6ba91ebdfa22d621f495a5d0ded170 as build WORKDIR /app COPY bin /app/bin @@ -10,7 +10,7 @@ COPY LICENSE.md /app/ COPY stackup.gemspec /app/ RUN gem build stackup.gemspec -FROM ruby:3.0-alpine@sha256:9afcc885895358e84929c19ea53cb62ecc50daf93dcbd45de469f2e668d96e9a +FROM ruby:3.1-alpine@sha256:499a310e8fab835ad47ab6251302aba1fd6ba91ebdfa22d621f495a5d0ded170 MAINTAINER https://github.com/realestate-com-au/stackup diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 0000000..8d872de --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,20 @@ +ARG BASE_IMAGE +FROM $BASE_IMAGE + +ARG TARGETARCH +ENV BUNDLE_JOBS=3 + +RUN mkdir -p /work/ +WORKDIR /work/ + +COPY .rubocop.yml /work/ +COPY .rspec /work/ +COPY examples /work/examples +COPY bin /work/bin +COPY stackup.gemspec /work/ +COPY Gemfile /work/ +COPY spec /work/spec +COPY lib /work/lib +RUN bundle install + +CMD ["/usr/bin/env", "bash"] diff --git a/Rakefile b/Rakefile deleted file mode 100644 index a61d4b3..0000000 --- a/Rakefile +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -require "bundler/gem_tasks" - -require "rspec/core/rake_task" - -RSpec::Core::RakeTask.new do |t| - t.pattern = "spec/**/*_spec.rb" - t.rspec_opts = ["--colour", "--format", "documentation"] -end - -task "default" => "spec" - -require "rubocop/rake_task" - -RuboCop::RakeTask.new diff --git a/auto/dev-environment b/auto/dev-environment deleted file mode 100755 index 5ed05ce..0000000 --- a/auto/dev-environment +++ /dev/null @@ -1,11 +0,0 @@ -#! /bin/bash -e -# -# Run rake - -cd $(dirname $0)/.. - -trap "docker-compose down --volumes" 0 - -docker volume create --name ruby3.0-bundle-cache > /dev/null -docker-compose run --rm dev sh -c 'bundle check > /dev/null || bundle install' -docker-compose run --rm dev bundle exec "${@-bash}" diff --git a/auto/lint b/auto/lint index 3f144df..f435b3e 100755 --- a/auto/lint +++ b/auto/lint @@ -1,8 +1,8 @@ -#! /bin/bash -eu -# -# Run linter +#!/usr/bin/env bash +set -eu -o pipefail cd $(dirname $0)/.. echo "+++ Running linter" -./auto/dev-environment rake rubocop +# We lint on the lowest supported ruby version +./auto/ruby-2.7 rubocop diff --git a/auto/release-gem b/auto/release-gem index ffb9894..7417124 100755 --- a/auto/release-gem +++ b/auto/release-gem @@ -1,7 +1,6 @@ -#! /bin/bash -eu -# -# Release Stackup +#!/usr/bin/env bash +set -eu -o pipefail cd $(dirname $0)/.. rm -f stackup-*.gem @@ -11,4 +10,4 @@ git fetch origin git diff origin/main --exit-code echo "--- Releasing gem" -docker run --rm -itw /cwd -v "$PWD:/cwd" ruby:3.0-alpine auto/release-in-docker +docker run --rm -itw /cwd -v "$PWD:/cwd" ruby:3.1-alpine auto/release-in-docker diff --git a/auto/ruby b/auto/ruby new file mode 100755 index 0000000..177561c --- /dev/null +++ b/auto/ruby @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +set -eu -o pipefail +cd $(dirname $0)/.. + +if [ -z "${RUBY_IMAGE:-}" ]; then + 2>&1 echo "Please use one of the auto/ruby-* wrappers and not this one." + exit 1 +fi + +echo "~~~ Building dev image" +docker build \ + --quiet \ + --build-arg BASE_IMAGE="${RUBY_IMAGE}" \ + --tag stackup:dev \ + --file Dockerfile.dev \ + . + +echo "~~~ Running dev image" +docker run --rm --interactive --tty stackup:dev $@ diff --git a/auto/ruby-2.7 b/auto/ruby-2.7 new file mode 100755 index 0000000..01c2fc3 --- /dev/null +++ b/auto/ruby-2.7 @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -eu -o pipefail +cd $(dirname $0)/.. + +RUBY_IMAGE="ruby:2.7@sha256:3d9c2a2d305318710c9e5a4ee001e07e227f356a40e0b6003d8440835d430770" exec auto/ruby "${@}" diff --git a/auto/ruby-3.0 b/auto/ruby-3.0 new file mode 100755 index 0000000..9106875 --- /dev/null +++ b/auto/ruby-3.0 @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -eu -o pipefail +cd $(dirname $0)/.. + +RUBY_IMAGE="ruby:3.0@sha256:dfb439f51e6ba58810fed23e4c4582f3e3c24e6a972ec505de27217f5036c567" exec auto/ruby "${@}" diff --git a/auto/ruby-3.1 b/auto/ruby-3.1 new file mode 100755 index 0000000..9f2e81c --- /dev/null +++ b/auto/ruby-3.1 @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -eu -o pipefail +cd $(dirname $0)/.. + +RUBY_IMAGE="ruby:3.1@sha256:ffdb4e42cf4663e10c32d3ea91312b61df931b41439c16f7b88a7f6e70a65b6d" exec auto/ruby "${@}" diff --git a/auto/test b/auto/test index 03960d9..152f6e8 100755 --- a/auto/test +++ b/auto/test @@ -1,8 +1,13 @@ -#! /bin/bash -eu -# -# Run tests +#!/usr/bin/env bash +set -eu -o pipefail cd $(dirname $0)/.. -echo "+++ Running specs" -./auto/dev-environment rake spec +echo "+++ Running specs for ruby 3.1" +./auto/ruby-3.1 rspec + +echo "+++ Running specs for ruby 3.0" +./auto/ruby-3.0 rspec + +echo "+++ Running specs for ruby 2.7" +./auto/ruby-2.7 rspec diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index f932e5b..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: "2" - -services: - dev: - image: ruby:3.0@sha256:f6c236c1474acd83216ccacbaf7019778cbaea73c8048652087a4b64a862af63 - volumes: - - .:/work - - ruby3.0-bundle-cache:/usr/local/bundle - environment: - BUNDLE_GEMFILE: /work/Gemfile - AWS_ACCESS_KEY_ID: - AWS_SECRET_ACCESS_KEY: - AWS_SESSION_TOKEN: - AWS_REGION: ap-southeast-2 - working_dir: /work - command: ["bash"] - -volumes: - ruby3.0-bundle-cache: - external: true diff --git a/lib/stackup/yaml.rb b/lib/stackup/yaml.rb index a7b3267..2d191e9 100644 --- a/lib/stackup/yaml.rb +++ b/lib/stackup/yaml.rb @@ -24,7 +24,8 @@ def dump(*args) # `!Foo blah` as a shortcut for `{ "Fn::Foo" => blah }` # def load(yaml, filename = nil) - tree = ::YAML.parse(yaml, filename) + legacy_yaml = Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3.0") + tree = legacy_yaml ? ::YAML.parse(yaml, filename) : ::YAML.parse(yaml, :filename => filename) return tree unless tree CloudFormationToRuby.create.accept(tree)