|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: [ main ] |
| 7 | + |
| 8 | +jobs: |
| 9 | + scan_ruby: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + |
| 12 | + steps: |
| 13 | + - name: Checkout code |
| 14 | + uses: actions/checkout@v4 |
| 15 | + |
| 16 | + - name: Set up Ruby |
| 17 | + uses: ruby/setup-ruby@v1 |
| 18 | + with: |
| 19 | + ruby-version: .ruby-version |
| 20 | + bundler-cache: true |
| 21 | + |
| 22 | + - name: Scan for common Rails security vulnerabilities using static analysis |
| 23 | + run: bin/brakeman --no-pager |
| 24 | + |
| 25 | + scan_js: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + |
| 28 | + steps: |
| 29 | + - name: Checkout code |
| 30 | + uses: actions/checkout@v4 |
| 31 | + |
| 32 | + - name: Set up Ruby |
| 33 | + uses: ruby/setup-ruby@v1 |
| 34 | + with: |
| 35 | + ruby-version: .ruby-version |
| 36 | + bundler-cache: true |
| 37 | + |
| 38 | + - name: Scan for security vulnerabilities in JavaScript dependencies |
| 39 | + run: bin/importmap audit |
| 40 | + |
| 41 | + lint: |
| 42 | + runs-on: ubuntu-latest |
| 43 | + steps: |
| 44 | + - name: Checkout code |
| 45 | + uses: actions/checkout@v4 |
| 46 | + |
| 47 | + - name: Set up Ruby |
| 48 | + uses: ruby/setup-ruby@v1 |
| 49 | + with: |
| 50 | + ruby-version: .ruby-version |
| 51 | + bundler-cache: true |
| 52 | + |
| 53 | + - name: Lint code for consistent style |
| 54 | + run: bin/rubocop -f github |
| 55 | + |
| 56 | + test: |
| 57 | + runs-on: ubuntu-latest |
| 58 | + |
| 59 | + services: |
| 60 | + postgres: |
| 61 | + image: postgres |
| 62 | + env: |
| 63 | + POSTGRES_USER: postgres |
| 64 | + POSTGRES_PASSWORD: postgres |
| 65 | + ports: |
| 66 | + - 5432:5432 |
| 67 | + options: --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3 |
| 68 | + |
| 69 | + # redis: |
| 70 | + # image: redis |
| 71 | + # ports: |
| 72 | + # - 6379:6379 |
| 73 | + # options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5 |
| 74 | + |
| 75 | + steps: |
| 76 | + - name: Install packages |
| 77 | + run: sudo apt-get update && sudo apt-get install --no-install-recommends -y build-essential git libpq-dev libyaml-dev pkg-config google-chrome-stable |
| 78 | + |
| 79 | + - name: Checkout code |
| 80 | + uses: actions/checkout@v4 |
| 81 | + |
| 82 | + - name: Set up Ruby |
| 83 | + uses: ruby/setup-ruby@v1 |
| 84 | + with: |
| 85 | + ruby-version: .ruby-version |
| 86 | + bundler-cache: true |
| 87 | + |
| 88 | + - name: Run tests |
| 89 | + env: |
| 90 | + RAILS_ENV: test |
| 91 | + DATABASE_URL: postgres://postgres:postgres@localhost:5432 |
| 92 | + # REDIS_URL: redis://localhost:6379/0 |
| 93 | + run: bin/rails db:test:prepare test test:system |
| 94 | + |
| 95 | + - name: Keep screenshots from failed system tests |
| 96 | + uses: actions/upload-artifact@v4 |
| 97 | + if: failure() |
| 98 | + with: |
| 99 | + name: screenshots |
| 100 | + path: ${{ github.workspace }}/tmp/screenshots |
| 101 | + if-no-files-found: ignore |
0 commit comments