diff --git a/.github/workflows/test_generated_app.yml b/.github/workflows/test_generated_app.yml index 71899587..5e5449d6 100644 --- a/.github/workflows/test_generated_app.yml +++ b/.github/workflows/test_generated_app.yml @@ -9,9 +9,9 @@ env: DOCKER_REGISTRY_HOST: ${{ secrets.DOCKER_REGISTRY_HOST }} DOCKER_REGISTRY_USERNAME: ${{ github.repository_owner }} DOCKER_REGISTRY_TOKEN: ${{ secrets.DOCKER_REGISTRY_TOKEN }} - RUBY_VERSION: 3.2.2 - NODE_VERSION: 18 - RAILS_VERSION: 7.1.2 + RUBY_VERSION: 3.3.1 + NODE_VERSION: 22 + RAILS_VERSION: 7.1.3 concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/test_production_build.yml b/.github/workflows/test_production_build.yml index 362c9655..5e02e0c2 100644 --- a/.github/workflows/test_production_build.yml +++ b/.github/workflows/test_production_build.yml @@ -6,9 +6,9 @@ env: APP_NAME: rails-templates DOCKER_IMAGE: ${{ github.repository }} DOCKER_REGISTRY_HOST: ${{ secrets.DOCKER_REGISTRY_HOST }} - RUBY_VERSION: 3.2.2 - NODE_VERSION: 18 - RAILS_VERSION: 7.1.2 + RUBY_VERSION: 3.3.1 + NODE_VERSION: 22 + RAILS_VERSION: 7.1.3 concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/test_template.yml b/.github/workflows/test_template.yml index 37ceb327..73abfa1f 100644 --- a/.github/workflows/test_template.yml +++ b/.github/workflows/test_template.yml @@ -3,7 +3,7 @@ name: Test the codebase of the template on: push env: - RUBY_VERSION: 3.2.2 + RUBY_VERSION: 3.3.1 concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.template/addons/docker/docker-compose.dev.yml.tt b/.template/addons/docker/docker-compose.dev.yml.tt index d6096c45..092f6857 100644 --- a/.template/addons/docker/docker-compose.dev.yml.tt +++ b/.template/addons/docker/docker-compose.dev.yml.tt @@ -1,4 +1,4 @@ -version: '3.2' +version: '3.8' services: db: diff --git a/.template/addons/docker/docker-compose.test.yml.tt b/.template/addons/docker/docker-compose.test.yml.tt index cb83d3f4..ad14ba96 100644 --- a/.template/addons/docker/docker-compose.test.yml.tt +++ b/.template/addons/docker/docker-compose.test.yml.tt @@ -1,4 +1,4 @@ -version: '3.2' +version: '3.8' services: db: diff --git a/.template/addons/docker/docker-compose.yml.tt b/.template/addons/docker/docker-compose.yml.tt index 0957e933..570afa4f 100644 --- a/.template/addons/docker/docker-compose.yml.tt +++ b/.template/addons/docker/docker-compose.yml.tt @@ -1,4 +1,4 @@ -version: '3.2' +version: '3.8' services: db: @@ -6,6 +6,7 @@ services: container_name: <%= CONTAINERIZED_APP_NAME %>-db environment: - POSTGRES_DB=<%= APP_NAME %>_production + - POSTGRES_PASSWORD=postgres ports: - "5432:5432" diff --git a/.template/addons/semaphore/.semaphore/README.md.tt b/.template/addons/semaphore/.semaphore/README.md.tt deleted file mode 100644 index b7459b1e..00000000 --- a/.template/addons/semaphore/.semaphore/README.md.tt +++ /dev/null @@ -1,49 +0,0 @@ -# Semaphore CI 2.0 - -## Requirements: - -- Install [Semaphore CLI](https://docs.semaphoreci.com/reference/sem-command-line-tool/) - -## Setup the CI - -### Secrets - -Setup the following secrets in order to run the pipeline: - -Secret name: `<%= APP_NAME %>` - -- DOCKER_REGISTRY_HOST -- DOCKER_REGISTRY_USERNAME -- DOCKER_REGISTRY_TOKEN -- HEROKU_API_KEY - -### Deployment dashboard - -After the project is created on Semaphore CI (on first push), -use the sem CLI to create the deployment dashboard. - -``` -# Get the project id -> sem get project <%= APP_NAME %> - -# Create the deployment dashboard -> sem create dashboard <%= APP_NAME %> -> sem edit dashboard <%= APP_NAME %> -``` - -Configure the widgets to show the deployment pipelines - -``` -spec: - widgets: - - name: Production - type: list_pipelines - filters: - pipeline_file: .semaphore/promotion-production.yml - project_id: - - name: Staging - type: list_pipelines - filters: - pipeline_file: .semaphore/promotion-staging.yml - project_id: -``` diff --git a/.template/addons/semaphore/.semaphore/promotion-production.yml.tt b/.template/addons/semaphore/.semaphore/promotion-production.yml.tt deleted file mode 100644 index 188cbbb5..00000000 --- a/.template/addons/semaphore/.semaphore/promotion-production.yml.tt +++ /dev/null @@ -1,42 +0,0 @@ -version: v1.0 - -name: <%= APP_NAME_HUMANIZED %> Production -agent: - machine: - type: e1-standard-2 - os_image: ubuntu1804 - -global_job_config: - env_vars: - - name: HEROKU_APP - value: <%= APP_NAME %>-production - - name: DOCKER_IMAGE - value: <%= DOCKER_IMAGE %> - secrets: - - name: <%= APP_NAME %> - prologue: - commands: - - checkout - - echo "$DOCKER_REGISTRY_TOKEN" | docker login $DOCKER_REGISTRY_HOST --username=$DOCKER_REGISTRY_USERNAME --password-stdin - - export BRANCH_TAG=${SEMAPHORE_GIT_BRANCH/\//-} - -blocks: - - name: Build - task: - jobs: - - name: Build - commands: - - bin/docker-prepare - - docker compose build - - docker compose push web - - - name: Deploy - task: - prologue: - commands: - - heroku container:login - jobs: - - name: Heroku - commands: - - heroku container:push --arg DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST,DOCKER_IMAGE=$DOCKER_IMAGE,BRANCH_TAG=$BRANCH_TAG --recursive - - heroku container:release web worker diff --git a/.template/addons/semaphore/.semaphore/promotion-staging.yml.tt b/.template/addons/semaphore/.semaphore/promotion-staging.yml.tt deleted file mode 100644 index ee100af3..00000000 --- a/.template/addons/semaphore/.semaphore/promotion-staging.yml.tt +++ /dev/null @@ -1,42 +0,0 @@ -version: v1.0 - -name: <%= APP_NAME_HUMANIZED %> Staging -agent: - machine: - type: e1-standard-2 - os_image: ubuntu1804 - -global_job_config: - env_vars: - - name: HEROKU_APP - value: <%= APP_NAME %>-staging - - name: DOCKER_IMAGE - value: <%= DOCKER_IMAGE %> - secrets: - - name: <%= APP_NAME %> - prologue: - commands: - - checkout - - echo "$DOCKER_REGISTRY_TOKEN" | docker login $DOCKER_REGISTRY_HOST --username=$DOCKER_REGISTRY_USERNAME --password-stdin - - export BRANCH_TAG=${SEMAPHORE_GIT_BRANCH/\//-} - -blocks: - - name: Build - task: - jobs: - - name: Build - commands: - - bin/docker-prepare - - docker compose build - - docker compose push web - - - name: Deploy - task: - prologue: - commands: - - heroku container:login - jobs: - - name: Heroku - commands: - - heroku container:push --arg DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST,DOCKER_IMAGE=$DOCKER_IMAGE,BRANCH_TAG=$BRANCH_TAG --recursive - - heroku container:release web worker diff --git a/.template/addons/semaphore/.semaphore/semaphore.yml.tt b/.template/addons/semaphore/.semaphore/semaphore.yml.tt deleted file mode 100644 index caa42592..00000000 --- a/.template/addons/semaphore/.semaphore/semaphore.yml.tt +++ /dev/null @@ -1,70 +0,0 @@ -version: v1.0 - -name: <%= APP_NAME_HUMANIZED %> -agent: - machine: - type: e1-standard-2 - os_image: ubuntu1804 -auto_cancel: - running: - when: "branch != 'main'" - -global_job_config: - env_vars: - - name: COMPOSE_FILE - value: docker-compose.test.yml - secrets: - - name: <%= APP_NAME %> - prologue: - commands: - - checkout - - export BRANCH_TAG=${SEMAPHORE_GIT_BRANCH/\//-} - - echo "$DOCKER_REGISTRY_TOKEN" | docker login $DOCKER_REGISTRY_HOST --username=$DOCKER_REGISTRY_USERNAME --password-stdin - -blocks: - - name: Build - task: - jobs: - - name: Build - commands: - - >- - if ([ $SEMAPHORE_GIT_BRANCH != 'main' ] && [ $SEMAPHORE_GIT_BRANCH != 'development' ]); - then (echo "Pulling built image for the branch"; docker compose pull test || true); - else (echo "Skipping docker pull"); - fi || true - - bin/docker-prepare - - docker compose build - - docker compose push test - - - name: Tests - task: - prologue: - commands: - - docker compose pull - jobs: - - name: Linters - commands: - - docker compose run test yarn lint - - name: Nginx configuration validate - commands: - - docker compose run test nginx -c /etc/nginx/conf.d/default.conf -t - - name: Unit tests - commands: - - docker compose run test bundle exec rspec --exclude-pattern "spec/systems/**/*_spec.rb" --profile --format progress - - name: System tests - commands: - - docker compose run test bundle exec rspec spec/systems --profile --format progress - epilogue: - on_fail: - commands: - - artifact push job tmp/screenshots - -promotions: - - name: Staging - pipeline_file: promotion-staging.yml - auto_promote: - when: "branch = 'development' AND result = 'passed'" - - name: Production - pipeline_file: promotion-production.yml - auto_promote: - when: "branch = 'main' AND result = 'passed'" diff --git a/.template/addons/semaphore/template.rb b/.template/addons/semaphore/template.rb deleted file mode 100644 index 263e4e32..00000000 --- a/.template/addons/semaphore/template.rb +++ /dev/null @@ -1,5 +0,0 @@ -# frozen_string_literal: true - -use_source_path __dir__ - -directory '.semaphore' diff --git a/.tool-versions b/.tool-versions index df6fb92d..3403b199 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ nodejs >= 18 -ruby 3.2.2 +ruby 3.3.1 diff --git a/Gemfile.tt b/Gemfile.tt index 07c0a5c9..12ca9d68 100644 --- a/Gemfile.tt +++ b/Gemfile.tt @@ -2,7 +2,7 @@ source 'https://rubygems.org' ruby '<%= RUBY_VERSION %>' # Backend -gem 'rails', '7.1.2' # Latest stable +gem 'rails', '~> 7.1' # Latest stable gem 'pg' # Use Postgresql as database gem 'puma' # Use Puma as the app server gem 'mini_magick' # A ruby wrapper for ImageMagick or GraphicsMagick command line @@ -53,7 +53,7 @@ group :development, :test do # Code Analysis gem 'bullet' # help to kill N+1 queries and unused eager loading gem 'brakeman', require: false # A static analysis security vulnerability scanner for Ruby on Rails applications - gem 'parser', '3.2.2.3' # Use correct parser version to avoid parser warnings + gem 'parser', '~> 3.3' # Use correct parser version to avoid parser warnings gem 'rubocop', require: false # A Ruby static code analyzer and formatter, based on the community Ruby style guide. gem 'rubocop-rails', require: false # A RuboCop extension focused on enforcing Rails best practices and coding conventions. gem 'rubocop-rspec', require: false # Code style checking for RSpec files diff --git a/README.md b/README.md index ef8ec384..acc90cfc 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,9 @@ with building complex applications over the years. ### Requirements -- Install ruby and set your local ruby version to `3.2.2` -- Install rails `7.1.2` -- Install node `18.19.0` (For creating web application) +- Install ruby and set your local ruby version to `3.3.1` +- Install rails `7.1.3` +- Install node `22.1.0` (For creating web application) > 📝 If running on Apple M1, to build docker image, please make sure to set platform to AMD64 by `export DOCKER_DEFAULT_PLATFORM=linux/amd64` @@ -49,7 +49,6 @@ Available Addons: - `docker` - `nginx` - `phrase` -- `semaphore` - `bootstrap` - `slim` - `devise` diff --git a/template.rb b/template.rb index 0b6690c5..d7d75df3 100644 --- a/template.rb +++ b/template.rb @@ -9,9 +9,9 @@ APP_NAME_HUMANIZED = app_name.split(/[-_]/).map(&:capitalize).join(' ').gsub(/ Web$/, '') DOCKER_REGISTRY_HOST = 'docker.io' DOCKER_IMAGE = "nimblehq/#{CONTAINERIZED_APP_NAME}".freeze -RUBY_VERSION = '3.2.2' -POSTGRES_VERSION = '15.2' -REDIS_VERSION = '6.2.7' +RUBY_VERSION = '3.3.1' +POSTGRES_VERSION = '16.3' +REDIS_VERSION = '7.0.9' # Variants API_VARIANT = options[:api] || ENV['API'] == 'true' WEB_VARIANT = !API_VARIANT @@ -22,8 +22,8 @@ }.freeze if WEB_VARIANT - NODE_VERSION = '18.19.0' - NODE_SOURCE_VERSION = '18' # Used in Dockerfile https://github.com/nodesource/distributions + NODE_VERSION = '22.1.0' + NODE_SOURCE_VERSION = '22' # Used in Dockerfile https://github.com/nodesource/distributions end def apply_template!(template_root) @@ -95,7 +95,6 @@ def ask_for_all_variant_addons @install_github_action = yes?(install_addon_prompt('Github Action and Wiki')) @install_openapi = API_VARIANT || yes?(install_addon_prompt('OpenAPI')) @install_mock_server = @install_openapi && yes?(install_addon_prompt('Mock Server')) - @install_semaphore = yes?(install_addon_prompt('SemaphoreCI')) @install_nginx = yes?(install_addon_prompt('Nginx')) @install_phrase = yes?(install_addon_prompt('Phrase')) @install_crud = WEB_VARIANT && yes?(install_addon_prompt('Crud (includes Devise, Bootstrap and Slim)')) @@ -112,7 +111,6 @@ def ask_for_web_variant_addons def apply_optional_addons apply '.template/addons/github/template.rb' if @install_github_action apply '.template/addons/openapi/template.rb' if @install_openapi - apply '.template/addons/semaphore/template.rb' if @install_semaphore apply '.template/addons/nginx/template.rb' if @install_nginx apply '.template/addons/phrase/template.rb' if @install_phrase apply '.template/addons/devise/template.rb' if @install_devise