Restore local CI, sensible setup for open source users

This commit is contained in:
Jorge Manrubia
2025-11-27 16:14:57 +01:00
parent cebd5d35f6
commit f03fbba5ac
4 changed files with 47 additions and 12 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/basecamp/fizzy-saas
revision: f251028405bd0ba586fe836d1a8c56428b8abff0
revision: 720bedaf37faf8dff18c9586e1fa7031bad1d2a9
specs:
fizzy-saas (0.1.0)
queenbee
+30
View File
@@ -82,8 +82,25 @@ step "Installing RubyGems" bundle install
if [ -n "$SAAS" ]; then
saas_setup=$(bundle show fizzy-saas)/bin/setup
source "$saas_setup"
else
if ! nc -z localhost 3306 2>/dev/null; then
if docker ps -aq -f name=fizzy-mysql | grep -q .; then
step "Starting MySQL" docker start fizzy-mysql
else
step "Setting up MySQL" bash -c '
docker pull mysql:8.4
docker run -d \
--name fizzy-mysql \
-e MYSQL_ALLOW_EMPTY_PASSWORD=yes \
-p 3306:3306 \
mysql:8.4
echo "MySQL is starting… (it may take a few seconds)"
'
fi
fi
fi
if [ -n "$SAAS" ]; then
if [[ $* == *--reset* ]]; then
step "Resetting the database" rails db:reset
else
@@ -93,6 +110,19 @@ else
step "Seeding the database" rails db:seed
fi
fi
else
for adapter in sqlite mysql; do
if [[ $* == *--reset* ]]; then
step "Resetting the database ($adapter)" env DATABASE_ADAPTER=$adapter rails db:reset
else
step "Preparing the database ($adapter)" env DATABASE_ADAPTER=$adapter rails db:prepare
if needs_seeding; then
step "Seeding the database ($adapter)" env DATABASE_ADAPTER=$adapter rails db:seed
fi
fi
done
fi
step "Cleaning up logs and tempfiles" rails log:clear tmp:clear
+7 -2
View File
@@ -11,8 +11,13 @@ CI.run do
step "Security: Importmap audit", "bin/importmap audit"
step "Security: Brakeman audit", "bin/brakeman --quiet --no-pager --exit-on-warn --exit-on-error"
step "Tests: Open source", "bin/rails test"
step "Tests: System", "bin/rails test:system"
if Fizzy.saas?
step "Tests: SaaS", "SAAS=true BUNDLE_GEMFILE=Gemfile.saas bin/rails test:all"
else
step "Tests: MySQL", "SAAS=false BUNDLE_GEMFILE=Gemfile DATABASE_ADAPTER=mysql bin/rails test:all"
step "Tests: SQLite", "SAAS=false BUNDLE_GEMFILE=Gemfile DATABASE_ADAPTER=sqlite bin/rails test:all"
end
if success?
step "Signoff: All systems go. Ready for merge and deploy.", "gh signoff"
+1 -1
View File
@@ -2,7 +2,7 @@ module Fizzy
class << self
def saas?
return @saas if defined?(@saas)
@saas = !!(ENV["SAAS"] || File.exist?(File.expand_path("../tmp/saas.txt", __dir__)))
@saas = !!(((ENV["SAAS"] || File.exist?(File.expand_path("../tmp/saas.txt", __dir__))) && ENV["SAAS"] != "false"))
end
def db_adapter