Restore local CI, sensible setup for open source users
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
GIT
|
GIT
|
||||||
remote: https://github.com/basecamp/fizzy-saas
|
remote: https://github.com/basecamp/fizzy-saas
|
||||||
revision: f251028405bd0ba586fe836d1a8c56428b8abff0
|
revision: 720bedaf37faf8dff18c9586e1fa7031bad1d2a9
|
||||||
specs:
|
specs:
|
||||||
fizzy-saas (0.1.0)
|
fizzy-saas (0.1.0)
|
||||||
queenbee
|
queenbee
|
||||||
|
|||||||
@@ -82,16 +82,46 @@ step "Installing RubyGems" bundle install
|
|||||||
if [ -n "$SAAS" ]; then
|
if [ -n "$SAAS" ]; then
|
||||||
saas_setup=$(bundle show fizzy-saas)/bin/setup
|
saas_setup=$(bundle show fizzy-saas)/bin/setup
|
||||||
source "$saas_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
|
fi
|
||||||
|
|
||||||
if [[ $* == *--reset* ]]; then
|
if [ -n "$SAAS" ]; then
|
||||||
|
if [[ $* == *--reset* ]]; then
|
||||||
step "Resetting the database" rails db:reset
|
step "Resetting the database" rails db:reset
|
||||||
else
|
else
|
||||||
step "Preparing the database" rails db:prepare
|
step "Preparing the database" rails db:prepare
|
||||||
|
|
||||||
if needs_seeding; then
|
if needs_seeding; then
|
||||||
step "Seeding the database" rails db:seed
|
step "Seeding the database" rails db:seed
|
||||||
fi
|
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
|
fi
|
||||||
|
|
||||||
step "Cleaning up logs and tempfiles" rails log:clear tmp:clear
|
step "Cleaning up logs and tempfiles" rails log:clear tmp:clear
|
||||||
|
|||||||
+7
-2
@@ -11,8 +11,13 @@ CI.run do
|
|||||||
step "Security: Importmap audit", "bin/importmap audit"
|
step "Security: Importmap audit", "bin/importmap audit"
|
||||||
step "Security: Brakeman audit", "bin/brakeman --quiet --no-pager --exit-on-warn --exit-on-error"
|
step "Security: Brakeman audit", "bin/brakeman --quiet --no-pager --exit-on-warn --exit-on-error"
|
||||||
|
|
||||||
step "Tests: Open source", "bin/rails test"
|
if Fizzy.saas?
|
||||||
step "Tests: System", "bin/rails test:system"
|
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?
|
if success?
|
||||||
step "Signoff: All systems go. Ready for merge and deploy.", "gh signoff"
|
step "Signoff: All systems go. Ready for merge and deploy.", "gh signoff"
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@ module Fizzy
|
|||||||
class << self
|
class << self
|
||||||
def saas?
|
def saas?
|
||||||
return @saas if defined?(@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
|
end
|
||||||
|
|
||||||
def db_adapter
|
def db_adapter
|
||||||
|
|||||||
Reference in New Issue
Block a user