diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index eb8f2e3..f3b3f66 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -70,7 +70,7 @@ jobs: steps: - id: setup name: Setup - uses: scientist-softserv/actions/setup-env@v0.0.11 + uses: notch8/actions/setup-env@v0.0.13 with: tag: ${{ inputs.tag }} image_name: ${{ inputs.image_name }} @@ -90,7 +90,7 @@ jobs: cd ${{ inputs.subdir }}; touch .env.development; touch .env; - TAG=latest docker-compose pull web || true + TAG=latest docker compose pull web || true - name: Retag action for web id: meta-web uses: docker/metadata-action@v4.1.1 diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml new file mode 100644 index 0000000..b5aab25 --- /dev/null +++ b/.github/workflows/cypress.yaml @@ -0,0 +1,134 @@ +name: "Cypress testing" +on: + workflow_dispatch: + inputs: + confdir: + required: false + type: string + default: "/app/samvera/hyrax-webapp/solr/config" + cypress-container-name: + required: false + type: string + subdir: + default: '.' + type: string + tag: + required: false + type: string + rspec_cmd: + required: false + type: string + default: "gem install semaphore_test_boosters && rspec_booster --job $CI_NODE_INDEX/$CI_NODE_TOTAL" + setup_db_cmd: + required: false + type: string + default: "RAILS_ENV=test bundle exec rake db:create db:schema:load db:migrate" + worker: + required: false + type: boolean + workflow_call: + inputs: + confdir: + required: false + type: string + default: "/app/samvera/hyrax-webapp/solr/config" + cypress-container-name: + required: false + type: string + subdir: + default: '.' + type: string + tag: + required: false + type: string + rspec_cmd: + required: false + type: string + default: "gem install semaphore_test_boosters && rspec_booster --job $CI_NODE_INDEX/$CI_NODE_TOTAL" + setup_db_cmd: + required: false + type: string + default: "RAILS_ENV=test bundle exec rake db:create db:schema:load db:migrate" + worker: + required: false + type: boolean + +env: + REGISTRY: ghcr.io + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + env: + ALLOW_ANONYMOUS_LOGIN: "yes" + CONFDIR: ${{ inputs.confdir }} + DB_CLEANER_ALLOW_REMOTE_DB_URL: "true" + TB_RSPEC_FORMATTER: progress + TB_RSPEC_OPTIONS: --format RspecJunitFormatter --out rspec.xml + steps: + - id: setup + name: Setup + uses: notch8/actions/setup-env@v0.0.13 + with: + tag: ${{ inputs.tag }} + token: ${{ secrets.CHECKOUT_TOKEN || secrets.GITHUB_TOKEN }} + - name: Github Container Login + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - 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: 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 + - name: Start containers + run: >- + cd ${{ inputs.subdir }}; + [ -f "db/schema.rb" ] && chmod 777 db/schema.rb; + docker compose up -d web + - name: Check for and setup Solr if needed + shell: bash + run: | + cd ${{ inputs.subdir }}; + if [ -d solr ] + then + docker compose exec -T web sh -c \ + "solrcloud-upload-configset.sh "${CONFDIR}" && + SOLR_COLLECTION_NAME=hydra-test solrcloud-assign-configset.sh && + solrcloud-assign-configset.sh" + else + echo "No solr directory found, skipping..." + fi + - name: Setup db + run: >- + cd ${{ inputs.subdir }}; + docker compose exec -T web sh -c + "${{ inputs.setup_db_cmd }}" + - name: Run Cypress Tests + id: run-specs + continue-on-error: true + run: >- + cd ${{ inputs.subdir }}; + docker compose up ${{ inputs.cypress-container-name }} + - name: Fail job if spec failure + run: if [[ ${{ steps.run-specs.outcome }} == "failure" ]]; then exit 1; else exit 0; fi + - name: Publish Cypress Test Report + uses: mikepenz/action-junit-report@v3 + if: always() # always run even if the previous step fails + with: + report_paths: 'cypress/results/results-*.xml' \ No newline at end of file diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 4c280d3..813e9b2 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -67,7 +67,7 @@ jobs: steps: - id: setup name: Setup - uses: scientist-softserv/actions/setup-env@v0.0.11 + uses: notch8/actions/setup-env@v0.0.13 with: tag: ${{ inputs.tag }} image_name: ${{ inputs.image_name }} diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 83e8a81..884eb1b 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -2,6 +2,10 @@ name: "Lint for Rails Projects" on: workflow_dispatch: inputs: + lint_cmd: + required: false + type: string + default: docker compose run web bundle exec rubocop --parallel --format progress subdir: default: '.' type: string @@ -13,6 +17,10 @@ on: type: boolean workflow_call: inputs: + lint_cmd: + required: false + type: string + default: docker compose run web bundle exec rubocop --parallel --format progress subdir: default: '.' type: string @@ -32,7 +40,7 @@ jobs: steps: - id: setup name: Setup - uses: scientist-softserv/actions/setup-env@v0.0.11 + uses: notch8/actions/setup-env@v0.0.13 with: tag: ${{ inputs.tag }} token: ${{ secrets.CHECKOUT_TOKEN || secrets.GITHUB_TOKEN }} @@ -47,17 +55,18 @@ jobs: cd ${{ inputs.subdir }}; touch .env.development; touch .env; - docker-compose pull web + docker compose pull web - name: Pull worker image to prevent build run: >- cd ${{ inputs.subdir }}; - docker-compose pull worker + docker compose pull worker if: ${{ inputs.worker }} - name: Run Rubocop run: >- cd ${{ inputs.subdir }}; [ -f "db/schema.rb" ] && chmod 777 db/schema.rb; - docker-compose run web bundle exec rubocop --parallel --format progress + [ -f "bin/checkout_all.sh" ] && ./bin/checkout_all.sh; + ${{ inputs.lint_cmd }} - 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/test.yaml b/.github/workflows/test.yaml index cc3a408..6804cbe 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -72,7 +72,7 @@ jobs: steps: - id: setup name: Setup - uses: scientist-softserv/actions/setup-env@v0.0.11 + uses: notch8/actions/setup-env@v0.0.13 with: tag: ${{ inputs.tag }} token: ${{ secrets.CHECKOUT_TOKEN || secrets.GITHUB_TOKEN }} @@ -92,24 +92,24 @@ jobs: cd ${{ inputs.subdir }}; touch .env.development; touch .env; - docker-compose pull web + docker compose pull web - name: Pull worker image to prevent build if: ${{ inputs.worker }} run: >- cd ${{ inputs.subdir }}; - docker-compose pull worker + docker compose pull worker - name: Start containers run: >- cd ${{ inputs.subdir }}; [ -f "db/schema.rb" ] && chmod 777 db/schema.rb; - docker-compose up -d web + docker compose up -d web - name: Check for and setup Solr if needed shell: bash run: | cd ${{ inputs.subdir }}; if [ -d solr ] then - docker-compose exec -T web sh -c \ + docker compose exec -T web sh -c \ "solrcloud-upload-configset.sh "${CONFDIR}" && SOLR_COLLECTION_NAME=hydra-test solrcloud-assign-configset.sh && solrcloud-assign-configset.sh" @@ -119,7 +119,7 @@ jobs: - name: Setup db run: >- cd ${{ inputs.subdir }}; - docker-compose exec -T web sh -c + docker compose exec -T web sh -c "${{ inputs.setup_db_cmd }}" - name: Run Specs id: run-specs @@ -132,7 +132,7 @@ jobs: continue-on-error: true run: >- cd ${{ inputs.subdir }}; - docker-compose exec -T web sh -c + docker compose exec -T web sh -c "${{ inputs.rspec_cmd }}" - name: Fail job if spec failure run: if [[ ${{ steps.run-specs.outcome }} == "failure" ]]; then exit 1; else exit 0; fi