Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests #472

Merged
merged 7 commits into from
Apr 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions .github/workflows/codecov.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 0 additions & 41 deletions .github/workflows/test-integration.yml

This file was deleted.

84 changes: 84 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename the folder to docker/run_tests as it is not specifically for Cypress tests anymore.


- 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
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: Run integration tests
working-directory: docker/run_cypress_tests
env:
# pass the Dashboard record key as an environment variable
CYPRESS_baseUrl: http://mampf:3000
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# 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 }}"

6 changes: 2 additions & 4 deletions docker/run_cypress_tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions docker/run_cypress_tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ services:
- type: bind
source: ../../spec/
target: /usr/src/app/spec/
- ../../coverage:/usr/src/app/coverage
depends_on:
- db
- solr
Expand Down
20 changes: 0 additions & 20 deletions docker/run_tests/Dockerfile

This file was deleted.

67 changes: 0 additions & 67 deletions docker/run_tests/docker-compose.yml

This file was deleted.

18 changes: 0 additions & 18 deletions docker/run_tests/run_tests.sh

This file was deleted.

10 changes: 0 additions & 10 deletions spec/cypress/e2e/simple_spec.cy.js

This file was deleted.

22 changes: 0 additions & 22 deletions spec/cypress/e2e/testing_spec.cy.js

This file was deleted.

12 changes: 6 additions & 6 deletions spec/cypress/e2e/tutorials_spec.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
Expand Down Expand Up @@ -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");
Expand Down
3 changes: 1 addition & 2 deletions spec/cypress/e2e/watchlists_spec.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
Expand Down