diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d2bd0f5..9870e87 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,13 +5,19 @@ on: - main jobs: tests: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v2 - name: Setup FluentCI uses: fluentci-io/setup-fluentci@v5 + with: + wasm: true + plugin: postgres + args: start env: GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} + POSTGRES_USER: postgres + POSTGRES_DB: demo_rails_test - name: check style + security run: | fluentci run --wasm ruby bundle_exec rubocop @@ -26,3 +32,4 @@ jobs: fluentci run --wasm ruby bundle_exec rspec spec env: GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} + RAILS_ENV: test diff --git a/Gemfile b/Gemfile index fb803cb..40f7cd8 100644 --- a/Gemfile +++ b/Gemfile @@ -9,8 +9,8 @@ gem "rails", "~> 7.0.6" # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] gem "sprockets-rails" -# Use sqlite3 as the database for Active Record -gem "sqlite3", "~> 1.4" +# Use postgresql as the database for Active Record +gem "pg", "~> 1.1" # Use the Puma web server [https://github.com/puma/puma] gem "puma", "~> 5.0" diff --git a/Gemfile.lock b/Gemfile.lock index 78245dd..65be050 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -135,6 +135,7 @@ GEM parser (3.2.2.3) ast (~> 2.4.1) racc + pg (1.5.7) public_suffix (5.0.3) puma (5.6.6) nio4r (~> 2.0) @@ -220,7 +221,6 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - sqlite3 (1.6.3-x86_64-linux) stimulus-rails (1.2.1) railties (>= 6.0.0) thor (1.2.2) @@ -260,6 +260,7 @@ DEPENDENCIES debug importmap-rails jbuilder + pg (~> 1.1) puma (~> 5.0) rails (~> 7.0.6) redis (~> 4.0) @@ -267,7 +268,6 @@ DEPENDENCIES rubocop selenium-webdriver sprockets-rails - sqlite3 (~> 1.4) stimulus-rails turbo-rails tzinfo-data diff --git a/config/database.yml b/config/database.yml index fcba57f..cee1584 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,25 +1,87 @@ -# SQLite. Versions 3.8.0 and up are supported. -# gem install sqlite3 +# PostgreSQL. Versions 9.3 and up are supported. # -# Ensure the SQLite 3 gem is defined in your Gemfile -# gem "sqlite3" +# Install the pg driver: +# gem install pg +# On macOS with Homebrew: +# gem install pg -- --with-pg-config=/usr/local/bin/pg_config +# On Windows: +# gem install pg +# Choose the win32 build. +# Install PostgreSQL and put its /bin directory on your path. +# +# Configure Using Gemfile +# gem "pg" # default: &default - adapter: sqlite3 + adapter: postgresql + encoding: unicode + # For details on connection pooling, see Rails configuration guide + # https://guides.rubyonrails.org/configuring.html#database-pooling pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> - timeout: 5000 + username: postgres + host: localhost + port: 5432 development: <<: *default - database: db/development.sqlite3 + database: demo_rails_development + + # The specified database role being used to connect to PostgreSQL. + # To create additional roles in PostgreSQL see `$ createuser --help`. + # When left blank, PostgreSQL will use the default role. This is + # the same name as the operating system user running Rails. + #username: blog + + # The password associated with the PostgreSQL role (username). + #password: + + # Connect on a TCP socket. Omitted by default since the client uses a + # domain socket that doesn't need configuration. Windows does not have + # domain sockets, so uncomment these lines. + #host: localhost + + # The TCP port the server listens on. Defaults to 5432. + # If your server runs on a different port number, change accordingly. + #port: 5432 + + # Schema search path. The server defaults to $user,public + #schema_search_path: myapp,sharedapp,public + + # Minimum log levels, in increasing order: + # debug5, debug4, debug3, debug2, debug1, + # log, notice, warning, error, fatal, and panic + # Defaults to warning. + #min_messages: notice # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: <<: *default - database: db/test.sqlite3 + database: demo_rails_test +# As with config/credentials.yml, you never want to store sensitive information, +# like your database password, in your source code. If your source code is +# ever seen by anyone, they now have access to your database. +# +# Instead, provide the password or a full connection URL as an environment +# variable when you boot the app. For example: +# +# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase" +# +# If the connection URL is provided in the special DATABASE_URL environment +# variable, Rails will automatically merge its configuration values on top of +# the values provided in this file. Alternatively, you can specify a connection +# URL environment variable explicitly: +# +# production: +# url: <%= ENV["MY_APP_DATABASE_URL"] %> +# +# Read https://guides.rubyonrails.org/configuring.html#configuring-a-database +# for a full overview on how database connection configuration can be specified. +# production: <<: *default - database: db/production.sqlite3 + database: demo_rails_production + username: postgres + password: <%= ENV["BLOG_DATABASE_PASSWORD"] %> diff --git a/devbox.json b/devbox.json index 05fcaa8..47f030f 100644 --- a/devbox.json +++ b/devbox.json @@ -6,7 +6,8 @@ "yarn@latest", "pkg-config@latest", "gcc@latest", - "gnumake@latest" + "gnumake@latest", + "postgresql@latest" ], "shell": { "init_hook": [ diff --git a/devbox.lock b/devbox.lock index e4c7339..5fd568e 100644 --- a/devbox.lock +++ b/devbox.lock @@ -273,6 +273,115 @@ } } }, + "postgresql@latest": { + "last_modified": "2024-08-21T20:16:49Z", + "plugin_version": "0.0.2", + "resolved": "github:NixOS/nixpkgs/36a9aeaaa17a2d4348498275f9fe530cd4f9e519#postgresql", + "source": "devbox-search", + "version": "16.4", + "systems": { + "aarch64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/i0asdxabgdls1xnjgd1a5y1fv27nfmfw-postgresql-16.4", + "default": true + }, + { + "name": "man", + "path": "/nix/store/mx2n38fqz3y7bbw9i2vccgr1nr53nlhy-postgresql-16.4-man", + "default": true + }, + { + "name": "doc", + "path": "/nix/store/8s96kqcqdjxczgqlwjsp5sd293pgfc1m-postgresql-16.4-doc" + }, + { + "name": "lib", + "path": "/nix/store/jvc35r9p6y5pv8i7skbmbi120s7jq6ay-postgresql-16.4-lib" + } + ], + "store_path": "/nix/store/i0asdxabgdls1xnjgd1a5y1fv27nfmfw-postgresql-16.4" + }, + "aarch64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/d1ks0fmlm3jx4zb3zs8ghp973v28p2hi-postgresql-16.4", + "default": true + }, + { + "name": "man", + "path": "/nix/store/kvf1yxvm3zsbykm022zhk5xjdsady9c1-postgresql-16.4-man", + "default": true + }, + { + "name": "debug", + "path": "/nix/store/mxf4lgspi1c2ag5z3nmr2sd8q6pmssjb-postgresql-16.4-debug" + }, + { + "name": "doc", + "path": "/nix/store/f1vyyv54ai0hq553ncm8ahaz5i948ign-postgresql-16.4-doc" + }, + { + "name": "lib", + "path": "/nix/store/wbypzrzg1z9yl6cw6n4c2703z9m3dyzl-postgresql-16.4-lib" + } + ], + "store_path": "/nix/store/d1ks0fmlm3jx4zb3zs8ghp973v28p2hi-postgresql-16.4" + }, + "x86_64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/fpwv4ygz88bdk9xa3zw9almda756p9x8-postgresql-16.4", + "default": true + }, + { + "name": "man", + "path": "/nix/store/yn0kvg33b2c6bkparh2vb74m2fdpszzs-postgresql-16.4-man", + "default": true + }, + { + "name": "doc", + "path": "/nix/store/66sbl8q8gl2v6gjck736pg9ay8h68apy-postgresql-16.4-doc" + }, + { + "name": "lib", + "path": "/nix/store/qlp9p58ph8i1pjn6cnz0mycq64kid88a-postgresql-16.4-lib" + } + ], + "store_path": "/nix/store/fpwv4ygz88bdk9xa3zw9almda756p9x8-postgresql-16.4" + }, + "x86_64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/48abcjx52nbp8myygxgwqb4gh4xsg5fa-postgresql-16.4", + "default": true + }, + { + "name": "man", + "path": "/nix/store/nskmfhwxkzpn0cb1b69ap46jp9qcdg5p-postgresql-16.4-man", + "default": true + }, + { + "name": "debug", + "path": "/nix/store/mwdr7qpyf1ggllcs0f1qgywj3rab14v4-postgresql-16.4-debug" + }, + { + "name": "doc", + "path": "/nix/store/vxrd7vs1v3mv70004mrs3070fjl58vrr-postgresql-16.4-doc" + }, + { + "name": "lib", + "path": "/nix/store/37l0ff1bqzppalq55g7a5af0fcvg47wy-postgresql-16.4-lib" + } + ], + "store_path": "/nix/store/48abcjx52nbp8myygxgwqb4gh4xsg5fa-postgresql-16.4" + } + } + }, "ruby_3_1@latest": { "last_modified": "2024-05-01T20:12:28Z", "plugin_version": "0.0.2",