-
Notifications
You must be signed in to change notification settings - Fork 28
93 lines (81 loc) · 2.44 KB
/
ci-checks.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# run local with act
# Note: the dummy.env file is not optional to prevent act to load the .env file
# this is super important because if a proxy is set in the .env file,
# because act will use the proxy and the tests will fail
# act -j test --env-file dummy.env --rm
name: CI Check
on:
pull_request:
types:
- opened
- synchronize
- reopened
jobs:
test:
runs-on: ubuntu-latest
container:
image: ruby:3.2
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: "postgres"
POSTGRES_DB: postgres
POSTGRES_HOST_AUTH_METHOD: trust
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Setup Javascript (act only)
# install nodejs only if running locally with act
# otherwise the actions/setup-node@v4 will fails
# because it needs a installed nodejs to be able to run
if: ${{ env.ACT }}
run: |
apt-get update
apt-get install -y nodejs
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
- name: Gem cache
id: cache-bundle
uses: actions/cache@v4
with:
path: vendor/bundle
key: bundle-${{ hashFiles('**/Gemfile.lock') }}
- name: Bundle install
id: bundle-install
env:
RAILS_ENV: test
run: |
gem install bundler
bundle install --jobs 4 --retry 3 --path vendor/bundle
- name: Install yarn
run: npm install -g yarn
- name: Get yarn cache dir
id: yarn-cache-dir
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Yarn cache
id: cache-yarn
uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache-dir.outputs.dir }}
key: yarn-${{ hashFiles('**/yarn.lock') }}
- name: Setup DB, Run tests
id: test-rails
env:
POSTGRES_SERVICE_HOST: postgres
PGUSER: postgres
PGPORT: 5432
RAILS_ENV: test
run: |
bin/rake db:create db:migrate
bundle exec rspec
- name: Yarn install
id: test-js
run: |
yarn install
yarn test