Skip to content

Commit 35bf35b

Browse files
committed
Initial github action setup
1 parent 6e42a23 commit 35bf35b

File tree

2 files changed

+102
-2
lines changed

2 files changed

+102
-2
lines changed

.github/workflows/ci.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
security:
9+
name: Security
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: ruby/setup-ruby@v1
16+
env:
17+
BUNDLE_GITHUB__COM: "x-access-token:${{ secrets.GH_TOKEN }}"
18+
BUNDLE_GEMFILE: Gemfile
19+
with:
20+
ruby-version: .ruby-version
21+
bundler-cache: true
22+
23+
- name: Gem audit
24+
run: bin/bundler-audit check --update
25+
26+
- name: Importmap audit
27+
run: bin/importmap audit
28+
29+
- name: Brakeman audit
30+
run: bin/brakeman --quiet --no-pager --exit-on-warn --exit-on-error
31+
32+
33+
lint:
34+
name: Lint
35+
runs-on: ubuntu-latest
36+
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- uses: ruby/setup-ruby@v1
41+
env:
42+
BUNDLE_GITHUB__COM: "x-access-token:${{ secrets.GH_TOKEN }}"
43+
BUNDLE_GEMFILE: Gemfile
44+
with:
45+
ruby-version: .ruby-version
46+
bundler-cache: true
47+
48+
- name: Lint code for consistent style
49+
run: bin/rubocop
50+
51+
52+
test:
53+
name: Tests (${{ matrix.mode }})
54+
runs-on: ubuntu-latest
55+
56+
strategy:
57+
matrix:
58+
mode: [SQLite, MySQL, SaaS]
59+
60+
services:
61+
mysql:
62+
image: ${{ (matrix.mode == 'MySQL' || matrix.mode == 'SaaS') && 'mysql:8.0' || '' }}
63+
env:
64+
MYSQL_ALLOW_EMPTY_PASSWORD: yes
65+
MYSQL_DATABASE: fizzy_test
66+
ports:
67+
- 3306:3306
68+
options: >-
69+
--health-cmd="mysqladmin ping"
70+
--health-interval=10s
71+
--health-timeout=5s
72+
--health-retries=3
73+
74+
env:
75+
RAILS_ENV: test
76+
DATABASE_ADAPTER: ${{ matrix.mode == 'SQLite' && 'sqlite' || 'mysql' }}
77+
${{ matrix.mode == 'SaaS' && 'SAAS' || 'SAAS_DISABLED' }}: ${{ matrix.mode == 'SaaS' && '1' || '' }}
78+
BUNDLE_GEMFILE: ${{ matrix.mode == 'SaaS' && 'Gemfile.saas' || 'Gemfile' }}
79+
MYSQL_HOST: 127.0.0.1
80+
MYSQL_PORT: 3306
81+
MYSQL_USER: root
82+
83+
steps:
84+
- name: Install system packages
85+
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y libsqlite3-0 libvips curl ffmpeg
86+
87+
- uses: actions/checkout@v4
88+
89+
- uses: ruby/setup-ruby@v1
90+
env:
91+
BUNDLE_GITHUB__COM: "x-access-token:${{ secrets.GH_TOKEN }}"
92+
with:
93+
ruby-version: .ruby-version
94+
bundler-cache: true
95+
96+
- name: Run tests
97+
run: bin/rails db:setup test
98+
99+
- name: Run system tests
100+
run: bin/rails test:system

lib/tasks/saas.rake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ namespace :saas do
22
SAAS_FILE_PATH = "tmp/saas.txt"
33

44
desc "Enable SaaS mode"
5-
task :enable => :environment do
5+
task enable: :environment do
66
file_path = Rails.root.join(SAAS_FILE_PATH)
77
FileUtils.mkdir_p(File.dirname(file_path))
88
FileUtils.touch(file_path)
99
puts "SaaS mode enabled (#{file_path} created)"
1010
end
1111

1212
desc "Disable SaaS mode"
13-
task :disable => :environment do
13+
task disable: :environment do
1414
file_path = Rails.root.join(SAAS_FILE_PATH)
1515
FileUtils.rm_f(file_path)
1616
puts "SaaS mode disabled (#{file_path} removed)"

0 commit comments

Comments
 (0)