From 484b712e4ed1c720b022a596029441f1966b63af Mon Sep 17 00:00:00 2001 From: Brandur Date: Thu, 19 Dec 2024 21:54:10 -0700 Subject: [PATCH] Add `.tool-versions` containing Ruby 3.3 Add a `.tool-versions` so that the project works out of the box with version managers like asdf and mise. Add a CI check that makes sure our Ruby version in use there matches what's in `.tool-versions` so the two don't drift. --- .github/workflows/ci.yaml | 21 +++++++++++++++++++++ .tool-versions | 1 + 2 files changed, 22 insertions(+) create mode 100644 .tool-versions diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 61f712d..af69ac7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -84,6 +84,27 @@ jobs: run: bundle exec standardrb working-directory: ./driver/riverqueue-sequel + tool_versions_check: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Check RUBY_VERSION matches .tool-versions Ruby version + run: | + cat <<- "EOF" | ruby + ruby_env = ENV["RUBY_VERSION"] || abort("need RUBY_VERSION") + ruby_tool_versions = File.read('.tool-versions').split('\n')[0].split[1] + + if ruby_env != ruby_tool_versions + abort("CI version $RUBY_VERSION ${ruby_env } should match .tool-versions Ruby ${ruby_tool_versions }") + end + EOF + + # run: | + # [[ "$RUBY_VERSION" == "$(cat .tool-versions | grep ruby | cut -w -f 2)" ]] || echo "CI version \$RUBY_VERSION should match .tool-versions Ruby `cat .tool-versions | grep ruby | cut -w -f 2`" && (exit 1) + type_check: runs-on: ubuntu-latest timeout-minutes: 3 diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..053cba7 --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +ruby 3.3