diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 27aa315..65a815d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,4 +1,4 @@ -name: Ruby +name: Lint on: [push] diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..c3c2a0a --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,30 @@ +name: Test + +on: [push] + +jobs: + test: + env: + RAILS_ENV: "test" + TEST_DATABASE_URL: "mysql2://root:unipept@127.0.0.1:3306/unipept_test" + runs-on: ubuntu-latest + services: + mysql: + image: mariadb:10.9 + env: + MYSQL_DATABASE: "unipept_test" + MYSQL_ROOT_PASSWORD: "unipept" + MYSQL_HOST: "localhost" + ports: + - 3306:3306 + options: --health-cmd "mysqladmin ping -h localhost" --health-interval 10s --health-timeout 5s --health-retries 5 + steps: + - uses: actions/checkout@v3 + - name: Use ruby from .ruby-version + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + - name: Run tests + run: | + bundle exec rails db:test:prepare + bundle exec rails test diff --git a/config/database.yml b/config/database.yml index dbbd538..1147c46 100644 --- a/config/database.yml +++ b/config/database.yml @@ -17,7 +17,7 @@ development: test: <<: *default database: unipept_test - socket: /tmp/mysql.sock + url: <%= ENV['TEST_DATABASE_URL'] || ENV['DATABASE_URL'] %> production: <<: *default