-
-
Notifications
You must be signed in to change notification settings - Fork 315
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
Changes from 36 commits
f11f10f
226c4a6
668e67c
88488a0
71817c0
07cd5b8
007f883
608e452
bb6b7f0
3382926
11bf8fa
deb7f46
5efcfe0
edd7854
94e7827
2cb167b
063cb7a
12ef48d
e772b0a
4c67223
954901c
49eb096
a710cfc
2a07f16
64352b8
649e904
f26ca02
6395b19
ff3e5cf
62439b2
b7657c3
ba894a2
04b970b
609dd49
1db88d1
cfa53d9
e5bfc70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,14 @@ jobs: | |
cd .github/actions/project_update/ | ||
python project_update.py ${{ github.event.issue.node_id }} --status Blocked | ||
|
||
- name: Update Waiting issues | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pavish This change seems like a bad merge. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kgodey This was added in 12ef48d, which was mentioned here as harmless: #746 (comment) There wasn't another step with the same name. Should I go ahead and remove this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I got confused and forgot that I added it in this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. Updated in e5bfc70 |
||
if: "${{ contains(github.event.issue.labels.*.name, 'status: waiting') }}" | ||
env: | ||
MATHESAR_ORG_GITHUB_TOKEN: ${{secrets.MATHESAR_ORG_GITHUB_TOKEN}} | ||
run: | | ||
cd .github/actions/project_update/ | ||
python project_update.py ${{ github.event.issue.node_id }} --status Blocked | ||
|
||
- name: Update Ready issues | ||
if: "${{ contains(github.event.issue.labels.*.name, 'status: ready') }}" | ||
env: | ||
|
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 | ||
|
||
|
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 |
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 | ||
================================= |
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() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.