-
Notifications
You must be signed in to change notification settings - Fork 9
98 lines (82 loc) · 2.79 KB
/
test.yml
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
94
95
96
97
98
# This code from https://dev.to/vvo/a-rails-and-postgresql-setup-for-github-actions-ci-nc8
# and https://dev.to/jennapederson/github-actions-in-action-2c5
name: Run tests
env:
RAILS_ENV: test
NODE_ENV: development
on: [push]
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:13.7-alpine
env:
POSTGRES_USER: outpost
POSTGRES_PASSWORD: password
POSTGRES_DB: outpost_test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
mongo:
image: mongo:6
env:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: password
ports:
- 27017:27017
steps:
- name: Checkout repository
uses: actions/checkout@main
- name: Install native postgres client
run: |
sudo apt-get -y install libpq-dev
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Install required Node.js version
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- name: Get Yarn cache directory path
id: yarn-cache
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Setup cache key and directory for node_modules cache
uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Yarn install
env:
NODE_OPTIONS: --openssl-legacy-provider
run: yarn --frozen-lockfile
- name: Setup database
env:
RAILS_ENV: test
DATABASE_URL: postgresql://outpost:password@localhost:5432/outpost_test
DB_URI: mongodb://root:password@localhost:27017/outpost_development?authSource=admin
run: |
bundle exec rails db:drop
bundle exec rails db:create
bundle exec rails db:migrate
- name: Compile assets
env:
RAILS_ENV: test
NODE_OPTIONS: --openssl-legacy-provider
run: |
bundle exec rails assets:precompile
- name: Run tests
env:
RAILS_ENV: test
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
OFSTED_FEED_API_ENDPOINT: https://test-ofsted-feed.stub # this is not a real url, we just need an env variable set for the stub to work in tests
DATABASE_URL: postgresql://outpost:password@localhost:5432/outpost_test
run: |
bundle exec rspec
- name: Upload report to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}