From 00c6f236e097f52cc4d8d47b8736cf7ce751f0c7 Mon Sep 17 00:00:00 2001 From: Bram Jetten Date: Tue, 8 Oct 2024 21:50:50 +0200 Subject: [PATCH] Add SQLite database tests --- .github/workflows/ruby.yml | 45 +++++++++++++++++-- ...atabase.yml.ci => database.yml.postgresql} | 0 test/dummy/config/database.yml.sqlite | 8 ++++ 3 files changed, 50 insertions(+), 3 deletions(-) rename test/dummy/config/{database.yml.ci => database.yml.postgresql} (100%) create mode 100644 test/dummy/config/database.yml.sqlite diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 1fd8a72a8..f83df351b 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -7,11 +7,12 @@ on: branches: [ main ] jobs: - test: + test-postgresql: + name: Test on PostgreSQL runs-on: ubuntu-latest strategy: matrix: - ruby-version: ['3.2'] + ruby-version: ['3.3'] services: postgres: @@ -50,7 +51,7 @@ jobs: env: RAILS_ENV: test run: | - cp test/dummy/config/database.yml.ci test/dummy/config/database.yml + cp test/dummy/config/database.yml.postgresql test/dummy/config/database.yml bin/rails db:setup - name: Compile assets @@ -66,3 +67,41 @@ jobs: GIT_BRANCH: ${GITHUB_REF/refs\/heads\//} run: ./cc-test-reporter after-build -r ${{ secrets.CodeClimate }} if: github.ref == 'refs/heads/main' + + test-sqlite: + name: Test on SQLite + runs-on: ubuntu-latest + strategy: + matrix: + ruby-version: ['3.3'] + steps: + - uses: actions/checkout@v2 + + - name: Install libvips + run: sudo apt-get install -y libvips + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true + + - name: Install dependencies + run: bundle install + + - name: Create DB + env: + RAILS_ENV: test + run: | + cp test/dummy/config/database.yml.sqlite test/dummy/config/database.yml + bin/rails db:setup + + - name: Compile assets + env: + RAILS_ENV: test + run: bin/rails app:assets:precompile + + - name: Run tests + env: + RAILS_ENV: test + run: bin/rails test test/* diff --git a/test/dummy/config/database.yml.ci b/test/dummy/config/database.yml.postgresql similarity index 100% rename from test/dummy/config/database.yml.ci rename to test/dummy/config/database.yml.postgresql diff --git a/test/dummy/config/database.yml.sqlite b/test/dummy/config/database.yml.sqlite new file mode 100644 index 000000000..873cd3808 --- /dev/null +++ b/test/dummy/config/database.yml.sqlite @@ -0,0 +1,8 @@ +default: &default + adapter: sqlite3 + pool: 5 + timeout: 5000 + +test: + <<: *default + database: db/test.sqlite3