|
| 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 |
0 commit comments