diff --git a/.github/workflows/build-solr-arm64.yaml b/.github/workflows/build-solr-arm64.yaml new file mode 100644 index 0000000..15df484 --- /dev/null +++ b/.github/workflows/build-solr-arm64.yaml @@ -0,0 +1,75 @@ +name: "Build Docker Images" +on: + workflow_dispatch: + inputs: + image_name: + type: string + description: "Docker image name part. Fills in ghcr.io/IMAGE_NAME. Typically this is the `repo_name`, but in some projects it might be `repo_name/sub_name`" + subdir: + default: '.' + type: string + tag: + required: false + type: string + target: + required: false + type: string + workflow_call: + inputs: + image_name: + type: string + description: "Docker image name part. Fills in ghcr.io/IMAGE_NAME. Typically this is the `repo_name`, but in some projects it might be `repo_name/sub_name`" + subdir: + default: '.' + type: string + tag: + required: false + type: string + target: + required: false + type: string + +env: + REGISTRY: ghcr.io + +jobs: + build-solr-arm64: + runs-on: ubuntu-latest + steps: + - id: setup + name: Setup + uses: scientist-softserv/actions/setup-env@arm-wrestle + - name: Checkout code + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + - name: Retag action for solr + id: meta-solr + uses: docker/metadata-action@v4.1.1 + with: + images: ${{ env.REGISTRY }}/${{ env.REPO_LOWER }}/solr + tags: | + # set latest tag for default branch + type=raw,value=latest,enable={{is_default_branch}} + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push solr + uses: docker/build-push-action@v3 + with: + builder: ${{ steps.buildx.outputs.name }} + cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_LOWER }}/solr:${{ env.TAG }} + context: . + labels: ${{ steps.meta-solr.outputs.labels }} + platforms: linux/arm64 + push: true + tags: | + ${{ steps.meta-solr.outputs.tags }} + ${{ env.REGISTRY }}/${{ env.REPO_LOWER }}/solr:${{ env.TAG }} + target: ${{ inputs.target }} diff --git a/.github/workflows/build-solr.yaml b/.github/workflows/build-solr.yaml new file mode 100644 index 0000000..d55273b --- /dev/null +++ b/.github/workflows/build-solr.yaml @@ -0,0 +1,73 @@ +name: "Build Docker Images" +on: + workflow_dispatch: + inputs: + image_name: + type: string + description: "Docker image name part. Fills in ghcr.io/IMAGE_NAME. Typically this is the `repo_name`, but in some projects it might be `repo_name/sub_name`" + subdir: + default: '.' + type: string + tag: + required: false + type: string + target: + required: false + type: string + workflow_call: + inputs: + image_name: + type: string + description: "Docker image name part. Fills in ghcr.io/IMAGE_NAME. Typically this is the `repo_name`, but in some projects it might be `repo_name/sub_name`" + subdir: + default: '.' + type: string + tag: + required: false + type: string + target: + required: false + type: string + +env: + REGISTRY: ghcr.io + +jobs: + build-solr: + runs-on: ubuntu-latest + steps: + - id: setup + name: Setup + uses: scientist-softserv/actions/setup-env@arm-wrestle + - name: Checkout code + uses: actions/checkout@v3 + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + - name: Retag action for solr + id: meta-solr + uses: docker/metadata-action@v4.1.1 + with: + images: ${{ env.REGISTRY }}/${{ env.REPO_LOWER }}/solr + tags: | + # set latest tag for default branch + type=raw,value=latest,enable={{is_default_branch}} + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push solr + uses: docker/build-push-action@v3 + with: + builder: ${{ steps.buildx.outputs.name }} + cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_LOWER }}/solr:${{ env.TAG }} + context: . + labels: ${{ steps.meta-solr.outputs.labels }} + platforms: linux/amd64 + push: true + tags: | + ${{ steps.meta-solr.outputs.tags }} + ${{ env.REGISTRY }}/${{ env.REPO_LOWER }}/solr:${{ env.TAG }} + target: ${{ inputs.target }} diff --git a/.github/workflows/build-web-arm64.yaml b/.github/workflows/build-web-arm64.yaml new file mode 100644 index 0000000..02541d6 --- /dev/null +++ b/.github/workflows/build-web-arm64.yaml @@ -0,0 +1,75 @@ +name: "Build Docker Images" +on: + workflow_dispatch: + inputs: + image_name: + type: string + description: "Docker image name part. Fills in ghcr.io/IMAGE_NAME. Typically this is the `repo_name`, but in some projects it might be `repo_name/sub_name`" + subdir: + default: '.' + type: string + tag: + required: false + type: string + target: + required: false + type: string + workflow_call: + inputs: + image_name: + type: string + description: "Docker image name part. Fills in ghcr.io/IMAGE_NAME. Typically this is the `repo_name`, but in some projects it might be `repo_name/sub_name`" + subdir: + default: '.' + type: string + tag: + required: false + type: string + target: + required: false + type: string + +env: + REGISTRY: ghcr.io + +jobs: + build-web-arm64: + runs-on: ubuntu-latest + steps: + - id: setup + name: Setup + uses: scientist-softserv/actions/setup-env@arm-wrestle + - name: Checkout code + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + - name: Retag action for web + id: meta-web + uses: docker/metadata-action@v4.1.1 + with: + images: ${{ env.REGISTRY }}/${{ env.REPO_LOWER }} + tags: | + # set latest tag for default branch + type=raw,value=latest,enable={{is_default_branch}} + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push web + uses: docker/build-push-action@v3 + with: + builder: ${{ steps.buildx.outputs.name }} + cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_LOWER }}:${{ env.TAG }} + context: . + labels: ${{ steps.meta-web.outputs.labels }} + platforms: linux/arm64 + push: true + tags: | + ${{ steps.meta-web.outputs.tags }} + ${{ env.REGISTRY }}/${{ env.REPO_LOWER }}:${{ env.TAG }} + target: ${{ inputs.target }} diff --git a/.github/workflows/build-web.yaml b/.github/workflows/build-web.yaml new file mode 100644 index 0000000..fcdb4f4 --- /dev/null +++ b/.github/workflows/build-web.yaml @@ -0,0 +1,73 @@ +name: "Build Docker Images" +on: + workflow_dispatch: + inputs: + image_name: + type: string + description: "Docker image name part. Fills in ghcr.io/IMAGE_NAME. Typically this is the `repo_name`, but in some projects it might be `repo_name/sub_name`" + subdir: + default: '.' + type: string + tag: + required: false + type: string + target: + required: false + type: string + workflow_call: + inputs: + image_name: + type: string + description: "Docker image name part. Fills in ghcr.io/IMAGE_NAME. Typically this is the `repo_name`, but in some projects it might be `repo_name/sub_name`" + subdir: + default: '.' + type: string + tag: + required: false + type: string + target: + required: false + type: string + +env: + REGISTRY: ghcr.io + +jobs: + build-web: + runs-on: ubuntu-latest + steps: + - id: setup + name: Setup + uses: scientist-softserv/actions/setup-env@arm-wrestle + - name: Checkout code + uses: actions/checkout@v3 + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + - name: Retag action for web + id: meta-web + uses: docker/metadata-action@v4.1.1 + with: + images: ${{ env.REGISTRY }}/${{ env.REPO_LOWER }} + tags: | + # set latest tag for default branch + type=raw,value=latest,enable={{is_default_branch}} + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push web + uses: docker/build-push-action@v3 + with: + builder: ${{ steps.buildx.outputs.name }} + cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_LOWER }}:${{ env.TAG }} + context: . + labels: ${{ steps.meta-web.outputs.labels }} + platforms: linux/amd64 + push: true + tags: | + ${{ steps.meta-web.outputs.tags }} + ${{ env.REGISTRY }}/${{ env.REPO_LOWER }}:${{ env.TAG }} + target: ${{ inputs.target }} diff --git a/.github/workflows/build.yaml b/.github/workflows/build-worker-arm64.yaml similarity index 50% rename from .github/workflows/build.yaml rename to .github/workflows/build-worker-arm64.yaml index 25ac19b..d9f9c41 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build-worker-arm64.yaml @@ -2,8 +2,11 @@ name: "Build Docker Images" on: workflow_dispatch: inputs: - platforms: - default: "linux/amd64,linux/arm64" + image_name: + type: string + description: "Docker image name part. Fills in ghcr.io/IMAGE_NAME. Typically this is the `repo_name`, but in some projects it might be `repo_name/sub_name`" + subdir: + default: '.' type: string tag: required: false @@ -11,16 +14,13 @@ on: target: required: false type: string - worker: - required: false - type: boolean - workerTarget: - required: false - type: string workflow_call: inputs: - platforms: - default: "linux/amd64,linux/arm64" + image_name: + type: string + description: "Docker image name part. Fills in ghcr.io/IMAGE_NAME. Typically this is the `repo_name`, but in some projects it might be `repo_name/sub_name`" + subdir: + default: '.' type: string tag: required: false @@ -28,62 +28,48 @@ on: target: required: false type: string - worker: - required: false - type: boolean - workerTarget: - required: false - type: string env: REGISTRY: ghcr.io jobs: - build: + build-worker-arm64: runs-on: ubuntu-latest steps: - id: setup name: Setup - uses: scientist-softserv/actions/setup-env@main - with: - tag: ${{ inputs.tag }} + uses: scientist-softserv/actions/setup-env@arm-wrestle - name: Checkout code uses: actions/checkout@v3 - name: Set up QEMU uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx + id: buildx uses: docker/setup-buildx-action@v2 - - name: Github Container Login + - name: Retag action for worker + id: meta-worker + uses: docker/metadata-action@v4.1.1 + with: + images: ${{ env.REGISTRY }}/${{ env.REPO_LOWER }}/worker + tags: | + # set latest tag for default branch + type=raw,value=latest,enable={{is_default_branch}} + - name: Login to GitHub Container Registry uses: docker/login-action@v2 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Pull from cache to speed up build - run: >- - touch .env.development; - touch .env; - TAG=latest docker-compose pull web || true - - name: Build and push - uses: docker/build-push-action@v3 - with: - context: . - platforms: ${{ inputs.platforms }} - target: ${{ inputs.target }} - cache-from: | - ${{ env.REGISTRY }}/${{ env.REPO_LOWER }}:${{ env.TAG }} - push: true - tags: | - ${{ env.REGISTRY }}/${{ env.REPO_LOWER }}:${{ env.TAG }} - name: Build and push worker uses: docker/build-push-action@v3 with: + builder: ${{ steps.buildx.outputs.name }} + cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_LOWER }}/worker:${{ env.TAG }} context: . - platforms: ${{ inputs.platforms }} - target: ${{ inputs.workerTarget }} - cache-from: | - ${{ env.REGISTRY }}/${{ env.REPO_LOWER }}:${{ env.TAG }} + labels: ${{ steps.meta-worker.outputs.labels }} + platforms: linux/arm64 push: true tags: | + ${{ steps.meta-worker.outputs.tags }} ${{ env.REGISTRY }}/${{ env.REPO_LOWER }}/worker:${{ env.TAG }} - if: ${{ inputs.worker }} + target: ${{ inputs.target }} diff --git a/.github/workflows/build-worker.yaml b/.github/workflows/build-worker.yaml new file mode 100644 index 0000000..8c7b85d --- /dev/null +++ b/.github/workflows/build-worker.yaml @@ -0,0 +1,73 @@ +name: "Build Docker Images" +on: + workflow_dispatch: + inputs: + image_name: + type: string + description: "Docker image name part. Fills in ghcr.io/IMAGE_NAME. Typically this is the `repo_name`, but in some projects it might be `repo_name/sub_name`" + subdir: + default: '.' + type: string + tag: + required: false + type: string + target: + required: false + type: string + workflow_call: + inputs: + image_name: + type: string + description: "Docker image name part. Fills in ghcr.io/IMAGE_NAME. Typically this is the `repo_name`, but in some projects it might be `repo_name/sub_name`" + subdir: + default: '.' + type: string + tag: + required: false + type: string + target: + required: false + type: string + +env: + REGISTRY: ghcr.io + +jobs: + build-worker: + runs-on: ubuntu-latest + steps: + - id: setup + name: Setup + uses: scientist-softserv/actions/setup-env@arm-wrestle + - name: Checkout code + uses: actions/checkout@v3 + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + - name: Retag action for worker + id: meta-worker + uses: docker/metadata-action@v4.1.1 + with: + images: ${{ env.REGISTRY }}/${{ env.REPO_LOWER }}/worker + tags: | + # set latest tag for default branch + type=raw,value=latest,enable={{is_default_branch}} + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push worker + uses: docker/build-push-action@v3 + with: + builder: ${{ steps.buildx.outputs.name }} + cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_LOWER }}/worker:${{ env.TAG }} + context: . + labels: ${{ steps.meta-worker.outputs.labels }} + platforms: linux/amd64 + push: true + tags: | + ${{ steps.meta-worker.outputs.tags }} + ${{ env.REGISTRY }}/${{ env.REPO_LOWER }}/worker:${{ env.TAG }} + target: ${{ inputs.target }} diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 829e1fa..48ab70b 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -2,12 +2,19 @@ name: "Deploy" on: workflow_call: inputs: + image_name: + type: string + description: "Docker image name part. Fills in ghcr.io/IMAGE_NAME. Typically this is the `repo_name`, but in some projects it might be `repo_name/sub_name`" k8s-release-name: required: false type: string k8s-namespace: required: false type: string + solr: + description: "Add if your solr image is from the registry" + required: false + type: boolean tag: description: "Tag to override default of current branch sha" required: false @@ -17,8 +24,8 @@ env: REGISTRY: ghcr.io jobs: - deployment: - runs-on: ubuntu-latest + deploy: + runs-on: self-hosted container: dtzar/helm-kubectl:3.9.4 environment: ${{ inputs.environment }} env: @@ -35,17 +42,23 @@ jobs: GOOGLE_OAUTH_PRIVATE_KEY_SECRET: ${{ secrets.GOOGLE_OAUTH_PRIVATE_KEY_SECRET }} IA_PASSWORD: ${{ secrets.IA_PASSWORD }} MAIL_PASS: ${{ secrets.MAIL_PASS }} + PAPERTRAIL_API_TOKEN: ${{ secrets.PAPERTRAIL_API_TOKEN }} POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} REDIS_PASSWORD: ${{ secrets.REDIS_PASSWORD }} SECRET_KEY_BASE: ${{ secrets.SECRET_KEY_BASE }} + SENDGRID_PASSWORD: ${{ secrets.SENDGRID_PASSWORD }} SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }} SOLR_ADMIN_PASSWORD: ${{ secrets.SOLR_ADMIN_PASSWORD }} + SQUARE_ACCESS_TOKEN: ${{ secrets.SQUARE_ACCESS_TOKEN }} + SQUARE_WEBHOOK_SIGNATURE_KEY: ${{ secrets.SQUARE_WEBHOOK_SIGNATURE_KEY }} + STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }} steps: - id: setup name: Setup uses: scientist-softserv/actions/setup-env@main with: tag: ${{ inputs.tag }} + image_name: ${{ inputs.image_name }} - name: Checkout code uses: actions/checkout@v3 - name: Setup tmate session @@ -53,11 +66,21 @@ jobs: if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} with: limit-access-to-actor: true + - name: Do deploy with solr registry image + if: ${{ inputs.solr }} + run: | + echo $KUBECONFIG_FILE | base64 -d > $KUBECONFIG; + DOLLAR=$ envsubst < ops/${{ inputs.environment }}-deploy.tmpl.yaml > ops/${{ inputs.environment }}-deploy.yaml; + export DEPLOY_TAG=${TAG}; + export DEPLOY_IMAGE=${REGISTRY}/${REPO_LOWER}; + export WORKER_IMAGE=${REGISTRY}/${REPO_LOWER}/worker; + export SOLR_IMAGE=${REGISTRY}/${REPO_LOWER}/solr; + ./bin/helm_deploy ${{ inputs.k8s-release-name || format('{0}-{1}', github.event.repository.name, inputs.environment) }} ${{ inputs.k8s-namespace || format('{0}-{1}', github.event.repository.name, inputs.environment) }} - name: Do deploy - run: >- + run: | echo $KUBECONFIG_FILE | base64 -d > $KUBECONFIG; DOLLAR=$ envsubst < ops/${{ inputs.environment }}-deploy.tmpl.yaml > ops/${{ inputs.environment }}-deploy.yaml; export DEPLOY_TAG=${TAG}; - export DEPLOY_IMAGE=ghcr.io/${REPO_LOWER}; - export WORKER_IMAGE=ghcr.io/${REPO_LOWER}/worker; + export DEPLOY_IMAGE=${REGISTRY}/${REPO_LOWER}; + export WORKER_IMAGE=${REGISTRY}/${REPO_LOWER}/worker; ./bin/helm_deploy ${{ inputs.k8s-release-name || format('{0}-{1}', github.event.repository.name, inputs.environment) }} ${{ inputs.k8s-namespace || format('{0}-{1}', github.event.repository.name, inputs.environment) }} diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index d2f5576..f311534 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -2,27 +2,33 @@ name: "Lint for Rails Projects" on: workflow_dispatch: inputs: - worker: - required: false - type: boolean + subdir: + default: '.' + type: string tag: required: false type: string - workflow_call: - inputs: worker: required: false type: boolean + workflow_call: + inputs: + subdir: + default: '.' + type: string tag: required: false type: string + worker: + required: false + type: boolean env: REGISTRY: ghcr.io jobs: lint: - runs-on: ubuntu-latest + runs-on: self-hosted steps: - id: setup name: Setup @@ -39,15 +45,21 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Pull image to prevent build run: >- + cd ${{ inputs.subdir }}; touch .env.development; touch .env; docker-compose pull web - name: Pull worker image to prevent build run: >- + cd ${{ inputs.subdir }}; + chmod 777 db/schema.rb; docker-compose pull worker if: ${{ inputs.worker }} - name: Run Rubocop - run: docker-compose run web bundle exec rubocop --parallel --format progress + run: >- + cd ${{ inputs.subdir }}; + chmod 777 db/schema.rb; + docker-compose run web bundle exec rubocop --parallel --format progress - name: Publish Test Report uses: mikepenz/action-junit-report@v3 if: always() # always run even if the previous step fails diff --git a/.github/workflows/retag.yaml b/.github/workflows/retag.yaml deleted file mode 100644 index f6b9e7e..0000000 --- a/.github/workflows/retag.yaml +++ /dev/null @@ -1,51 +0,0 @@ -name: "Retag the item on main" -on: - workflow_dispatch: - inputs: - worker: - required: false - type: boolean - tag: - required: false - type: string - workflow_call: - inputs: - worker: - required: false - type: boolean - tag: - required: false - type: string - -env: - REGISTRY: ghcr.io - -jobs: - retag: - runs-on: ubuntu-latest - if: ${{ github.ref == 'refs/heads/main' }} - steps: - - id: setup - name: Setup - uses: scientist-softserv/actions/setup-env@main - with: - tag: ${{ inputs.tag }} - - name: Retag web to latest - uses: koraykoska/retag-docker-image@0.2.4 - with: - registry: ${{ env.REGISTRY }} - name: ${{ env.REPO_LOWER }} - old_tag: ${{ env.TAG }} - new_tag: latest - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Retag worker to latest - uses: koraykoska/retag-docker-image@0.2.4 - with: - registry: ${{ env.REGISTRY }} - name: ${{ env.REPO_LOWER }}/worker - old_tag: ${{ env.TAG }} - new_tag: latest - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - if: ${{ inputs.worker }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ab09645..1d8ba80 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -2,9 +2,13 @@ name: "Rspec for Rails Apps" on: workflow_dispatch: inputs: - worker: + confdir: required: false - type: boolean + type: string + default: "/app/samvera/hyrax-webapp/solr/config" + subdir: + default: '.' + type: string tag: required: false type: string @@ -12,11 +16,18 @@ on: required: false type: string default: "gem install semaphore_test_boosters && rspec_booster --job $CI_NODE_INDEX/$CI_NODE_TOTAL" - workflow_call: - inputs: worker: required: false type: boolean + workflow_call: + inputs: + confdir: + required: false + type: string + default: "/app/samvera/hyrax-webapp/solr/config" + subdir: + default: '.' + type: string tag: required: false type: string @@ -24,12 +35,16 @@ on: required: false type: string default: "gem install semaphore_test_boosters && rspec_booster --job $CI_NODE_INDEX/$CI_NODE_TOTAL" + worker: + required: false + type: boolean + env: REGISTRY: ghcr.io jobs: test: - runs-on: ubuntu-latest + runs-on: self-hosted strategy: fail-fast: false matrix: @@ -42,7 +57,7 @@ jobs: ci_node_index: [0, 1, 2] env: ALLOW_ANONYMOUS_LOGIN: "yes" - CONFDIR: "/app/samvera/hyrax-webapp/solr/config" + CONFDIR: ${{ inputs.confdir }} DB_CLEANER_ALLOW_REMOTE_DB_URL: "true" TB_RSPEC_FORMATTER: progress TB_RSPEC_OPTIONS: --format RspecJunitFormatter --out rspec.xml @@ -67,21 +82,28 @@ jobs: limit-access-to-actor: true - name: Pull image to prevent build run: >- + cd ${{ inputs.subdir }}; touch .env.development; touch .env; docker-compose pull web - name: Pull worker image to prevent build + if: ${{ inputs.worker }} run: >- + cd ${{ inputs.subdir }}; docker-compose pull worker - if: ${{ inputs.worker }} - name: Start containers - run: docker-compose up -d web + run: >- + cd ${{ inputs.subdir }}; + chmod 777 db/schema.rb; + docker-compose up -d web - name: Check for and setup Solr if needed + shell: sh run: | + cd ${{ inputs.subdir }}; if [ -d solr ] then docker-compose exec -T web sh -c \ - "solrcloud-upload-configset.sh /app/samvera/hyrax-webapp/solr/config && + "solrcloud-upload-configset.sh "${CONFDIR}" && SOLR_COLLECTION_NAME=hydra-test solrcloud-assign-configset.sh && solrcloud-assign-configset.sh" else @@ -89,6 +111,7 @@ jobs: fi - name: Setup db run: >- + cd ${{ inputs.subdir }}; docker-compose exec -T web sh -c "RAILS_ENV=test bundle exec rake db:create db:schema:load db:migrate" - name: Run Specs @@ -100,6 +123,7 @@ jobs: CI_NODE_INDEX: ${{ matrix.ci_node_index }} continue-on-error: true run: >- + cd ${{ inputs.subdir }}; docker-compose exec -T web sh -c "${{ inputs.rspec_cmd }}" - name: Publish Test Report diff --git a/README.md b/README.md index caac7ba..eef2743 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ # actions -Github action for Docker build, Rubocop linting, and running Rspec tests for Rails applications. +Github action for Docker build, Rubocop linting, and running Rspec tests for Rails applications configured to run on a self-hosted runner. diff --git a/setup-env/action.yaml b/setup-env/action.yaml index f24bc7f..e29cb06 100644 --- a/setup-env/action.yaml +++ b/setup-env/action.yaml @@ -4,20 +4,29 @@ inputs: tag: required: false type: string + image_name: + required: false + type: string runs: using: "composite" steps: - name: Set env - run: >- - echo "TAG=${HEAD_TAG::8}" >> ${GITHUB_ENV}; - echo ${HEAD_TAG::8} env: HEAD_TAG: ${{ inputs.tag || github.event.pull_request.head.sha || github.sha }} shell: bash + run: >- + echo "TAG=${HEAD_TAG::8}" >> ${GITHUB_ENV}; + echo ${HEAD_TAG::8}; + echo "export DOCKER_CLIENT_TIMEOUT=360"; + echo "export COMPOSE_HTTP_TIMEOUT=360" - name: Downcase repo - run: | - echo "REPO_LOWER=${REPO,,}" >> ${GITHUB_ENV} env: - REPO: "${{ github.repository }}" + REPO: "${{ inputs.image_name || github.repository }}" shell: bash + run: | + echo "REPO_LOWER=${REPO,,}" >> ${GITHUB_ENV} + - name: Install docker-compose + uses: KengoTODA/actions-setup-docker-compose@main + with: + version: '2.12.2'