Skip to content

Commit

Permalink
Merge branch 'develop' into fix-build
Browse files Browse the repository at this point in the history
  • Loading branch information
orangewolf committed Dec 12, 2023
2 parents 73022df + 885ba24 commit 29e5cae
Show file tree
Hide file tree
Showing 212 changed files with 5,483 additions and 2,147 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ db/*.sqlite3-journal
log/*
node_modules
tmp
ops/provision
29 changes: 17 additions & 12 deletions .env
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
AAPB_HOST=americanarchive.org
APP_NAME=gbh-hyrax
CHROME_HOSTNAME=chrome
DB_ADAPTER=mysql2
DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL=true
DB_ADAPTER=postgresql
DB_HOST=postgres
DB_NAME=ams
DB_PASSWORD=ams_password
DB_PORT=5432
DB_TEST_NAME=ams_test
DB_USERNAME=ams_user
FCREPO_URL=http://fcrepo:8080/rest
HYRAX_VALKYRIE=true
MYSQL_DATABASE=gbh
MYSQL_HOST=db
MYSQL_PASSWORD=DatabaseFTW
MYSQL_ROOT_PASSWORD=DatabaseFTW
MYSQL_USER=root
NODE_OPTIONS=--openssl-legacy-provider
POSTGRES_DB=ams
POSTGRES_HOST_AUTH_METHOD=trust
POSTGRES_PASSWORD=ams_password
POSTGRES_USER=ams_user
REDIS_HOST=redis
REDIS_SERVER=redis
SETTINGS__BULKRAX__ENABLED=true
Expand All @@ -24,16 +37,8 @@ SOLR_HOST=solr
SOLR_PORT=8983
SOLR_URL="http://${SOLR_ADMIN_USER}:${SOLR_ADMIN_PASSWORD}@solr:8983/solr/"
TAG=latest
TB_RSPEC_FORMATTER=progress
TB_RSPEC_OPTIONS="--format RspecJunitFormatter --out rspec.xml"
TEST_DB=GBH_test
VALKYRIE_ID_TYPE=string
ZK_HOST=zoo:2181

# SMTP Mailer variables
# To enable mailer:
# - Uncomment and edit SMTP vars
# - Uncomment SMTP Mailer section in respective config/environments file
# SMTP_USER_NAME=CHANGEME
# SMTP_PASSWORD=CHANGEME
# SMTP_ADDRESS=CHANGEME
# SMTP_DOMAIN=CHANGEME
# SMTP_PORT=CHANGEME
# SMTP_TYPE=CHA NGEME
196 changes: 26 additions & 170 deletions .github/workflows/build-test-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ on:

env:
REGISTRY: ghcr.io
RAILS_ENV: test

jobs:
build-rails-5-1:
build-rails-6-1:
runs-on: ubuntu-latest
steps:
- name: Set env
Expand All @@ -25,6 +26,7 @@ jobs:
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
Expand All @@ -45,7 +47,7 @@ jobs:
- name: Pull from cache to speed up build
run: >-
touch .env.development;
TAG=latest docker-compose pull web || true
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 }}
Expand Down Expand Up @@ -104,18 +106,18 @@ jobs:
# - name: Pull from cache to speed up build
# run: >-
# touch .env.development;
# docker-compose pull web;
# docker-compose pull worker
# 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
# 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-5-1
needs: build-rails-6-1
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -131,6 +133,7 @@ jobs:
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:
Expand All @@ -152,25 +155,25 @@ jobs:
- name: Pull from cache to speed up build
run: >-
touch .env.development;
docker-compose pull web;
docker-compose pull worker
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
run: docker compose up -d web
- name: Setup solr
run: >-
docker-compose exec -T web bash -c
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:schema:load db:migrate db:seed"
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:
Expand All @@ -181,84 +184,18 @@ jobs:
CI_NODE_INDEX: ${{ matrix.ci_node_index }}
continue-on-error: true
run: >-
docker-compose exec -T web bash -c
docker compose exec -T web bash -c
"gem install semaphore_test_boosters &&
rspec_booster --job $CI_NODE_INDEX/$CI_NODE_TOTAL"
- name: Fail job if spec failure
run: if [[ ${{ steps.run-specs.outcome }} == "failure" ]]; then exit 1; else exit 0; fi
rspec_booster --job $CI_NODE_INDEX/$CI_NODE_TOTAL &&
ls -l $PWD"
- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
if: always() # always run even if the previous step fails
with:
report_paths: 'rspec*.xml'
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
BUNDLE_GEMFILE: Gemfile_next
BUNDLER_VERSION: 2.0.1
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
if: success() || failure()
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 }}
report_paths: '**/rspec*.xml'
fail_on_failure: true
require_passed_tests: true
detailed_summary: true

