|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: [main] |
| 7 | + |
| 8 | +jobs: |
| 9 | +<%- if Bundler.rubygems.find_name("bundler-audit").any? -%> |
| 10 | + scan_ruby: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Checkout code |
| 15 | + uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Set up Ruby |
| 18 | + uses: ruby/setup-ruby@v1 |
| 19 | + with: |
| 20 | + ruby-version: .ruby-version |
| 21 | + bundler-cache: true |
| 22 | + |
| 23 | + - name: Scan for security vulnerabilities in Ruby dependencies |
| 24 | + run: | |
| 25 | + bin/rails bundle:audit:update |
| 26 | + bin/rails bundle:audit |
| 27 | +<% end -%> |
| 28 | + |
| 29 | +<%- if File.exist?("bin/importmap") && File.exist?("package.json") -%> |
| 30 | + scan_js: |
| 31 | + runs-on: ubuntu-latest |
| 32 | + |
| 33 | + steps: |
| 34 | + - name: Checkout code |
| 35 | + uses: actions/checkout@v4 |
| 36 | + |
| 37 | + - name: Set up Ruby |
| 38 | + uses: ruby/setup-ruby@v1 |
| 39 | + with: |
| 40 | + ruby-version: .ruby-version |
| 41 | + bundler-cache: true |
| 42 | + |
| 43 | + - name: Setup Node |
| 44 | + uses: actions/setup-node@v4 |
| 45 | + with: |
| 46 | + node-version-file: .node-version |
| 47 | + |
| 48 | + - name: Install modules |
| 49 | + run: yarn install |
| 50 | + |
| 51 | + - name: Scan for security vulnerabilities in JavaScript dependencies |
| 52 | + run: | |
| 53 | + bin/importmap audit |
| 54 | + yarn audit |
| 55 | +<% end -%> |
| 56 | + |
| 57 | +<%- if Bundler.rubygems.find_name("standard").any? && File.exist?(".prettierrc") -%> |
| 58 | + lint: |
| 59 | + runs-on: ubuntu-latest |
| 60 | + steps: |
| 61 | + - name: Checkout code |
| 62 | + uses: actions/checkout@v4 |
| 63 | + |
| 64 | + - name: Set up Ruby |
| 65 | + uses: ruby/setup-ruby@v1 |
| 66 | + with: |
| 67 | + ruby-version: .ruby-version |
| 68 | + bundler-cache: true |
| 69 | + |
| 70 | + - name: Setup Node |
| 71 | + uses: actions/setup-node@v4 |
| 72 | + with: |
| 73 | + node-version-file: .node-version |
| 74 | + |
| 75 | + - name: Install modules |
| 76 | + run: yarn install |
| 77 | + |
| 78 | + - name: Lint Ruby code for consistent style |
| 79 | + run: bin/rails standard |
| 80 | + |
| 81 | + - name: Lint front-end code for consistent style |
| 82 | + run: yarn lint |
| 83 | +<% end -%> |
| 84 | + |
| 85 | + test: |
| 86 | + runs-on: ubuntu-latest |
| 87 | + |
| 88 | + services: |
| 89 | + postgres: |
| 90 | + image: postgres |
| 91 | + env: |
| 92 | + POSTGRES_USER: postgres |
| 93 | + POSTGRES_PASSWORD: postgres |
| 94 | + ports: |
| 95 | + - 5432:5432 |
| 96 | + options: --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3 |
| 97 | + |
| 98 | + # redis: |
| 99 | + # image: redis |
| 100 | + # ports: |
| 101 | + # - 6379:6379 |
| 102 | + # options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5 |
| 103 | + |
| 104 | + steps: |
| 105 | + - name: Install packages |
| 106 | + run: sudo apt-get update && sudo apt-get install --no-install-recommends -y google-chrome-stable curl libjemalloc2 libvips postgresql-client libpq-dev |
| 107 | + |
| 108 | + - name: Checkout code |
| 109 | + uses: actions/checkout@v4 |
| 110 | + |
| 111 | + - name: Set up Ruby |
| 112 | + uses: ruby/setup-ruby@v1 |
| 113 | + with: |
| 114 | + ruby-version: .ruby-version |
| 115 | + bundler-cache: true |
| 116 | + |
| 117 | + - name: Setup Node |
| 118 | + uses: actions/setup-node@v4 |
| 119 | + with: |
| 120 | + node-version-file: .node-version |
| 121 | + |
| 122 | + - name: Install modules |
| 123 | + run: yarn install |
| 124 | + |
| 125 | + - name: Run tests |
| 126 | + env: |
| 127 | + RAILS_ENV: test |
| 128 | + DATABASE_URL: postgres://postgres:postgres@localhost:5432 |
| 129 | + # REDIS_URL: redis://localhost:6379/0 |
| 130 | + <%- if File.exist? "spec" -%> |
| 131 | + run: bin/rails db:setup spec |
| 132 | + <%- else -%> |
| 133 | + run: bin/rails db:setup test test:system |
| 134 | + <%- end -%> |
| 135 | + |
| 136 | + - name: Keep screenshots from failed system tests |
| 137 | + uses: actions/upload-artifact@v4 |
| 138 | + if: failure() |
| 139 | + with: |
| 140 | + name: screenshots |
| 141 | + <%- if File.exist? "spec" -%> |
| 142 | + path: ${{ github.workspace }}/tmp/capybara |
| 143 | + <%- else -%> |
| 144 | + path: ${{ github.workspace }}/tmp/screenshots |
| 145 | + <%- end -%> |
| 146 | + if-no-files-found: ignore |
0 commit comments