-
-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #746 from centerofci/integ_test_playwright_python
E2E Integration test environment setup
- Loading branch information
Showing
10 changed files
with
268 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
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-e2e-tests- | ||
- name: Copy env file | ||
run: cp .env.example .env | ||
|
||
- name: Use integ test dockerfile | ||
run: rm Dockerfile && mv Dockerfile.integ-tests Dockerfile | ||
|
||
# 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 integration_tests/ | ||
|
||
- uses: actions/upload-artifact@v2 | ||
if: ${{ failure() || success() }} | ||
with: | ||
name: Recordings | ||
path: ${{ github.workspace }}/videos/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
FROM python:3.9-buster | ||
|
||
# Add mathesar user | ||
ENV PYTHONUNBUFFERED=1 | ||
ENV DOCKERIZE_VERSION v0.6.1 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
FROM buildpack-deps:focal | ||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
|
||
# Install python | ||
# Some of this is ported from docker file for python-3.9: | ||
# https://github.com/docker-library/python/blob/33751272d8171cece37c59180c049ab77cf9c837/3.9/buster/Dockerfile | ||
|
||
# ensure local python is preferred over distribution python | ||
ENV PATH /usr/local/bin:$PATH | ||
|
||
# http://bugs.python.org/issue19846 | ||
# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK. | ||
ENV LANG C.UTF-8 | ||
|
||
# Download node14 source | ||
RUN curl -fsSL https://deb.nodesource.com/setup_14.x | bash - | ||
|
||
# extra dependencies (over what buildpack-deps already includes) | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
libbluetooth-dev \ | ||
tk-dev \ | ||
uuid-dev \ | ||
sudo \ | ||
nodejs \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
ENV GPG_KEY E3FF2839C048B25C084DEBE9B26995E310250568 | ||
ENV PYTHON_VERSION 3.9.8 | ||
|
||
RUN set -ex \ | ||
\ | ||
&& wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \ | ||
&& wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \ | ||
&& export GNUPGHOME="$(mktemp -d)" \ | ||
&& gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY" \ | ||
&& gpg --batch --verify python.tar.xz.asc python.tar.xz \ | ||
&& { command -v gpgconf > /dev/null && gpgconf --kill all || :; } \ | ||
&& rm -rf "$GNUPGHOME" python.tar.xz.asc \ | ||
&& mkdir -p /usr/src/python \ | ||
&& tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz \ | ||
&& rm python.tar.xz \ | ||
\ | ||
&& cd /usr/src/python \ | ||
&& gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \ | ||
&& ./configure \ | ||
--build="$gnuArch" \ | ||
--enable-loadable-sqlite-extensions \ | ||
--enable-optimizations \ | ||
--enable-option-checking=fatal \ | ||
--enable-shared \ | ||
--with-system-expat \ | ||
--with-system-ffi \ | ||
--without-ensurepip \ | ||
&& make -j "$(nproc)" \ | ||
&& make install \ | ||
&& rm -rf /usr/src/python \ | ||
\ | ||
&& find /usr/local -depth \ | ||
\( \ | ||
\( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ | ||
-o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name '*.a' \) \) \ | ||
\) -exec rm -rf '{}' + \ | ||
\ | ||
&& ldconfig \ | ||
\ | ||
&& python3 --version | ||
|
||
# make some useful symlinks that are expected to exist | ||
RUN cd /usr/local/bin \ | ||
&& ln -s idle3 idle \ | ||
&& ln -s pydoc3 pydoc \ | ||
&& ln -s python3 python \ | ||
&& ln -s python3-config python-config | ||
|
||
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'" | ||
ENV PYTHON_PIP_VERSION 21.2.4 | ||
# https://github.com/docker-library/python/issues/365 | ||
ENV PYTHON_SETUPTOOLS_VERSION 57.5.0 | ||
# https://github.com/pypa/get-pip | ||
ENV PYTHON_GET_PIP_URL https://github.com/pypa/get-pip/raw/d781367b97acf0ece7e9e304bf281e99b618bf10/public/get-pip.py | ||
ENV PYTHON_GET_PIP_SHA256 01249aa3e58ffb3e1686b7141b4e9aac4d398ef4ac3012ed9dff8dd9f685ffe0 | ||
|
||
RUN set -ex; \ | ||
\ | ||
wget -O get-pip.py "$PYTHON_GET_PIP_URL"; \ | ||
echo "$PYTHON_GET_PIP_SHA256 *get-pip.py" | sha256sum --check --strict -; \ | ||
\ | ||
python get-pip.py \ | ||
--disable-pip-version-check \ | ||
--no-cache-dir \ | ||
"pip==$PYTHON_PIP_VERSION" \ | ||
"setuptools==$PYTHON_SETUPTOOLS_VERSION" \ | ||
; \ | ||
pip --version; \ | ||
\ | ||
find /usr/local -depth \ | ||
\( \ | ||
\( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ | ||
-o \ | ||
\( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \ | ||
\) -exec rm -rf '{}' +; \ | ||
rm -f get-pip.py | ||
|
||
ENV PYTHONUNBUFFERED=1 | ||
ENV DOCKERIZE_VERSION v0.6.1 | ||
|
||
# Install dockerize | ||
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ | ||
&& tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ | ||
&& rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz | ||
|
||
RUN pip install playwright==1.16.1 | ||
RUN pip install pytest-playwright==0.2.2 | ||
RUN playwright install | ||
RUN playwright install-deps | ||
|
||
# Change work directory | ||
WORKDIR /code/ | ||
|
||
COPY requirements.txt . | ||
COPY requirements-dev.txt . | ||
|
||
RUN pip install -r requirements.txt --force-reinstall sqlalchemy-filters | ||
RUN pip install -r requirements-dev.txt | ||
COPY . . | ||
|
||
RUN sudo npm install -g npm-force-resolutions | ||
RUN cd mathesar_ui && npm install --unsafe-perm && npm run build | ||
|
||
EXPOSE 8000 3000 6006 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Component: python3.9 docker image source file | ||
Copyright: 2014 Docker, Inc | ||
License: MIT | ||
License Text: https://github.com/docker-library/python/blob/33751272d8171cece37c59180c049ab77cf9c837/LICENSE | ||
Derivative files: | ||
/Dockerfile.integ-tests | ||
|
||
================================= | ||
BEGIN of license | ||
================================= | ||
|
||
The MIT License (MIT) | ||
|
||
Copyright (c) 2014 Docker, Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included | ||
in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
================================= | ||
END of license | ||
================================= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters