Skip to content

Commit 45db210

Browse files
committed
Add test.yml
1 parent d2d9e01 commit 45db210

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

.github/workflows/test.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: CI and CD
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
test:
16+
runs-on: ubuntu-latest
17+
18+
env:
19+
RACK_ENV: test
20+
RAILS_ENV: test
21+
DATABASE_URL: "postgresql://postgres:[email protected]/assure-test"
22+
23+
services:
24+
postgres:
25+
image: postgres:17.4-alpine
26+
env:
27+
POSTGRES_DB: assure-test
28+
POSTGRES_USER: postgres
29+
POSTGRES_PASSWORD: postgres
30+
ports:
31+
- 5432:5432
32+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
33+
34+
steps:
35+
- name: Checkout code
36+
uses: actions/checkout@v4
37+
38+
- name: Setup Ruby and install gems
39+
uses: ruby/setup-ruby@v1
40+
with:
41+
bundler-cache: true
42+
43+
- name: Find yarn cache location
44+
id: yarn-cache
45+
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
46+
47+
- name: JS package cache
48+
uses: actions/cache@v4
49+
with:
50+
path: ${{ steps.yarn-cache.outputs.dir }}
51+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
52+
restore-keys: |
53+
${{ runner.os }}-yarn-
54+
55+
- name: Install packages with yarn
56+
run: yarn install --frozen-lockfile
57+
58+
- name: Precompile assets
59+
run: bin/rails assets:precompile
60+
61+
- name: Setup test database
62+
run: bin/rails db:prepare
63+
64+
- name: Run linters
65+
run: bundle exec rubocop
66+
67+
- name: Run tests
68+
run: bundle exec rspec

0 commit comments

Comments
 (0)