# lint:
# needs: build
Expand All @@ -282,93 +219,12 @@ jobs:
# - name: Pull from cache to speed up build
# run: >-
# touch .env.development;
# docker-compose pull web;
# docker-compose pull worker
# 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
# 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-rails-6-1:
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"
BUNDLE_GEMFILE: Gemfile_next
BUNDLER_VERSION: 2.0.1
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: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"
- name: Fail job if spec failure
run: if [[ ${{ steps.run-specs.outcome }} == "failure" ]]; then exit 1; else exit 0; fi
- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
if: always() # always run even if the previous step fails
with:
report_paths: 'rspec*.xml'
26 changes: 4 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
ARG HYRAX_IMAGE_VERSION=v4.0.0.beta2
ARG RUBY_VERSION=2.7.6
FROM ruby:$RUBY_VERSION-alpine3.15 as builder

RUN apk add build-base
RUN wget -O - https://github.com/jemalloc/jemalloc/releases/download/5.2.1/jemalloc-5.2.1.tar.bz2 | tar -xj && \
cd jemalloc-5.2.1 && \
./configure && \
make && \
make install


ARG HYRAX_IMAGE_VERSION=hyrax-v5.0.0.rc1
FROM ghcr.io/samvera/hyrax/hyrax-base:$HYRAX_IMAGE_VERSION as ams-base
USER root

Expand Down Expand Up @@ -42,9 +31,6 @@ RUN apk --no-cache upgrade && \
echo "******** Packages Installed *********"

USER app
COPY --from=builder /usr/local/lib/libjemalloc.so.2 /usr/local/lib/
ENV LD_PRELOAD=/usr/local/lib/libjemalloc.so.2

RUN mkdir -p /app/fits && \
cd /app/fits && \
wget https://github.com/harvard-lts/fits/releases/download/1.5.5/fits-1.5.5.zip -O fits.zip && \
Expand All @@ -53,28 +39,24 @@ RUN mkdir -p /app/fits && \
chmod a+x /app/fits/fits.sh
ENV PATH="${PATH}:/app/fits"

RUN rm -f /app/samvera/rails
COPY --chown=1001:101 $APP_PATH/Gemfile* /app/samvera/hyrax-webapp/
RUN bundle install --jobs "$(nproc)"

# NOTE Bootboot enablement
# COPY --chown=1001:101 $APP_PATH/Gemfile /app/samvera/hyrax-webapp/Gemfile_next
# RUN DEPENDENCIES_NEXT=1 bundle install --jobs "$(nproc)"

COPY --chown=1001:101 $APP_PATH/Gemfile /app/samvera/hyrax-webapp/Gemfile
RUN bundle install --jobs "$(nproc)"

COPY --chown=1001:101 $APP_PATH /app/samvera/hyrax-webapp

ARG SETTINGS__BULKRAX__ENABLED="false"

# NOTE Bootboot enablement
# RUN sh -l -c " \
# DEPENDENCIES_NEXT=1 yarn install && \
# SOLR_URL=localhost DEPENDENCIES_NEXT=1 RAILS_ENV=production SECRET_KEY_BASE=fake-key-for-asset-building-only DB_ADAPTER=nulldb bundle exec rake assets:precompile"

# RUN sh -l -c " \
# yarn install && \
# RAILS_ENV=production SECRET_KEY_BASE=fake-key-for-asset-building-only DB_ADAPTER=nulldb bundle exec rake assets:precompile"
RUN sh -l -c " \
NODE_OPTIONS=--openssl-legacy-provider SOLR_URL=http://localhost:8983 RAILS_ENV=production SECRET_KEY_BASE=fake-key-for-asset-building-only DB_ADAPTER=nulldb bundle exec rake assets:precompile"

CMD ./bin/web

Expand Down
Loading

0 comments on commit 29e5cae

Please sign in to comment.