Skip to content

Add local testing, linting, CI #20

Add local testing, linting, CI

Add local testing, linting, CI #20

Workflow file for this run

name: "Self Deposit CI"
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
test:
runs-on: ubuntu-latest
env:
RAILS_ENV: test
DATABASE_URL: postgresql://hyrax_user:hyrax_password@localhost/dlp-selfdeposit?pool=5
DB_HOST: localhost
DB_NAME: dlp-selfdeposit
DB_USERNAME: hyrax_user
DB_PASSWORD: hyrax_password
DB_PORT: 5432
FCREPO_URL: http://fedoraAdmin:fedoraAdmin@localhost:8080/fcrepo/rest
SOLR_TEST_URL: http://localhost:8983/solr/dlp-selfdeposit-test
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Ruby and gems
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2.2'
bundler-cache: true
- name: Create database
run: bundle exec rails db:create
- name: Migrate database
run: bundle exec rails db:migrate
- name: Zip Solr configuration
run: |
zip -1 -r solr_conf.zip ./solr/conf
- name: Upload Solr configuration
run: |
curl -H "Content-type: application/octet-stream" --data-binary @solr_conf.zip \
"http://localhost:8983/solr/admin/configs?action=UPLOAD&name=solrconfig"
- name: Create Solr core
run: |
curl -H 'Content-type: application/json' \
http://localhost:8983/api/collections/ \
-d '{ "create": { "name": "dlp-selfdeposit-test", "config": "solrconfig", "numShards": 1 }}'
# Add or replace test runners here
- name: Run tests
run: bundle exec rspec spec
services:
postgres:
# Docker Hub image
image: postgres:15
# Provide the password for postgres
env:
POSTGRES_USER: hyrax_user
POSTGRES_PASSWORD: hyrax_password
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
fcrepo:
image: fcrepo/fcrepo:6.4.0
env:
CATALINA_OPTS: -Dfcrepo.home=/fcrepo-home -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 -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true
JAVA_OPTS: -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true
ports:
- 8080:8080
solr:
image: solr:8.11
ports:
- 8983:8983
options: >-
--health-cmd "curl -f http://localhost:8983/solr/admin/cores?action=STATUS"
--health-interval 10s
--health-timeout 5s
--health-retries 5
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Ruby and gems
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2.2'
bundler-cache: true
# Add or replace any other lints here
- name: Lint Ruby files
run: bundle exec rubocop --parallel