T343 schoolie #37
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI testing | |
on: | |
# allow running action manually | |
workflow_dispatch: | |
# trigger on pull request to "master" branch | |
pull_request: | |
branches: | |
- master | |
push: | |
branches: | |
- ci-workflow | |
jobs: | |
CI: | |
runs-on: ubuntu-latest | |
permissions: | |
packages: read | |
steps: | |
# Logs in to the Github Container Registry | |
# Requires user to set "GHCR_USERNAME" and "CR_PAT" as repository secrets in github - instructions for generating these are in README | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ secrets.GHCR_USERNAME }} | |
password: ${{ secrets.CR_PAT }} | |
# Prepare the folder structure for scholarspace | |
- name: Create scholarspace folders | |
run: | | |
mkdir -p /opt/scholarspace | |
mkdir /opt/scholarspace/certs | |
mkdir /opt/scholarspace-tmp | |
mkdir /opt/scholarspace-minter | |
mkdir /opt/scholarspace/fedora-data | |
mkdir /opt/scholarspace/solr-data | |
cd /opt/scholarspace | |
# Checkout the repository code | |
- name: Check out repository code | |
uses: actions/checkout@v4 | |
# Copy the pre-filled docker/ci.env file to use as the .env file for testing | |
- name: Create env file | |
run: | | |
cp docker/ci.env .env | |
# Start all of the docker containers and wait until positive response from healthchecks | |
- name: Start Docker containers | |
run: | | |
docker compose up --wait | |
- name: Create dev/test databases | |
run: | | |
docker exec $(docker ps --filter 'name=app' -q) bash -lc "bundle exec rails db:create" | |
- name: Migrate dev/test databases | |
run: | | |
docker exec $(docker ps --filter 'name=app' -q) bash -lc "bundle exec rails db:migrate" | |
- name: Run RSpec tests | |
run: | | |
docker exec $(docker ps --filter 'name=app' -q) bash -lc "bundle exec rspec" |