Skip to content

Commit

Permalink
Merge pull request #98 from realestate-com-au/ruby-3-1
Browse files Browse the repository at this point in the history
Ruby 3.1 support
  • Loading branch information
Danial Pearce authored Aug 23, 2022
2 parents 6da7dd7 + 856a934 commit beca225
Show file tree
Hide file tree
Showing 15 changed files with 86 additions and 67 deletions.
4 changes: 0 additions & 4 deletions .dockerignore

This file was deleted.

7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand Down
20 changes: 20 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -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"]
16 changes: 0 additions & 16 deletions Rakefile

This file was deleted.

11 changes: 0 additions & 11 deletions auto/dev-environment

This file was deleted.

8 changes: 4 additions & 4 deletions auto/lint
Original file line number Diff line number Diff line change
@@ -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
7 changes: 3 additions & 4 deletions auto/release-gem
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#! /bin/bash -eu
#
# Release Stackup
#!/usr/bin/env bash

set -eu -o pipefail
cd $(dirname $0)/..

rm -f stackup-*.gem
Expand All @@ -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
20 changes: 20 additions & 0 deletions auto/ruby
Original file line number Diff line number Diff line change
@@ -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 $@
6 changes: 6 additions & 0 deletions auto/ruby-2.7
Original file line number Diff line number Diff line change
@@ -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 "${@}"
6 changes: 6 additions & 0 deletions auto/ruby-3.0
Original file line number Diff line number Diff line change
@@ -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 "${@}"
6 changes: 6 additions & 0 deletions auto/ruby-3.1
Original file line number Diff line number Diff line change
@@ -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 "${@}"
15 changes: 10 additions & 5 deletions auto/test
Original file line number Diff line number Diff line change
@@ -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
20 changes: 0 additions & 20 deletions docker-compose.yml

This file was deleted.

3 changes: 2 additions & 1 deletion lib/stackup/yaml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit beca225

Please sign in to comment.