From 52793b0da56799ffa2b398ce122354ee35f8e82c Mon Sep 17 00:00:00 2001 From: April Rieger Date: Mon, 18 Sep 2023 21:23:54 -0700 Subject: [PATCH 1/4] Cypress in the house--again --- .github/workflows/build.yaml | 2 +- .github/workflows/cypress.yaml | 134 +++++++++++++++++++++++++++++++++ .github/workflows/deploy.yaml | 2 +- .github/workflows/lint.yaml | 2 +- .github/workflows/test.yaml | 2 +- 5 files changed, 138 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/cypress.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index eb8f2e3..6926bc0 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: scientist-softserv/actions/setup-env@v0.0.13 with: tag: ${{ inputs.tag }} image_name: ${{ inputs.image_name }} diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml new file mode 100644 index 0000000..df5c1c0 --- /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: scientist-softserv/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..29a3ebd 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: scientist-softserv/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..7852d7c 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -32,7 +32,7 @@ jobs: steps: - id: setup name: Setup - uses: scientist-softserv/actions/setup-env@v0.0.11 + uses: scientist-softserv/actions/setup-env@v0.0.13 with: tag: ${{ inputs.tag }} token: ${{ secrets.CHECKOUT_TOKEN || secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index cc3a408..457d7a4 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: scientist-softserv/actions/setup-env@v0.0.13 with: tag: ${{ inputs.tag }} token: ${{ secrets.CHECKOUT_TOKEN || secrets.GITHUB_TOKEN }} From 4a540c997e1669a2211c50950b7e9e6da4f05b1c Mon Sep 17 00:00:00 2001 From: April Rieger Date: Mon, 18 Sep 2023 21:48:51 -0700 Subject: [PATCH 2/4] lint command back in effect --- .github/workflows/lint.yaml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 7852d7c..4bdc433 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 @@ -57,7 +65,8 @@ jobs: 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 From fa3a96eb366f687a78d292378a56a471a068a7a9 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Wed, 5 Feb 2025 11:55:24 -0800 Subject: [PATCH 3/4] v0.0.13 with docker-compose => docker compose --- .github/workflows/build.yaml | 2 +- .github/workflows/cypress.yaml | 10 +++++----- .github/workflows/lint.yaml | 8 ++++---- .github/workflows/test.yaml | 12 ++++++------ 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 6926bc0..fed2379 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -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 index df5c1c0..1ce4324 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -90,24 +90,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" @@ -117,7 +117,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 Cypress Tests id: run-specs diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 4bdc433..62101c2 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -5,7 +5,7 @@ on: lint_cmd: required: false type: string - default: docker-compose run web bundle exec rubocop --parallel --format progress + default: docker compose run web bundle exec rubocop --parallel --format progress subdir: default: '.' type: string @@ -20,7 +20,7 @@ on: lint_cmd: required: false type: string - default: docker-compose run web bundle exec rubocop --parallel --format progress + default: docker compose run web bundle exec rubocop --parallel --format progress subdir: default: '.' type: string @@ -55,11 +55,11 @@ 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: >- diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 457d7a4..6928386 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -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 From 264ba030cc90799902eec8f6e3a64954df9f8370 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Wed, 5 Feb 2025 11:56:29 -0800 Subject: [PATCH 4/4] scientist-softserv => notch8 --- .github/workflows/build.yaml | 2 +- .github/workflows/cypress.yaml | 2 +- .github/workflows/deploy.yaml | 2 +- .github/workflows/lint.yaml | 2 +- .github/workflows/test.yaml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index fed2379..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.13 + uses: notch8/actions/setup-env@v0.0.13 with: tag: ${{ inputs.tag }} image_name: ${{ inputs.image_name }} diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 1ce4324..b5aab25 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -70,7 +70,7 @@ jobs: steps: - id: setup name: Setup - uses: scientist-softserv/actions/setup-env@v0.0.13 + uses: notch8/actions/setup-env@v0.0.13 with: tag: ${{ inputs.tag }} token: ${{ secrets.CHECKOUT_TOKEN || secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 29a3ebd..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.13 + 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 62101c2..884eb1b 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -40,7 +40,7 @@ jobs: steps: - id: setup name: Setup - uses: scientist-softserv/actions/setup-env@v0.0.13 + uses: notch8/actions/setup-env@v0.0.13 with: tag: ${{ inputs.tag }} token: ${{ secrets.CHECKOUT_TOKEN || secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 6928386..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.13 + uses: notch8/actions/setup-env@v0.0.13 with: tag: ${{ inputs.tag }} token: ${{ secrets.CHECKOUT_TOKEN || secrets.GITHUB_TOKEN }}