From 133a46cabe4ac9d749b8c323939b9699b7c96ca7 Mon Sep 17 00:00:00 2001 From: Splines Date: Fri, 31 Mar 2023 20:43:34 +0200 Subject: [PATCH 1/7] Improve unit test workflow file - Update checkout action to version v3 - Use new docker layer caching version - Simplify commands to handle docker compose shell commands - Update codecov action --- .github/workflows/codecov.yml | 33 ----------------- .github/workflows/unit-tests.yml | 62 ++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 33 deletions(-) delete mode 100644 .github/workflows/codecov.yml create mode 100644 .github/workflows/unit-tests.yml diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml deleted file mode 100644 index 51add6871..000000000 --- a/.github/workflows/codecov.yml +++ /dev/null @@ -1,33 +0,0 @@ -on: [push] - -jobs: - rubocop: - runs-on: ubuntu-latest - name: A job to codecov report. - steps: - - uses: actions/checkout@v2 - with: - submodules: recursive - - run: docker-compose pull - working-directory: docker/development - - uses: satackey/action-docker-layer-caching@v0.0.11 - continue-on-error: true - - run: docker-compose build - working-directory: docker/development - - name: create db - working-directory: docker/development - run: | - docker-compose run --entrypoint="" mampf sh -c "RAILS_ENV=test rails db:create" - docker-compose run --entrypoint="" mampf sh -c "RAILS_ENV=test rails db:migrate" - docker-compose run --entrypoint="" mampf sh -c "RAILS_ENV=test rails db:test:prepare" - - name: Reindex sunspot - working-directory: docker/development - run: | - docker-compose run --entrypoint="" mampf sh -c "RAILS_ENV=test rake sunspot:reindex" - - name: Run tests - working-directory: docker/development - run: docker-compose run --entrypoint="" mampf sh -c "RAILS_ENV=test rails spec" - - name: Send test coverage report to codecov.io - uses: codecov/codecov-action@v2 - with: - directory: ./coverage diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 000000000..3ca90c5f9 --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,62 @@ +name: Unit tests + +on: + push: + branches: + - main + - mampf-next + - production + - experimental + pull_request: + +jobs: + unit-test-job: + name: Execute unit tests & upload to Codecov + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + submodules: recursive + + # Pull the latest image to build, and avoid caching pull-only images. + # (docker pull is faster than caching in most cases.) + - name: Pull docker images + run: docker compose pull + working-directory: docker/development + + # In this step, this action saves a list of existing images, + # the cache is created without them in the post run. + # It also restores the cache if it exists. + # https://github.com/jpribyl/action-docker-layer-caching + - name: Use Docker layer caching + uses: jpribyl/action-docker-layer-caching@v0.1.1 + continue-on-error: true + + - name: Build and start docker containers + working-directory: docker/development + run: | + docker compose up --build --detach + + - name: Create and prepare test database + working-directory: docker/development + run: | + docker compose exec mampf sh -c "RAILS_ENV=test rails db:create" + docker compose exec mampf sh -c "RAILS_ENV=test rails db:migrate" + docker compose exec mampf sh -c "RAILS_ENV=test rails db:test:prepare" + + - name: Reindex sunspot + working-directory: docker/development + run: | + docker compose exec mampf sh -c "RAILS_ENV=test rake sunspot:reindex" + + - name: Run unit tests + working-directory: docker/development + run: docker compose exec mampf sh -c "RAILS_ENV=test rails spec" + + - name: Send test coverage report to Codecov + uses: codecov/codecov-action@v3 + with: + directory: ./coverage + fail_ci_if_error: true + verbose: true From 02eae6556f671545433d92e6c14ae72c93af6357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Reinst=C3=A4dtler?= Date: Fri, 21 Apr 2023 21:02:50 +0200 Subject: [PATCH 2/7] fix tests --- .github/workflows/test-integration.yml | 4 +- .github/workflows/unit-tests.yml | 40 +++++------- docker/run_cypress_tests/Dockerfile | 6 +- docker/run_cypress_tests/docker-compose.yml | 1 + docker/run_tests/Dockerfile | 20 ------ docker/run_tests/docker-compose.yml | 67 --------------------- docker/run_tests/run_tests.sh | 18 ------ 7 files changed, 20 insertions(+), 136 deletions(-) delete mode 100644 docker/run_tests/Dockerfile delete mode 100644 docker/run_tests/docker-compose.yml delete mode 100755 docker/run_tests/run_tests.sh diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index e860bb4dd..97ef82173 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -29,7 +29,9 @@ jobs: - name: Build docker containers run: docker compose build working-directory: docker/run_cypress_tests - + - name: Create and migrate DB + run: docker compose run --entrypoint "" mampf sh -c "rake db:create db:migrate db:test:prepare" + working-directory: docker/run_cypress_tests - name: Run integration tests working-directory: docker/run_cypress_tests env: diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 3ca90c5f9..c6a7a8cf4 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -19,44 +19,32 @@ jobs: with: submodules: recursive - # Pull the latest image to build, and avoid caching pull-only images. - # (docker pull is faster than caching in most cases.) - name: Pull docker images - run: docker compose pull - working-directory: docker/development + run: docker compose pull --ignore-buildable + working-directory: docker/run_cypress_tests - # In this step, this action saves a list of existing images, - # the cache is created without them in the post run. - # It also restores the cache if it exists. - # https://github.com/jpribyl/action-docker-layer-caching - - name: Use Docker layer caching + - name: Use Docker layer caching # https://github.com/jpribyl/action-docker-layer-caching uses: jpribyl/action-docker-layer-caching@v0.1.1 continue-on-error: true - - name: Build and start docker containers - working-directory: docker/development - run: | - docker compose up --build --detach - - - name: Create and prepare test database - working-directory: docker/development - run: | - docker compose exec mampf sh -c "RAILS_ENV=test rails db:create" - docker compose exec mampf sh -c "RAILS_ENV=test rails db:migrate" - docker compose exec mampf sh -c "RAILS_ENV=test rails db:test:prepare" - + - name: Build docker containers + run: docker compose build + working-directory: docker/run_cypress_tests + - name: Create and migrate DB + run: docker compose run --entrypoint "" mampf sh -c "rake db:create db:migrate db:test:prepare" + working-directory: docker/run_cypress_tests - name: Reindex sunspot - working-directory: docker/development + working-directory: docker/run_cypress_tests run: | - docker compose exec mampf sh -c "RAILS_ENV=test rake sunspot:reindex" + docker compose run --entrypoint="" mampf sh -c "RAILS_ENV=test rake sunspot:reindex" - name: Run unit tests - working-directory: docker/development - run: docker compose exec mampf sh -c "RAILS_ENV=test rails spec" + working-directory: docker/run_cypress_tests + run: docker compose run --entrypoint="" mampf sh -c "RAILS_ENV=test rails spec" - name: Send test coverage report to Codecov uses: codecov/codecov-action@v3 with: - directory: ./coverage + files: coverage/coverage.xml fail_ci_if_error: true verbose: true diff --git a/docker/run_cypress_tests/Dockerfile b/docker/run_cypress_tests/Dockerfile index c02139e80..a21303cd3 100644 --- a/docker/run_cypress_tests/Dockerfile +++ b/docker/run_cypress_tests/Dockerfile @@ -25,13 +25,11 @@ RUN sed -i '/disable ghostscript format types/,+6d' /etc/ImageMagick-6/policy.xm WORKDIR /usr/src/app COPY ./Gemfile ./Gemfile.lock ./yarn.lock ./package.json /usr/src/app/ -RUN bundle install +RUN bundle install && \ + yarn install --production=false COPY --from=build-pdfcomprezzor /go/src/pdfcomprezzor.wasm /go/src/wasm_exec.js /usr/src/app/public/pdfcomprezzor/ COPY --from=build-pdfcomprezzor /go/src/pdfcomprezzor.wasm /go/src/wasm_exec.js / -COPY Gemfile Gemfile.lock package.json yarn.lock /usr/src/app/ -RUN bundle install && \ - yarn install --production=false COPY ./ /usr/src/app/ RUN RAILS_ENV=test TEST_DATABASE_ADAPTER=postgresql rake assets:precompile diff --git a/docker/run_cypress_tests/docker-compose.yml b/docker/run_cypress_tests/docker-compose.yml index dbc8bb99d..a6654f537 100644 --- a/docker/run_cypress_tests/docker-compose.yml +++ b/docker/run_cypress_tests/docker-compose.yml @@ -90,6 +90,7 @@ services: - ../../spec/cypress/fixtures:/cypress/fixtures:ro - ../../spec/cypress.config.js:/cypress.config.js:ro - ../../.git:/.git:ro + - ../../coverage:/coverage # cypress outputs are saved here (needed only locally) #- ../../cypress/videos:/cypress/videos #- ../../cypress/screenshots:/cypress/screenshots diff --git a/docker/run_tests/Dockerfile b/docker/run_tests/Dockerfile deleted file mode 100644 index fea9a9475..000000000 --- a/docker/run_tests/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM ruby:3.1.4 - -ENV RAILS_ENV=production - -EXPOSE 3000 - -ENTRYPOINT ["/usr/src/app/entrypoint.sh"] - -# https://github.com/nodesource/distributions#installation-instructions -RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \ - curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \ - apt-get update && apt-get install -y nodejs yarn ffmpeg imagemagick pdftk ghostscript sqlite3 shared-mime-info --no-install-recommends && rm -rf /var/lib/apt/lists/* && apt-get clean - -RUN groupadd -g 501 app && useradd -g 501 -u 501 -m -d /usr/src/app app -WORKDIR /usr/src/app -USER app - -COPY --chown=app:app ./Gemfile ./Gemfile.lock /usr/src/app/ -RUN bundle install -COPY --chown=app:app ./ /usr/src/app/ diff --git a/docker/run_tests/docker-compose.yml b/docker/run_tests/docker-compose.yml deleted file mode 100644 index d93f732b6..000000000 --- a/docker/run_tests/docker-compose.yml +++ /dev/null @@ -1,67 +0,0 @@ ---- -version: '3.4' -services: - redis: - image: "redis:6.2.6-alpine" - - solr: - image: "solr:8.11.1" - container_name: mampf_solr_test - volumes: - - type: bind - source: ../../solr/development/conf/ - target: /solrconfig/ - read_only: true - command: ["solr-precreate", "test", "/solrconfig"] - - db: - image: postgres:13 - container_name: mampf_db_test - environment: - - POSTGRES_USER=mampf - - POSTGRES_DB=mampf - - POSTGRES_HOST_AUTH_METHOD=trust - - mailcatcher: - restart: on-failure:10 - image: dockage/mailcatcher:latest - - mampf: - build: - context: ./../.. - dockerfile: docker/run_tests/Dockerfile - image: mampf:tests - container_name: mampf_mampf_test - entrypoint: ./docker/run_tests/run_tests.sh - environment: - RAILS_ENV: test - TEST_DATABASE_ADAPTER: postgresql - TEST_DATABASE_DATABASE: mampf - TEST_DATABASE_INTERACTIONS: interactions - TEST_DATABASE_USERNAME: mampf - TEST_DATABASE_HOST: db - TEST_DATABASE_PORT: 5432 - MAILSERVER: mailcatcher - FROM_ADDRESS: development@localhost - URL_HOST: localhost - PROJECT_EMAIL: project@localhost - PROJECT_NOTIFICATION_EMAIL: project+notification@localhost - ERROR_EMAIL: error@localhost - INSTANCE_PATH: mampf - REDIS_URL: redis://redis:6379/1 - SOLR_HOST: solr - SOLR_PORT: 8983 - SOLR_PATH: /solr/test - volumes: - - type: bind - source: ../../app/ - target: /usr/src/app/app/ - - type: bind - source: ../../spec/ - target: /usr/src/app/spec/ - - /usr/src/app/completed_initial_run - depends_on: - - db - - solr - - redis - - mailcatcher diff --git a/docker/run_tests/run_tests.sh b/docker/run_tests/run_tests.sh deleted file mode 100755 index 20bc2a040..000000000 --- a/docker/run_tests/run_tests.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -cd /usr/src/app -if ! [ -f completed_initial_run ] -then - echo 'Initialising mampf' &> >(tee -a /usr/src/app/log/initialisation.log) - echo running: bundle exec rails db:create &> >(tee -a /usr/src/app/log/initialisation.log) - bundle exec rails db:create > /usr/src/app/log/initialisation.log - echo running: bundle exec rails db:migrate &> >(tee -a /usr/src/app/log/initialisation.log) - bundle exec rails db:migrate > /usr/src/app/log/initialisation.log - echo running: bundle exec rails assets:precompile &> >(tee -a /usr/src/app/log/initialisation.log) - bundle exec rails assets:precompile &> /usr/src/app/log/initialisation.log - bundle exec rake sunspot:solr:reindex & - echo 'finished initialisation' &> >(tee -a /usr/src/app/log/initialisation.log) - touch completed_initial_run -fi -rm -f tmp/pids/server.pid -rspec From a8589b3fc6d8b6f8184ac537b9aae5b7fe5fad3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Reinst=C3=A4dtler?= Date: Fri, 21 Apr 2023 21:13:48 +0200 Subject: [PATCH 3/7] pass in token --- .github/workflows/unit-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index c6a7a8cf4..acfd18907 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -45,6 +45,7 @@ jobs: - name: Send test coverage report to Codecov uses: codecov/codecov-action@v3 with: + token: ${{ secrets.CODECOV_TOKEN }} files: coverage/coverage.xml fail_ci_if_error: true verbose: true From 2fb8fbb1f9b947374841be813cf7ac116b77dc2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Reinst=C3=A4dtler?= Date: Fri, 21 Apr 2023 22:23:56 +0200 Subject: [PATCH 4/7] right bind --- .github/workflows/unit-tests.yml | 4 +--- docker/run_cypress_tests/docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index acfd18907..ddcb572fc 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -41,11 +41,9 @@ jobs: - name: Run unit tests working-directory: docker/run_cypress_tests run: docker compose run --entrypoint="" mampf sh -c "RAILS_ENV=test rails spec" - - name: Send test coverage report to Codecov uses: codecov/codecov-action@v3 with: - token: ${{ secrets.CODECOV_TOKEN }} - files: coverage/coverage.xml + files: ./coverage/coverage.xml fail_ci_if_error: true verbose: true diff --git a/docker/run_cypress_tests/docker-compose.yml b/docker/run_cypress_tests/docker-compose.yml index a6654f537..70603e1cd 100644 --- a/docker/run_cypress_tests/docker-compose.yml +++ b/docker/run_cypress_tests/docker-compose.yml @@ -69,6 +69,7 @@ services: - type: bind source: ../../spec/ target: /usr/src/app/spec/ + - ../../coverage:/usr/src/app/coverage depends_on: - db - solr @@ -90,7 +91,6 @@ services: - ../../spec/cypress/fixtures:/cypress/fixtures:ro - ../../spec/cypress.config.js:/cypress.config.js:ro - ../../.git:/.git:ro - - ../../coverage:/coverage # cypress outputs are saved here (needed only locally) #- ../../cypress/videos:/cypress/videos #- ../../cypress/screenshots:/cypress/screenshots From 234676aece084556cc6b2abb0e69d9d37e84ea0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Reinst=C3=A4dtler?= Date: Fri, 21 Apr 2023 23:32:36 +0200 Subject: [PATCH 5/7] upgrade ruby for linter --- .github/workflows/linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 8f4484ac7..ff55d914e 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -9,7 +9,7 @@ jobs: - name: Set up Ruby 3 uses: ruby/setup-ruby@v1 with: - ruby-version: 3.1.2 + ruby-version: 3.1.4 - name: Install gems # usual step to install the gems. run: | bin/bundle config path vendor/bundle From 9808094d3847b9910c4db7b61c7548cf96b8fa4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Reinst=C3=A4dtler?= Date: Sat, 22 Apr 2023 00:41:27 +0200 Subject: [PATCH 6/7] Remove empty test suites, fix css selector based tests --- spec/cypress/e2e/simple_spec.cy.js | 10 ---------- spec/cypress/e2e/testing_spec.cy.js | 22 ---------------------- spec/cypress/e2e/tutorials_spec.cy.js | 12 ++++++------ spec/cypress/e2e/watchlists_spec.cy.js | 3 +-- 4 files changed, 7 insertions(+), 40 deletions(-) delete mode 100644 spec/cypress/e2e/simple_spec.cy.js delete mode 100644 spec/cypress/e2e/testing_spec.cy.js diff --git a/spec/cypress/e2e/simple_spec.cy.js b/spec/cypress/e2e/simple_spec.cy.js deleted file mode 100644 index f45101e10..000000000 --- a/spec/cypress/e2e/simple_spec.cy.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('My First Test', function() { - it('visit root', function() { - - // Visit the application under test - cy.visit('/'); - - cy.contains("MaMpf"); - cy.screenshot(); - }); - }); diff --git a/spec/cypress/e2e/testing_spec.cy.js b/spec/cypress/e2e/testing_spec.cy.js deleted file mode 100644 index bd57f3fa6..000000000 --- a/spec/cypress/e2e/testing_spec.cy.js +++ /dev/null @@ -1,22 +0,0 @@ -describe("Testing", () => { - - beforeEach(() => { - cy.app("clean"); - }); - describe("Set up test environment", () => { - beforeEach(() => { - cy.app("clean"); - cy.appScenario("admin"); - cy.visit("/users/sign_in"); - cy.get('input[type="email"]').type("administrator@mampf.edu"); - cy.get('input[type="password"]').type("test123456"); - cy.get('input[type="submit"]').click(); - }); - it("can view tutorials", () => { - cy.appFactories([ - ]).then((lectures) => { - - }); - }); - }); -}); \ No newline at end of file diff --git a/spec/cypress/e2e/tutorials_spec.cy.js b/spec/cypress/e2e/tutorials_spec.cy.js index ba5ca9e94..da2213d1b 100644 --- a/spec/cypress/e2e/tutorials_spec.cy.js +++ b/spec/cypress/e2e/tutorials_spec.cy.js @@ -43,9 +43,9 @@ describe("Tutorials", () => { cy.visit(`lectures/${lectures[0].id}`); cy.contains("Tutorien").should("exist"); cy.contains("Tutorien").click(); - cy.get('.col-sm-9 > .dropdown > .btn').contains("Tutorien").should("exist"); - cy.get('.col-sm-9 > .dropdown > .btn').contains("Tutorien").click(); - cy.get('.col-sm-9 > .dropdown > .dropdown-menu > .dropdown-item').contains(lectures[2].title).click(); + cy.get('main > .dropdown > .btn').contains("Tutorien").should("exist"); + cy.get('main > .dropdown > .btn').contains("Tutorien").click(); + cy.get('main > .dropdown > .dropdown-menu > .dropdown-item').contains(lectures[2].title).click(); cy.reload(); cy.contains("Übersicht").should("exist"); }); @@ -87,9 +87,9 @@ describe("Tutorials", () => { cy.visit(`lectures/${lectures[0].id}`); cy.contains("Tutorien").should("exist"); cy.contains("Tutorien").click(); - cy.contains("Übersicht").should("exist"); - cy.contains("Übersicht").click(); - cy.get('.col-sm-9 > .dropdown > .btn').contains("Tutorien").click(); + cy.get('main').contains("Übersicht").should("exist"); + cy.get('main').contains("Übersicht").click(); + cy.get('main > .dropdown > .btn').contains("Tutorien").click(); cy.contains('Eigene Tutorien').should('exist'); cy.contains('Sonstige Tutorien').should('exist'); cy.get('.dropdown-menu').contains(lectures[2].title).should("exist"); diff --git a/spec/cypress/e2e/watchlists_spec.cy.js b/spec/cypress/e2e/watchlists_spec.cy.js index 259ca0271..f9d773671 100644 --- a/spec/cypress/e2e/watchlists_spec.cy.js +++ b/spec/cypress/e2e/watchlists_spec.cy.js @@ -88,8 +88,7 @@ describe("Watchlists", () => { ] ]).then((data) => { cy.visit('lectures/1'); - cy.get('.nav > :nth-child(6) > .nav-link').click(); - cy.get('.fa-bookmark').click(); + cy.get('#watchlistsIcon').click(); cy.get('#watchlistButton').contains(`${data[0].name}`).should('exist'); }); }); From 36d856d2313b98963ec1b7004dcec09438cd21f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Reinst=C3=A4dtler?= Date: Sat, 22 Apr 2023 13:28:24 +0200 Subject: [PATCH 7/7] Merge test jobs to reuse cache. --- .../{test-integration.yml => tests.yml} | 43 +++++++++++++++- .github/workflows/unit-tests.yml | 49 ------------------- 2 files changed, 42 insertions(+), 50 deletions(-) rename .github/workflows/{test-integration.yml => tests.yml} (54%) delete mode 100644 .github/workflows/unit-tests.yml diff --git a/.github/workflows/test-integration.yml b/.github/workflows/tests.yml similarity index 54% rename from .github/workflows/test-integration.yml rename to .github/workflows/tests.yml index 97ef82173..ac0fb3280 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/tests.yml @@ -1,4 +1,5 @@ -name: Integration tests +name: Tests + on: push: branches: @@ -7,11 +8,50 @@ on: - production - experimental pull_request: + jobs: + unit-test-job: + name: Execute unit tests & upload to Codecov + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Pull docker images + run: docker compose pull --ignore-buildable + working-directory: docker/run_cypress_tests + + - name: Use Docker layer caching # https://github.com/jpribyl/action-docker-layer-caching + uses: jpribyl/action-docker-layer-caching@v0.1.1 + continue-on-error: true + + - name: Build docker containers + run: docker compose build + working-directory: docker/run_cypress_tests + - name: Create and migrate DB + run: docker compose run --entrypoint "" mampf sh -c "rake db:create db:migrate db:test:prepare" + working-directory: docker/run_cypress_tests + - name: Reindex sunspot + working-directory: docker/run_cypress_tests + run: | + docker compose run --entrypoint="" mampf sh -c "RAILS_ENV=test rake sunspot:reindex" + + - name: Run unit tests + working-directory: docker/run_cypress_tests + run: docker compose run --entrypoint="" mampf sh -c "RAILS_ENV=test rails spec" + - name: Send test coverage report to Codecov + uses: codecov/codecov-action@v3 + with: + files: ./coverage/coverage.xml + fail_ci_if_error: true + verbose: true e2e-test-job: name: Run E2E tests & upload results to Cypress runs-on: ubuntu-latest timeout-minutes: 30 + needs: unit-test-job steps: - name: Checkout code uses: actions/checkout@v3 @@ -41,3 +81,4 @@ jobs: # pass GitHub token to allow accurately detecting a build vs a re-run build GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: docker compose run -e GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} --entrypoint="" cypress_runner sh -c "while ! curl http://mampf:3000 ; do echo waiting for MaMpf to come online at http://mampf:3000; sleep 3; done; cypress run --record --key ${{ secrets.CYPRESS_RECORD_KEY }}" + diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml deleted file mode 100644 index ddcb572fc..000000000 --- a/.github/workflows/unit-tests.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Unit tests - -on: - push: - branches: - - main - - mampf-next - - production - - experimental - pull_request: - -jobs: - unit-test-job: - name: Execute unit tests & upload to Codecov - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - with: - submodules: recursive - - - name: Pull docker images - run: docker compose pull --ignore-buildable - working-directory: docker/run_cypress_tests - - - name: Use Docker layer caching # https://github.com/jpribyl/action-docker-layer-caching - uses: jpribyl/action-docker-layer-caching@v0.1.1 - continue-on-error: true - - - name: Build docker containers - run: docker compose build - working-directory: docker/run_cypress_tests - - name: Create and migrate DB - run: docker compose run --entrypoint "" mampf sh -c "rake db:create db:migrate db:test:prepare" - working-directory: docker/run_cypress_tests - - name: Reindex sunspot - working-directory: docker/run_cypress_tests - run: | - docker compose run --entrypoint="" mampf sh -c "RAILS_ENV=test rake sunspot:reindex" - - - name: Run unit tests - working-directory: docker/run_cypress_tests - run: docker compose run --entrypoint="" mampf sh -c "RAILS_ENV=test rails spec" - - name: Send test coverage report to Codecov - uses: codecov/codecov-action@v3 - with: - files: ./coverage/coverage.xml - fail_ci_if_error: true - verbose: true