From 8e6a63970089fe329c2bb39b7e743aa467b75470 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sat, 16 Apr 2022 22:05:29 -0700 Subject: [PATCH] Test with multiple Rails versions on CI --- .github/workflows/build.yml | 20 +++++++++++++++++++- .gitignore | 1 + gemfiles/rails50.gemfile | 9 +++++++++ gemfiles/rails51.gemfile | 9 +++++++++ gemfiles/rails52.gemfile | 9 +++++++++ gemfiles/rails60.gemfile | 9 +++++++++ gemfiles/rails61.gemfile | 9 +++++++++ test/charts_test.rb | 4 ++-- test/checks_test.rb | 2 ++ test/queries_test.rb | 2 +- 10 files changed, 70 insertions(+), 4 deletions(-) create mode 100644 gemfiles/rails50.gemfile create mode 100644 gemfiles/rails51.gemfile create mode 100644 gemfiles/rails52.gemfile create mode 100644 gemfiles/rails60.gemfile create mode 100644 gemfiles/rails61.gemfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8b0250411..57d9f38a5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,11 +3,29 @@ on: [push, pull_request] jobs: build: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - ruby: 3.1 + gemfile: Gemfile + - ruby: "3.0" + gemfile: gemfiles/rails61.gemfile + - ruby: 2.7 + gemfile: gemfiles/rails60.gemfile + - ruby: 2.6 + gemfile: gemfiles/rails52.gemfile + - ruby: 2.5 + gemfile: gemfiles/rails51.gemfile + - ruby: 2.4 + gemfile: gemfiles/rails50.gemfile + env: + BUNDLE_GEMFILE: ${{ matrix.gemfile }} steps: - uses: actions/checkout@v2 - uses: ruby/setup-ruby@v1 with: - ruby-version: 3.1 + ruby-version: ${{ matrix.ruby }} bundler-cache: true - uses: ankane/setup-postgres@v1 with: diff --git a/.gitignore b/.gitignore index 9422fab8c..6aae22186 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ *.log *.sqlite /test/internal/tmp +*.lock diff --git a/gemfiles/rails50.gemfile b/gemfiles/rails50.gemfile new file mode 100644 index 000000000..822c53ddb --- /dev/null +++ b/gemfiles/rails50.gemfile @@ -0,0 +1,9 @@ +source "https://rubygems.org" + +gemspec path: ".." + +gem "rake" +gem "minitest", ">= 5" +gem "combustion" +gem "rails", "~> 5.0.0" +gem "pg" diff --git a/gemfiles/rails51.gemfile b/gemfiles/rails51.gemfile new file mode 100644 index 000000000..d3ca05fbe --- /dev/null +++ b/gemfiles/rails51.gemfile @@ -0,0 +1,9 @@ +source "https://rubygems.org" + +gemspec path: ".." + +gem "rake" +gem "minitest", ">= 5" +gem "combustion" +gem "rails", "~> 5.1.0" +gem "pg" diff --git a/gemfiles/rails52.gemfile b/gemfiles/rails52.gemfile new file mode 100644 index 000000000..99410e397 --- /dev/null +++ b/gemfiles/rails52.gemfile @@ -0,0 +1,9 @@ +source "https://rubygems.org" + +gemspec path: ".." + +gem "rake" +gem "minitest", ">= 5" +gem "combustion" +gem "rails", "~> 5.2.0" +gem "pg" diff --git a/gemfiles/rails60.gemfile b/gemfiles/rails60.gemfile new file mode 100644 index 000000000..655f29a29 --- /dev/null +++ b/gemfiles/rails60.gemfile @@ -0,0 +1,9 @@ +source "https://rubygems.org" + +gemspec path: ".." + +gem "rake" +gem "minitest", ">= 5" +gem "combustion" +gem "rails", "~> 6.0.0" +gem "pg" diff --git a/gemfiles/rails61.gemfile b/gemfiles/rails61.gemfile new file mode 100644 index 000000000..18d9a3652 --- /dev/null +++ b/gemfiles/rails61.gemfile @@ -0,0 +1,9 @@ +source "https://rubygems.org" + +gemspec path: ".." + +gem "rake" +gem "minitest", ">= 5" +gem "combustion" +gem "rails", "~> 6.1.0" +gem "pg" diff --git a/test/charts_test.rb b/test/charts_test.rb index 317b3342d..ecb64a6a1 100644 --- a/test/charts_test.rb +++ b/test/charts_test.rb @@ -12,12 +12,12 @@ def test_line_chart_format2 end def test_column_chart_format1 - run_query "SELECT 'Label', 1" + run_query "SELECT 'Label' AS label, 1" assert_match "ColumnChart", response.body end def test_column_chart_format2 - run_query "SELECT 'Label', 'Group', 1" + run_query "SELECT 'Label' AS label, 'Group' AS group, 1" assert_match "ColumnChart", response.body assert_match %{"name":"Group"}, response.body end diff --git a/test/checks_test.rb b/test/checks_test.rb index c87934ead..a9fe8e6b6 100644 --- a/test/checks_test.rb +++ b/test/checks_test.rb @@ -50,6 +50,8 @@ def test_error end def test_emails + skip "No assert_emails" if Rails::VERSION::MAJOR < 6 + query = create_query check = create_check(query: query, check_type: "bad_data", emails: "hi@example.org,hi2@example.org") diff --git a/test/queries_test.rb b/test/queries_test.rb index 8aaae8ab5..364abb61c 100644 --- a/test/queries_test.rb +++ b/test/queries_test.rb @@ -107,7 +107,7 @@ def test_images_default def test_images Blazer.stub(:images, true) do run_query("SELECT 'http://localhost:3000/image.png'") - assert_match %{}, response.body + assert_match %{