Skip to content

Build of 669/merge by @afred #591

Build of 669/merge by @afred

Build of 669/merge by @afred #591

name: "Ruby on Rails CI"
run-name: Build of ${{ github.ref_name }} by @${{ github.actor }}
on:
pull_request:
branches:
- develop
- main
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
env:
REGISTRY: ghcr.io
RAILS_ENV: test
jobs:
build-rails-6-1:
runs-on: ubuntu-latest
steps:
- name: Set env
run: >-
echo "TAG=${HEAD_TAG::8}" >> ${GITHUB_ENV};
echo ${HEAD_TAG::8}
env:
HEAD_TAG: ${{ github.event.pull_request.head.sha || github.sha }}
SE_NODE_SESSION_TIMEOUT: 999999
shell: bash
- name: Downcase repo
run: echo "REPO_LOWER=${REPO,,}" >> $GITHUB_ENV
env:
REPO: '${{ github.repository }}'
- name: Checkout code
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Github Container Login
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull from cache to speed up build
run: >-
touch .env.development;
TAG=latest docker compose pull web || true
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
with:
limit-access-to-actor: true
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
# platforms: linux/amd64,linux/arm64
platforms: linux/amd64
target: ams-base
build-args: |
SETTINGS__BULKRAX__ENABLED=true
EXTRA_APK_PACKAGES=less vim bash openjdk11-jre ffmpeg rsync yarn
cache-from: |
${{ env.REGISTRY }}/${{ env.REPO_LOWER }}:${TAG}
push: true
tags: |
${{ env.REGISTRY }}/${{ env.REPO_LOWER }}:${{ env.TAG }}
- name: Build and push worker
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64
# platforms: linux/amd64,linux/arm64
target: ams-worker
build-args: |
SETTINGS__BULKRAX__ENABLED=true
EXTRA_APK_PACKAGES=less vim bash openjdk11-jre ffmpeg rsync yarn
cache-from: |
${{ env.REGISTRY }}/${{ env.REPO_LOWER }}:${TAG}
push: true
tags: |
${{ env.REGISTRY }}/${{ env.REPO_LOWER }}/worker:${{ env.TAG }}
# lint:
# needs: build
# runs-on: ubuntu-latest
# steps:
# - name: Set env
# run: >-
# echo "TAG=${HEAD_TAG::8}" >> ${GITHUB_ENV};
# echo ${HEAD_TAG::8}
# env:
# HEAD_TAG: ${{ github.event.pull_request.head.sha || github.sha }}
# shell: bash
# - name: Checkout code
# uses: actions/checkout@v3
# - name: Github Container Login
# uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
# with:
# registry: ${{ env.REGISTRY }}
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
# - name: Pull from cache to speed up build
# run: >-
# touch .env.development;
# docker compose pull web;
# docker compose pull worker
# - name: Run Rubocop
# run: docker compose run web bundle exec rubocop --parallel --format progress --format junit --out rubocop.xml --display-only-failed
# - name: Publish Test Report
# uses: mikepenz/action-junit-report@v3
# if: always() # always run even if the previous step fails
# with:
# report_paths: 'rubocop*.xml'
test:
needs: build-rails-6-1
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Set N number of parallel jobs you want to run tests on.
# Use higher number if you have slow tests to split them on more parallel jobs.
# Remember to update ci_node_index below to 0..N-1
ci_node_total: [3]
# set N-1 indexes for parallel jobs
# When you run 2 parallel jobs then first job will have index 0, the second job will have index 1 etc
ci_node_index: [0, 1, 2]
env:
ALLOW_ANONYMOUS_LOGIN: "yes"
CONFDIR: "/app/samvera/hyrax-webapp/solr/config"
DB_CLEANER_ALLOW_REMOTE_DB_URL: "true"
SE_NODE_SESSION_TIMEOUT: 999999
TB_RSPEC_FORMATTER: progress
TB_RSPEC_OPTIONS: --format RspecJunitFormatter --out rspec.xml
steps:
- name: Set env
run: >-
echo "TAG=${HEAD_TAG::8}" >> ${GITHUB_ENV};
echo ${HEAD_TAG::8}
env:
HEAD_TAG: ${{ github.event.pull_request.head.sha || github.sha }}
shell: bash
- name: Checkout code
uses: actions/checkout@v3
- name: Github Container Login
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull from cache to speed up build
run: >-
touch .env.development;
docker compose pull web;
docker compose pull worker
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
with:
limit-access-to-actor: true
- name: Start containers
run: docker compose up -d web
- name: Setup solr
run: >-
docker compose exec -T web bash -c
"solrcloud-upload-configset.sh /app/samvera/hyrax-webapp/solr/config &&
SOLR_COLLECTION_NAME=hydra-test solrcloud-assign-configset.sh &&
solrcloud-assign-configset.sh"
- name: Setup db
run: >-
docker compose exec -T web bash -c
"RAILS_ENV=test bundle exec rake db:environment:set db:schema:load db:migrate db:seed"
- name: Run Specs
id: run-specs
env:
# Specifies how many jobs you would like to run in parallel,
# used for partitioning
CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
# Use the index from matrix as an environment variable
CI_NODE_INDEX: ${{ matrix.ci_node_index }}
continue-on-error: true
run: >-
docker compose exec -T web bash -c
"gem install semaphore_test_boosters &&
rspec_booster --job $CI_NODE_INDEX/$CI_NODE_TOTAL &&
ls -l $PWD"
- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
if: success() || failure()
with:
report_paths: '**/rspec*.xml'
fail_on_failure: true
require_passed_tests: true
detailed_summary: true
# lint:
# needs: build
# runs-on: ubuntu-latest
# steps:
# - name: Set env
# run: >-
# echo "TAG=${HEAD_TAG::8}" >> ${GITHUB_ENV};
# echo ${HEAD_TAG::8}
# env:
# HEAD_TAG: ${{ github.event.pull_request.head.sha || github.sha }}
# shell: bash
# - name: Checkout code
# uses: actions/checkout@v3
# - name: Github Container Login
# uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
# with:
# registry: ${{ env.REGISTRY }}
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
# - name: Pull from cache to speed up build
# run: >-
# touch .env.development;
# docker compose pull web;
# docker compose pull worker
# - name: Run Rubocop
# run: docker compose run web bundle exec rubocop --parallel --format progress --format junit --out rubocop.xml --display-only-failed
# - name: Publish Test Report
# uses: mikepenz/action-junit-report@v3
# if: always() # always run even if the previous step fails
# with:
# report_paths: 'rubocop*.xml'