Skip to content

Commit

Permalink
Merge CI and Scalingo config tested on staging branch
Browse files Browse the repository at this point in the history
  • Loading branch information
goulvench authored Feb 12, 2025
2 parents 44c962c + de3675c commit 6582ff1
Show file tree
Hide file tree
Showing 15 changed files with 118 additions and 35 deletions.
2 changes: 2 additions & 0 deletions .buildpacks
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
https://github.com/Scalingo/apt-buildpack.git
https://github.com/Scalingo/ruby-buildpack.git
63 changes: 61 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
name: CI

on:
pull_request:
push:
branches: [ main ]
branches:
- '**' # This will match all branches
pull_request: # Added to also run on PRs

jobs:
scan_ruby:
name: Brakeman
runs-on: ubuntu-latest

steps:
Expand All @@ -23,6 +25,7 @@ jobs:
run: bin/brakeman --no-pager

scan_js:
name: JS audit
runs-on: ubuntu-latest

steps:
Expand All @@ -39,7 +42,9 @@ jobs:
run: bin/importmap audit

lint:
name: Rubocop
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -53,3 +58,57 @@ jobs:
- name: Lint code for consistent style
run: bin/rubocop -f github

test:
name: Rspec
if: ${{ !contains(github.event.head_commit.message, '[skip-ci]') }}
runs-on: ubuntu-latest

services:
postgres:
image: postgres:16
ports:
- "5432:5432"
env:
POSTGRES_DB: rails_test
POSTGRES_USER: rails
POSTGRES_PASSWORD: password

env:
RAILS_ENV: test
DATABASE_URL: "postgres://rails:password@localhost:5432/rails_test"
DISABLE_BOOTSNAP: "1"

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install libvips
run: sudo apt-get update && sudo apt-get install -y libvips

- name: Install Ruby and gems
uses: ruby/setup-ruby@v1
with:
bundler-cache: true

- name: Set up database schema
run: bin/rails db:schema:load

- name: Run tests
run: bundle exec rspec

deploy:
name: Déploiement sur Scalingo
runs-on: ubuntu-latest

needs: [test, lint]

if: ${{ (github.ref == 'refs/heads/staging') && !contains(github.event.head_commit.message, '[skip-deploy]') }}

steps:
- name: Install Scalingo CLI
run: curl -O https://cli-dl.scalingo.com/install && bash install

- run: scalingo login --api-token ${{ secrets.SCALINGO_TOKEN }}
- name: Déploiement sur staging
if: ${{ github.ref == 'refs/heads/staging' }}
run: scalingo --app acces-cible-staging integration-link-manual-deploy staging
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ AllCops:
# Use `[a, [b, c]]` not `[ a, [ b, c ] ]`
Layout/SpaceInsideArrayLiteralBrackets:
EnforcedStyle: "no_space"
Exclude:
- "db/*schema.rb"

# Ignore block length in config files
Metrics/BlockLength:
Exclude:
- "config/environments/*.rb"
- "config/routes.rb"
- "db/*.rb"

# Allow numbers in variable names in specs
Naming/VariableNumber:
Expand Down
1 change: 1 addition & 0 deletions Aptfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
libvips-dev
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
source "https://rubygems.org"

ruby file: ".ruby-version"

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 8.0.1"
gem "rails-i18n"
Expand Down
12 changes: 12 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ GEM
railties (>= 5.0.0)
faker (3.5.1)
i18n (>= 1.8.11, < 2)
ffi (1.17.1)
ffi (1.17.1-aarch64-linux-gnu)
ffi (1.17.1-aarch64-linux-musl)
ffi (1.17.1-arm-linux-gnu)
Expand Down Expand Up @@ -268,6 +269,7 @@ GEM
matrix (0.4.2)
method_source (1.1.0)
mini_mime (1.1.5)
mini_portile2 (2.8.8)
minitest (5.25.4)
msgpack (1.8.0)
multi_test (1.1.0)
Expand All @@ -282,6 +284,9 @@ GEM
net-smtp (0.5.1)
net-protocol
nio4r (2.7.4)
nokogiri (1.18.2)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nokogiri (1.18.2-aarch64-linux-gnu)
racc (~> 1.4)
nokogiri (1.18.2-aarch64-linux-musl)
Expand Down Expand Up @@ -441,6 +446,9 @@ GEM
rubocop-rspec (~> 3, >= 3.0.1)
ruby-progressbar (1.13.0)
rubyzip (2.4.1)
sass-embedded (1.83.4)
google-protobuf (~> 4.29)
rake (>= 13)
sass-embedded (1.83.4-aarch64-linux-gnu)
google-protobuf (~> 4.29)
sass-embedded (1.83.4-aarch64-linux-musl)
Expand Down Expand Up @@ -530,6 +538,7 @@ PLATFORMS
arm-linux-musl
arm-linux-musleabihf
arm64-darwin
ruby
x86_64-darwin
x86_64-linux
x86_64-linux-gnu
Expand Down Expand Up @@ -582,5 +591,8 @@ DEPENDENCIES
view_component
whiny_validation

RUBY VERSION
ruby 3.4.1p0

BUNDLED WITH
2.6.3
3 changes: 3 additions & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
web: bundle exec rails server
worker: bin/jobs
postdeploy: bin/rails db:prepare db:seed
25 changes: 1 addition & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1 @@
# README

