Skip to content

Lint Build Test of 7555/merge by @orangewolf #1793

Lint Build Test of 7555/merge by @orangewolf

Lint Build Test of 7555/merge by @orangewolf #1793

name: 'Lint Build Test'
run-name: Lint Build Test of ${{ github.ref_name }} by @${{ github.actor }}
on:
push:
branches:
- main
pull_request:
branches:
- 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
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-dev
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
bundler-cache: true
cache-version: 1
- name: Rubocop
run: bundle install && bundle exec rubocop --parallel --format progress --format junit --out rubocop.xml --display-only-failed
- name: Archive rubocop reports
uses: actions/upload-artifact@v7
if: always()
with:
name: rubocop-reports
path: 'rubocop*.xml'
build:
needs: lint
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Auth to ghcr.io
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Setup image tags
id: image-meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=pr
type=sha,format=long,prefix=
- name: Build and export
uses: docker/build-push-action@v7
with:
build-args: |
BUILD_TIMESTAMP=${{ fromJSON(steps.image-meta.outputs.json).labels['org.opencontainers.image.created'] }}
BUILD_GITSHA=${{ github.sha }}
cache-from: type=gha
cache-to: type=gha, mode=max
context: .
target: hyrax-engine-dev
push: true # ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.image-meta.outputs.tags }}
labels: ${{ steps.image-meta.outputs.labels }}
outputs: type=docker,dest=${{runner.temp}}/hyrax-dev-${{ github.sha }}.tar
- name: Trigger Nurax Deployment
uses: peter-evans/repository-dispatch@v4
if: ${{ github.ref == 'refs/heads/main' }}
with:
token: ${{ secrets.NURAX_ACCESS_TOKEN }}
event-type: deploy
repository: samvera-labs/nurax-terraform
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
- name: Upload built image artifact
uses: actions/upload-artifact@v7
with:
name: hyrax-dev
path: ${{runner.temp}}/hyrax-dev-${{ github.sha }}.tar
test:
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ci_test_app: [dassie,koppie,sirenia,allinson]
ci_node_total: [4]
ci_node_index: [0,1,2,3]
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup tmate debug session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
with:
limit-access-to-actor: true
detached: true
- name: Download built image artifact
uses: actions/download-artifact@v8
with:
name: hyrax-dev
path: ${{runner.temp}}
- name: Load hyrax image
run: |
docker load --input ${{runner.temp}}/hyrax-dev-${{ github.sha }}.tar
docker image ls -a
- name: RSpec
env:
CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
CI_NODE_INDEX: ${{ matrix.ci_node_index }}
# Use `run` instead of `up`: this starts only the web service and the
# services it depends_on (web's depends_on excludes the sidekiq worker),
# rather than every service in the compose file, reducing CI memory use.
#
# --entrypoint sh skips the image's dev entrypoint (db:prepare/migrate/seed
# + service waits). The specs don't need it: spec_helper.rb creates and
# migrates its own test database. Skipping it also avoids running db:seed,
# which isn't needed for specs.
#
# GIT_CONFIG_* marks every repo path as a git safe.directory. The checkout
# is owned by a different uid than the container user, so without this git
# aborts (dubious ownership) while bundler touches the engine and
# git-sourced gems.
#
# --use-aliases gives the run container the web service's network aliases,
# so the remote browser can reach the karma server at http://web:9876
# (the jasmine spec). Without it `run` omits the alias and the browser
# fails with net::ERR_NAME_NOT_RESOLVED.
run: >-
docker compose -f docker-compose-${{ matrix.ci_test_app }}.yml run -T --quiet-pull --pull missing
--use-aliases --entrypoint sh
-e GIT_CONFIG_COUNT=1 -e GIT_CONFIG_KEY_0=safe.directory -e GIT_CONFIG_VALUE_0='*'
web -c
"cd ../hyrax-engine && bundle install && yarn install && rspec_booster --job ${{ matrix.ci_node_index }}/${{ matrix.ci_node_total }}"
- name: Move Test Files
if: always()
env:
CI_TEST_APP: ${{ matrix.ci_test_app }}
CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
CI_NODE_INDEX: ${{ matrix.ci_node_index }}
run: >-
mv rspec.xml rspec-${CI_TEST_APP}-${CI_NODE_INDEX}.xml
- name: Archive spec reports
uses: actions/upload-artifact@v7
if: always()
with:
name: spec-reports-${{ matrix.ci_test_app }}-${{ matrix.ci_node_index }}
path: '**/rspec*.xml'
event_file:
name: "Event File"
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/upload-artifact@v7
with:
name: Event File
path: ${{ github.event_path }}