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

E2E Integration test environment setup #746

Merged
merged 37 commits into from
Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f11f10f
Add playwright to dev requirements
pavish Oct 21, 2021
226c4a6
Set base docker image to a temp custom prebuilt image with ubuntu+pyt…
pavish Oct 22, 2021
668e67c
Set container names in docker compose
pavish Oct 22, 2021
88488a0
Remove playwright from requirements file
pavish Oct 22, 2021
71817c0
Fix container name in documents and tests
pavish Oct 22, 2021
07cd5b8
Merge branch 'master' of https://github.com/centerofci/mathesar into …
pavish Oct 22, 2021
007f883
Github action to run e2e tests
pavish Oct 22, 2021
608e452
Sleep for 60 seconds to wait for server to be up, handle migrations
pavish Oct 22, 2021
bb6b7f0
Merge branch 'master' into integ_test_playwright_python
pavish Oct 25, 2021
3382926
Skip confirmation during db creation in github actions
pavish Oct 25, 2021
11bf8fa
Log page content to debug failing of test cases in GH workflow
pavish Oct 25, 2021
deb7f46
Record video artifacts to help debug failing tests
pavish Oct 25, 2021
5efcfe0
Merge branch 'master' into integ_test_playwright_python
pavish Oct 26, 2021
edd7854
Print DB name in installation message.
kgodey Oct 26, 2021
94e7827
Remove copy of env file.
kgodey Oct 26, 2021
2cb167b
Change cache key.
kgodey Oct 26, 2021
063cb7a
Revert "Remove copy of env file."
kgodey Oct 26, 2021
12ef48d
Update status: waiting issues automatically
kgodey Oct 30, 2021
e772b0a
Merge branch 'fix_install_script' of https://github.com/centerofci/ma…
pavish Nov 1, 2021
4c67223
Merge branch 'master' into integ_test_playwright_python
kgodey Nov 1, 2021
954901c
Merge branch 'master' of https://github.com/centerofci/mathesar into …
pavish Nov 5, 2021
49eb096
Merge branch 'master' of https://github.com/centerofci/mathesar into …
pavish Nov 8, 2021
a710cfc
Merge branch 'master' of https://github.com/centerofci/mathesar into …
pavish Nov 8, 2021
2a07f16
Merge branch 'master' of https://github.com/centerofci/mathesar into …
pavish Nov 9, 2021
64352b8
Merge branch 'master' of https://github.com/centerofci/mathesar into …
pavish Nov 12, 2021
649e904
Merge branch 'master' of https://github.com/centerofci/mathesar into …
pavish Nov 15, 2021
f26ca02
Reverting dockerfile changes
pavish Nov 16, 2021
6395b19
Run pytest on mathesar and db modules
pavish Nov 16, 2021
ff3e5cf
Dockerfile for integration tests
pavish Nov 16, 2021
62439b2
Use integ test dockerfile for running e2e tests
pavish Nov 16, 2021
b7657c3
Merge branch 'master' of https://github.com/centerofci/mathesar into …
pavish Nov 16, 2021
ba894a2
Specify different path for artifacts for each workflow
pavish Nov 16, 2021
04b970b
Documentation for running E2E tests
pavish Nov 16, 2021
609dd49
chore(docs): update TOC
pavish Nov 16, 2021
1db88d1
Add license of python3.9 dockerfile used as reference
pavish Nov 16, 2021
cfa53d9
Merge branch 'integ_test_playwright_python' of https://github.com/cen…
pavish Nov 16, 2021
e5bfc70
Removing conflicting step to set waiting status on issues
pavish Nov 16, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/run-e2e-integ-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Run E2E integration tests
on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
# We only want to run on external PRs, since internal PRs are covered by "push"
# This prevents this from running twice on internal PRs
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
steps:
- uses: actions/checkout@v2

# 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.
- uses: satackey/action-docker-layer-caching@v0.0.11
# Ignore the failure of a step and avoid terminating the job.
continue-on-error: true
with:
key: mathesar-docker-cache-integ-tests-{hash}
restore-keys: |
mathesar-docker-cache-integ-tests-

- name: Copy env file
run: cp .env.example .env

