From ef9ff7337c30fe6da8be93dfa1e86c50aedaf60a Mon Sep 17 00:00:00 2001 From: Shashike Jayatunge <35935196+donrestarone@users.noreply.github.com> Date: Mon, 13 Jun 2022 19:51:49 -0400 Subject: [PATCH] [CI] action to verify schema.rb integrity, [CI] Support for node 10 and 14 builds addresses: https://github.com/restarone/violet_rails/issues/660 https://github.com/restarone/violet_rails/issues/640 Co-authored-by: Mushfiq Rahman Co-authored-by: Prashant Co-authored-by: Shashike Jayatunge <35935196+donrestarone@users.noreply.github.com> Co-authored-by: Pralish Kayastha <50227291+Pralish@users.noreply.github.com> --- .github/workflows/ruby.yml | 19 ++++++++++++++++++- package.json | 5 +++-- test/models/subdomain_test.rb | 5 +++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 41941f30b..b80ac1fd2 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -28,6 +28,9 @@ jobs: image: redis:4.0-alpine ports: - 6379:6379 + strategy: + matrix: + node_version: [14.x, 10.x] steps: - name: Configure sysctl limits run: | @@ -49,11 +52,25 @@ jobs: bundler-cache: true # runs 'bundle install' and caches installed gems automatically - uses: actions/setup-node@v2 with: - node-version: 14.x + node-version: ${{ matrix.node_version }} + - name: Fetch schema file before running migration + run: | + tmpfile=$(mktemp) + cp ./db/schema.rb tmpfile - name: Setup main DB run: | bin/rails db:create bin/rails db:migrate + - name: Comparing schema.rb to db/migrations + run: | + if ! diff -q tmpfile ./db/schema.rb &>/dev/null; then + rm tmpfile + >&2 echo "Migration changes have not been committed." + # Exits the github workflow + exit 1 + fi + rm tmpfile + echo "Migrations have been committed." - name: compile assets/javascript run: | yarn install diff --git a/package.json b/package.json index 824e9fba4..82e18b8dc 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,8 @@ }, "cacheDirectories": ["client/node_modules","node_modules"], "engines": { - "node": "14.19.x || 10.19.x", - "yarn": "1.22.x" + "node": "14.x || 10.x", + "yarn": "1.22.x", + "npm": "6.14.x" } } diff --git a/test/models/subdomain_test.rb b/test/models/subdomain_test.rb index 3233c78ae..e1cf19be3 100755 --- a/test/models/subdomain_test.rb +++ b/test/models/subdomain_test.rb @@ -6,6 +6,11 @@ class SubdomainTest < ActiveSupport::TestCase @subdomain = subdomains(:public) end + test "can be created" do + subdomain = Subdomain.new(name: "test") + assert subdomain.save + end + test "uniqness" do duplicate = Subdomain.new( name: @subdomain.name