This README would normally document whatever steps are necessary to get the
application up and running.

Things you may want to cover:

* Ruby version

* System dependencies

* Configuration

* Database creation

* Database initialization

* How to run the test suite

* Services (job queues, cache servers, search engines, etc.)

* Deployment instructions

* ...
# Documentation
2 changes: 1 addition & 1 deletion config/credentials.yml.enc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CjdZ/dUOzIyFd55zUUudxFCmBCNH6DQ5GnniHIG9VxSgELSYkIvouxKwJPn9QW8IO1yhR1ellnLI4jA0zVV0wQXNQM36IA0Ho96BOARIiUiU6jPiIg2+0e9NhHFSEj+UYth4mk52hHLNCUXKm2xTG3cLShuw08b3WptZwjvyFsZpGGwENmm9IBLYVs3oNNhW3IGcddVoqGdYfK5vgGBJL3aYAUr7XS8Pl6Xuy1JHTIzesoO4LeQi5TXI8UImYJqZYdMIh6zcWvT7ZVUEVeMRd2DO7oW6xPxLn3CeCh2cUJMXnbKG9iiuImc1wAdc9nHwWPNnOZ6iiN1d/GdXm4MxbkgsYWGK4+eLnbHIpN64q5r8NJ2KvFnk3C15PInTy6//+h8T3T4/NGGhinzblOteIqCYz+zv5rc1hsGe+IT5bjTb0tZVHQJ3j3irStnC323+VexUqPY3Ofyd/EIWMsdDvJiclNnuU3NfHWBeypnvmQTD0pU2nIXesBYq--BundNfKHqoT1XZYd--Bw7c+acNSybqQ+mIDt93ZA==
E4fSdPeR7/QeNQp9UHRSuXSfsRJoBkD/HPkRKaQE0o5ttIxLscH62F2Uz/jLprVEzwpCmZ+hkDGofwrTgM66Ki4DXZwNlsjLAjPmm2NN+hHarj1wO6pV38sRiIcXRUQLkS9oAF4RoZ/cNmfQjbGoZODhIZkSmvysfqg80tMo55J75t+7yKEWuI4QGVePz3hb3cvq+XNGviImWNwlB678ilWKQObFbgDq5GXREntdkPSWyTaGvpkZcFCiCuEHLzqu+q9iGBlxYOI6fQtp5ujuo8PD/drJKh1UGSqHbXjEmMLqC78tILQI0XoRivTfsj7PycYEhqEq1tnk9l+DjHO26P+Iad8HTrufVNw1TzaHKrq6eioDWoH6aO1F3mrZTwyEtcSmR9JFqvibl3ylt/4TGmlyZQUu3ji2yE7XU6XV7GqAyXXrMevDcB/oWADQ0YlNugdkD32POdYjKDOL5AoUUhvIJQZo9QHEhK4Y9ekVQnAI4dBTsCBMy4H/--2HrBHxj7jELkOEHb--9G3SpNni7coXxugPIb8aEg==
3 changes: 1 addition & 2 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ production:
primary: &primary_production
<<: *default
database: acces_cible_production
username: acces_cible
password: <%= ENV["ACCES_CIBLE_DATABASE_PASSWORD"] %>
url: <%= ENV["DATABASE_URL"] %>
cache:
<<: *primary_production
database: acces_cible_production_cache
Expand Down
14 changes: 11 additions & 3 deletions config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,19 @@
# Any libraries that use a connection pool or another resource pool should
# be configured to provide at least as many connections as the number of
# threads. This includes Active Record's `pool` parameter in `database.yml`.
threads_count = ENV.fetch("RAILS_MAX_THREADS", 3)
workers Integer(ENV["WEB_CONCURRENCY"] || 2)
threads_count = Integer(ENV["MAX_THREADS"] || 5)
threads threads_count, threads_count

# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
port ENV.fetch("PORT", 3000)
preload_app!

port ENV["PORT"] || 3000
environment ENV["RACK_ENV"] || "development"

on_worker_boot do
# Worker specific setup for Rails 4.1+
ActiveRecord::Base.establish_connection
end

# Allow puma to be restarted by `bin/rails restart` command.
plugin :tmp_restart
Expand Down
2 changes: 1 addition & 1 deletion db/cable_schema.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ActiveRecord::Schema[7.1].define(version: 1) do
ActiveRecord::Schema[8.0].define(version: 1) do
create_table "solid_cable_messages", force: :cascade do |t|
t.binary "channel", limit: 1024, null: false
t.binary "payload", limit: 536870912, null: false
Expand Down
2 changes: 1 addition & 1 deletion db/cache_schema.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

ActiveRecord::Schema[7.2].define(version: 1) do
ActiveRecord::Schema[8.0].define(version: 1) do
create_table "solid_cache_entries", force: :cascade do |t|
t.binary "key", limit: 1024, null: false
t.binary "value", limit: 536870912, null: false
Expand Down
2 changes: 1 addition & 1 deletion db/queue_schema.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ActiveRecord::Schema[7.1].define(version: 1) do
ActiveRecord::Schema[8.0].define(version: 1) do
create_table "solid_queue_blocked_executions", force: :cascade do |t|
t.bigint "job_id", null: false
t.string "queue_name", null: false
Expand Down
17 changes: 17 additions & 0 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6582ff1

Please sign in to comment.