# The code is checked out under uid 1001 - reset this to 1000 for the
# container to run tests successfully
- name: Fix permissions
run: sudo chown -R 1000:1000 .

- name: Build the stack
run: docker-compose up --build -d

- name: Sleep for 60 seconds
run: sleep 60s
shell: bash

# TODO: This needs to be handled inside the tests
- name: Run migrations
run: docker exec mathesar_service python manage.py migrate

- name: Run type installation
run: docker exec mathesar_service python install.py --skip-confirm

- name: Run integ tests with pytest
run: docker exec mathesar_service pytest --browser chromium --browser webkit --browser firefox tests/

- uses: actions/upload-artifact@v2
if: ${{ failure() || success() }}
with:
name: Recordings
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should use the timestamp in the name of the artifact.

Copy link
Member Author

Choose a reason for hiding this comment

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

We may want to upload an artifact in a job and download in another job, time stamping the name would make it hard for us to do that.

I do understand the concern where multiple workflows could overwrite the artifact. So, I've modified the action to use different paths for each workflow in ba894a2. Let me know if this looks good.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good.

path: videos/
2 changes: 1 addition & 1 deletion .github/workflows/run-pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ jobs:
run: docker-compose up --build -d

- name: Run tests with pytest
run: docker exec mathesar_service pytest
run: docker exec mathesar_service pytest mathesar/
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add db/ to this, otherwise we're no longer running tests in the db module.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've added it. Thanks.

19 changes: 1 addition & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
FROM python:3.9-buster

# These should be run as a single command to avoid caching issues.
# See: http://lenguyenthedat.com/docker-cache/
RUN apt update && apt install -y sudo

# Add mathesar user
ENV PYTHONUNBUFFERED=1
ENV DOCKERIZE_VERSION v0.6.1

# Install dockerize
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz

# Install node
RUN curl -fsSL https://deb.nodesource.com/setup_14.x | bash -
RUN apt install -y nodejs
FROM pavish73/mathesar-base:latest-all

# Change work directory
WORKDIR /code/
Expand Down
4 changes: 2 additions & 2 deletions mathesar_ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ If you want to add or remove packages, or bascially run any npm action, **always
You can connect to the container and open the ui folder by running:

```bash
docker exec -it mathesar_service_1 /bin/bash
docker exec -it mathesar_service /bin/bash
cd mathesar_ui
```

Expand All @@ -71,7 +71,7 @@ For guidelines on component development, refer [README of components](https://gi
You can start storybook in dev mode by connecting to the container and then running `npm run storybook`:

```bash
docker exec -it mathesar_service_1 /bin/bash
docker exec -it mathesar_service /bin/bash

root@c273da65c52d:/code/mathesar_ui$ cd mathesar_ui && npm run storybook
```
Expand Down
5 changes: 3 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ env =
DEBUG=False
SECRET_KEY=hdC7qKjaFXNBjJ4heMMlOMrP-6j1-OvZpPf87DAXyaw
DJANGO_DATABASE_KEY=default
DJANGO_DATABASE_URL=postgres://mathesar:mathesar@db:5432/mathesar_django
MATHESAR_DATABASES=(mathesar_db_test|postgres://mathesar:mathesar@db:5432/mathesar_db_test)
DJANGO_DATABASE_URL=postgres://mathesar:mathesar@mathesar_db:5432/mathesar_django
MATHESAR_DATABASES=(mathesar_db_test|postgres://mathesar:mathesar@mathesar_db:5432/mathesar_db_test)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the usual way is for the hostname to be the header of the docker-compose.yml file section (so db in this case). I wonder if the version of docker you (we) have locally handles that smoothly, but the version on Github doesn't. Maybe try reverting this change.

Copy link
Member Author

Choose a reason for hiding this comment

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

It was db but after the workflow failed, I updated it to mathesar_db to check if that'll make a change. The result was the same. I could try changing it back again.

TEST=True
MODE=DEVELOPMENT
6 changes: 6 additions & 0 deletions tests/test_base_page.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def test_base_page(browser):
context = browser.new_context(record_video_dir='videos/')
page = context.new_page()
page.goto('http://localhost:8000')
assert page.inner_text('h1') == 'Welcome to Mathesar!'
context.close()