Lint Build Test of 7035/merge by @dlpierce #409
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: '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 | |
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@v4 | |
- 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@v4 | |
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@v4 | |
- name: Auth to ghcr.io | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Setup image tags | |
id: image-meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=raw,value=latest,enable={{is_default_branch}} | |
type=ref,event=branch | |
type=sha | |
- name: Build and export | |
uses: docker/build-push-action@v6 | |
with: | |
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@v3 | |
if: ${{ github.ref == 'refs/heads/main' }} | |
with: | |
token: ${{ secrets.NURAX_ACCESS_TOKEN }} | |
event-type: deploy | |
repository: samvera-labs/nurax | |
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}' | |
- name: Upload built image artifact | |
uses: actions/upload-artifact@v4 | |
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] | |
ci_node_total: [4] | |
ci_node_index: [0,1,2,3] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- 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@v4 | |
with: | |
name: hyrax-dev | |
path: ${{runner.temp}} | |
- name: Start containers | |
run: | | |
docker load --input ${{runner.temp}}/hyrax-dev-${{ github.sha }}.tar | |
docker image ls -a | |
docker compose -f docker-compose-${{ matrix.ci_test_app }}.yml up -d --quiet-pull --pull missing --no-build | |
- name: RSpec | |
env: | |
CI_NODE_TOTAL: ${{ matrix.ci_node_total }} | |
CI_NODE_INDEX: ${{ matrix.ci_node_index }} | |
run: >- | |
docker compose -f docker-compose-${{ matrix.ci_test_app }}.yml exec -T -w /app/samvera/hyrax-engine web sh -c | |
"bundle install && yarn install && rspec_booster --job ${{ matrix.ci_node_index }}/${{ matrix.ci_node_total }}" | |
- name: Capture Container Logs | |
if: always() | |
uses: jwalton/gh-docker-logs@v2 | |
with: | |
images: 'selenium/standalone-chromium,postgres,fcrepo/fcrepo,solr,bitnami/redis,ghcr.io/samvera/fitsservlet,ghcr.io/samvera/fcrepo4' | |
- 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@v4 | |
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@v4 | |
with: | |
name: Event File | |
path: ${{ github.event_path }} |