-
Notifications
You must be signed in to change notification settings - Fork 3
152 lines (149 loc) Β· 4.72 KB
/
lint-and-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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: Lint and Run Tests
on:
push:
jobs:
lint:
runs-on: ubuntu-latest
env:
BUNDLE_WITH: lint
BUNDLE_PATH: vendor/bundle
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
-
name: Restore installed Gems
uses: actions/cache@v4
with:
path: vendor/bundle
key: spot-bundle-lint-${{ hashFiles('Gemfile.lock') }}
-
name: Install gems
run: bundle install
-
name: Run Rubocop
run: bundle exec rubocop --format junit --out rubocop-$(date +'%Y%m%md').xml
-
name: Publish Rubo report
uses: mikepenz/action-junit-report@v3
if: always()
with:
report_paths: 'rubocop*.xml'
test:
runs-on: ubuntu-latest
container: ruby:2.7.8-slim-bullseye
needs: lint
services:
database:
image: postgres:13-alpine
ports:
- 5432:5432
env:
POSTGRES_DB: spot_test
POSTGRES_USER: spot_test_user
POSTGRES_PASSWORD: spot_test_pw
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
fedora:
image: samvera/fcrepo4:4.7.5
ports:
- 8080:8080
env:
CATALINA_OPTS: '-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms512m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC'
redis:
image: redis:6.2-alpine
ports:
- 6379:6379
solr:
image: bitnami/solr:8.11.2
ports:
- 8983:8983
env:
SOLR_ADMIN_USERNAME: solr_admin
SOLR_ADMIN_PASSWORD: solr_password
SOLR_CLOUD_BOOTSTRAP: yes
SOLR_ENABLE_CLOUD_MODE: yes
SOLR_HOST: solr
SOLR_ZK_HOSTS: zookeeper:2181
zookeeper:
image: bitnami/zookeeper:3.9
ports:
- 2181:2181
env:
ZOO_SERVER_ID: 1
ALLOW_ANONYMOUS_LOGIN: yes
ZOO_SERVERS: zookeeper:2888:3888
ZOO_4LW_COMMANDS_WHITELIST: srvr,mntr,conf,ruok
env:
BUNDLE_WITH: test
BUNDLE_PATH: vendor/bundle
CAS_BASE_URL: ''
FEDORA_TEST_URL: http://fedora:8080/rest
NOKOGIRI_USE_SYSTEM_LIBRARIES: true
PSQL_PASSWORD: spot_test_pw
PSQL_USER: spot_test_user
PSQL_DATABASE: spot_test
RAILS_ENV: test
SOLR_TEST_URL: http://solr:8983/solr/spot-test
URL: http://localhost:3000
steps:
-
name: Install system dependencies from Dockerfile
run: |
apt-get update -y && apt-get install -y --no-install-recommends \
build-essential coreutils curl git libpq-dev libxml2 libxml2-dev libxslt-dev \
netcat-openbsd openssl ruby-dev tzdata unzip zip
-
name: Setup Chrome
uses: browser-actions/setup-chrome@v1
with:
install-dependencies: true
install-chromedriver: true
-
name: Checkout code
uses: actions/checkout@v4
-
name: Restore Solr config.zip from cache
id: solr-config-cache
uses: actions/cache@v4
with:
path: /tmp/spot_solr_config.zip
key: spot-solr-${{ hashFiles('docker/solr/config') }}
-
name: Build Solr config.zip
if: steps.solr-config-cache.outputs.cache-hit != 'true'
run: |
cd docker/solr/config
zip -1 /tmp/spot_solr_config.zip ./*
-
name: Setup Solr core with local configs
run: |
curl --user solr_admin:solr_password -H "Content-type: application/octet-stream" --data-binary @/tmp/spot_solr_config.zip "http://solr:8983/solr/admin/configs?action=UPLOAD&name=spot"
curl --user solr_admin:solr_password -H "Content-type: application/json" http://solr:8983/api/collections/ -d "{create: {name: spot-test, config: spot, numShards: 1}}"
-
name: Restore installed Gems
uses: actions/cache@v4
with:
path: vendor/bundle
key: spot-bundle-${{ hashFiles('Gemfile.lock') }}
-
name: Install gem dependencies
run: |
gem install bundler:$(tail -n 1 Gemfile.lock | sed -e "s/ *//")
bundle install
-
name: Run migrations
run: bundle exec rake db:migrate
-
name: Run tests
run: |
mkdir /tmp/test-results
bundle exec rspec --backtrace --format RspecJunitFormatter --out /tmp/test-results/rspec.xml --format progress
-
name: Publish RSpec report
uses: mikepenz/action-junit-report@v3
if: always()
with:
report_paths: /tmp/test-results/*.xml