|
1 | | -name: CI |
| 1 | +name: Ruby |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
|
8 | 8 | pull_request: |
9 | 9 |
|
10 | 10 | jobs: |
11 | | - lint: |
| 11 | + build: |
12 | 12 | runs-on: ubuntu-latest |
| 13 | + name: Ruby ${{ matrix.ruby }} |
| 14 | + strategy: |
| 15 | + matrix: |
| 16 | + ruby: |
| 17 | + - '3.4.7' |
13 | 18 |
|
14 | 19 | steps: |
15 | | - - uses: actions/checkout@v4 |
16 | | - - name: Set up Ruby |
17 | | - uses: ruby/setup-ruby@v1 |
18 | | - with: |
19 | | - bundler-cache: true |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + persist-credentials: false |
| 23 | + - name: Set up Ruby |
| 24 | + uses: ruby/setup-ruby@v1 |
| 25 | + with: |
| 26 | + ruby-version: ${{ matrix.ruby }} |
| 27 | + bundler-cache: true |
| 28 | + - name: Run the default task |
| 29 | + run: bundle exec rake |
20 | 30 |
|
21 | | - - name: Lint |
22 | | - run: bin/rails standard |
23 | | - |
24 | | - test: |
| 31 | + test-template: |
25 | 32 | runs-on: ubuntu-latest |
26 | 33 |
|
27 | | - steps: |
28 | | - - uses: actions/checkout@v4 |
29 | | - - name: Set up Ruby |
30 | | - uses: ruby/setup-ruby@v1 |
31 | | - with: |
32 | | - bundler-cache: true |
| 34 | + services: |
| 35 | + postgres: |
| 36 | + image: postgres |
| 37 | + env: |
| 38 | + POSTGRES_USER: postgres |
| 39 | + POSTGRES_PASSWORD: postgres |
| 40 | + ports: |
| 41 | + - 5432:5432 |
| 42 | + options: --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3 |
33 | 43 |
|
34 | | - - name: Run tests |
35 | | - run: bin/rails test |
| 44 | + steps: |
| 45 | + - name: Checkout template |
| 46 | + uses: actions/checkout@v4 |
| 47 | + - name: Set up Ruby |
| 48 | + uses: ruby/setup-ruby@v1 |
| 49 | + with: |
| 50 | + ruby-version: '3.4.7' |
| 51 | + bundler-cache: false |
| 52 | + - name: Install Rails |
| 53 | + run: gem install rails |
| 54 | + - name: Install dependencies |
| 55 | + run: bundle install |
| 56 | + - name: Install Staples |
| 57 | + run: bundle exec rake install |
| 58 | + - name: Generate new Rails app with template |
| 59 | + run: | |
| 60 | + cd /tmp |
| 61 | + suspenders test_app |
| 62 | + - name: Set up generated app |
| 63 | + env: |
| 64 | + DATABASE_URL: postgres://postgres:postgres@localhost:5432 |
| 65 | + working-directory: /tmp/test_app |
| 66 | + run: | |
| 67 | + bundle install |
| 68 | + bin/setup --skip-server |
| 69 | + bin/rails db:migrate |
| 70 | + - name: Run tests in generated app |
| 71 | + env: |
| 72 | + RAILS_ENV: test |
| 73 | + DATABASE_URL: postgres://postgres:postgres@localhost:5432 |
| 74 | + working-directory: /tmp/test_app |
| 75 | + run: | |
| 76 | + bin/rails db:test:prepare |
| 77 | + bin/rails test:all |
| 78 | + - name: Verify app can start |
| 79 | + env: |
| 80 | + DATABASE_URL: postgres://postgres:postgres@localhost:5432 |
| 81 | + working-directory: /tmp/test_app |
| 82 | + run: | |
| 83 | + timeout 10 bin/rails server > /dev/null 2>&1 & |
| 84 | + sleep 5 |
| 85 | + curl -f http://localhost:3000 || exit 1 |
0 commit comments