|
1 | | -# This workflow uses actions that are not certified by GitHub. They are |
2 | | -# provided by a third-party and are governed by separate terms of service, |
3 | | -# privacy policy, and support documentation. |
4 | | -# |
5 | | -# This workflow will install a prebuilt Ruby version, install dependencies, and |
6 | | -# run tests and linters. |
7 | 1 | name: "Ruby on Rails CI" |
| 2 | + |
8 | 3 | on: |
9 | 4 | push: |
10 | 5 | branches: [ "main", "dev" ] |
11 | 6 | pull_request: |
12 | 7 | branches: [ "main", "dev" ] |
| 8 | + |
13 | 9 | jobs: |
14 | 10 | rspec: |
15 | 11 | runs-on: ubuntu-latest |
| 12 | + |
| 13 | + # ── Handle failures per-matrix entry ──────────────────────────────────────── |
| 14 | + continue-on-error: ${{ matrix.allowed_failure }} |
| 15 | + |
16 | 16 | strategy: |
| 17 | + fail-fast: false # don’t cancel other matrix jobs early |
17 | 18 | matrix: |
18 | | - ruby: ['3.4.4'] |
19 | | - rails: ['7.1.5.1', '7.2', '8.0'] |
20 | | - fail-fast: false |
21 | | - continue-on-error: ${{ matrix.rails != '7.1.5.1' }} |
| 19 | + include: |
| 20 | + # ✅ REQUIRED: must pass |
| 21 | + - ruby: '3.4.4' |
| 22 | + rails: '7.1.5.1' |
| 23 | + allowed_failure: false |
| 24 | + |
| 25 | + # ⚠️ ALLOWED TO FAIL (prep work for upgrades) |
| 26 | + - ruby: '3.4.4' |
| 27 | + rails: '7.2' |
| 28 | + allowed_failure: true |
| 29 | + |
| 30 | + - ruby: '3.4.4' |
| 31 | + rails: '8.0' |
| 32 | + allowed_failure: true |
| 33 | + |
22 | 34 | env: |
23 | 35 | RAILS_ENV: test |
24 | 36 | DATABASE_URL: "postgis://rails:password@localhost:5432/rails_test" |
25 | | - ES_HOST: "http://localhost" |
| 37 | + ES_HOST: "http://localhost" |
26 | 38 | RAILS_VERSION: ${{ matrix.rails }} |
27 | 39 | environment: test |
| 40 | + |
28 | 41 | services: |
29 | 42 | postgres: |
30 | 43 | image: postgis/postgis:latest |
31 | | - ports: |
32 | | - - "5432:5432" |
| 44 | + ports: [ "5432:5432" ] |
33 | 45 | env: |
34 | 46 | POSTGRES_DB: rails_test |
35 | 47 | POSTGRES_USER: rails |
36 | 48 | POSTGRES_PASSWORD: password |
37 | 49 | elasticsearch: |
38 | 50 | image: elasticsearch:7.17.23 |
39 | | - ports: |
40 | | - - "9200:9200" |
| 51 | + ports: [ "9200:9200" ] |
41 | 52 | env: |
42 | | - "node.name": elasticsearch |
43 | | - "cluster.name": better-together-es |
44 | | - "discovery.seed_hosts": elasticsearch |
45 | | - "discovery.type": single-node |
46 | | - "bootstrap.memory_lock": true |
47 | | - "ES_JAVA_OPTS": "-Xms512m -Xmx512m" |
| 53 | + node.name: elasticsearch |
| 54 | + cluster.name: better-together-es |
| 55 | + discovery.seed_hosts: elasticsearch |
| 56 | + discovery.type: single-node |
| 57 | + bootstrap.memory_lock: "true" |
| 58 | + ES_JAVA_OPTS: "-Xms512m -Xmx512m" |
| 59 | + |
48 | 60 | steps: |
49 | 61 | - name: Checkout code |
50 | 62 | uses: actions/checkout@v3 |
51 | | - # Add or replace dependency steps here |
52 | | - - name: Install Ruby and gems |
| 63 | + |
| 64 | + - name: Install Ruby/toolchain |
53 | 65 | uses: ruby/setup-ruby@v1 |
54 | 66 | with: |
55 | 67 | ruby-version: ${{ matrix.ruby }} |
56 | 68 | bundler-cache: ${{ matrix.rails == '7.1.5.1' }} |
57 | | - - name: Update Rails |
58 | | - if: matrix.rails != '7.1.5.1' |
| 69 | + |
| 70 | + - name: Update Rails for upgrade tracks |
| 71 | + if: matrix.allowed_failure |
59 | 72 | run: | |
60 | 73 | bundle config set deployment false |
61 | 74 | bundle update rails --conservative |
62 | 75 | bundle install |
63 | | - # Add or replace database setup steps here |
64 | | - - name: Set up database schema |
65 | | - run: rm -f spec/dummy/tmp/pids/server.pid && cd ./spec/dummy && bundle exec rails db:schema:load |
66 | | - # Add or replace test runners here |
67 | | - - name: Run tests |
| 76 | +
|
| 77 | + - name: Prepare DB schema |
| 78 | + run: rm -f spec/dummy/tmp/pids/server.pid && cd spec/dummy && bundle exec rails db:schema:load |
| 79 | + |
| 80 | + - name: Run RSpec |
68 | 81 | env: |
69 | 82 | RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} |
70 | 83 | run: rm -f spec/dummy/tmp/pids/server.pid && bundle exec rspec |
71 | 84 |
|
| 85 | + # ── Style & Security jobs stay unchanged ───────────────────────────────────── |
72 | 86 | rubocop: |
73 | 87 | runs-on: ubuntu-latest |
74 | 88 | steps: |
75 | | - - name: Checkout code |
76 | | - uses: actions/checkout@v3 |
77 | | - - name: Install Ruby and gems |
78 | | - uses: ruby/setup-ruby@v1 |
| 89 | + - uses: actions/checkout@v3 |
| 90 | + - uses: ruby/setup-ruby@v1 |
79 | 91 | with: |
80 | 92 | bundler-cache: true |
81 | | - - name: Lint Ruby files with Rubocop |
82 | | - run: bundle exec rubocop --parallel |
| 93 | + - run: bundle exec rubocop --parallel |
83 | 94 |
|
84 | 95 | security: |
85 | 96 | runs-on: ubuntu-latest |
86 | 97 | steps: |
87 | | - - name: Checkout code |
88 | | - uses: actions/checkout@v3 |
89 | | - - name: Install Ruby and gems |
90 | | - uses: ruby/setup-ruby@v1 |
| 98 | + - uses: actions/checkout@v3 |
| 99 | + - uses: ruby/setup-ruby@v1 |
91 | 100 | with: |
92 | 101 | bundler-cache: true |
93 | | - - name: Generate binstubs |
94 | | - run: bundle binstubs bundler-audit --force |
95 | | - - name: Security audit dependencies |
96 | | - run: bundle exec bundler-audit --update |
97 | | - - name: Security audit application code |
98 | | - run: bundle exec brakeman -q -w2 |
| 102 | + - run: bundle binstubs bundler-audit --force |
| 103 | + - run: bundle exec bundler-audit --update |
| 104 | + - run: bundle exec brakeman -q -w2 |
0 commit comments