Skip to content

Commit

Permalink
Integrate Gitpod (#290)
Browse files Browse the repository at this point in the history
Co-authored-by: Carlos Kidman <carlos@qap.dev>
  • Loading branch information
ElSnoMan and Carlos Kidman authored Oct 21, 2022
1 parent 40eb9b6 commit 05d645a
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 1 deletion.
51 changes: 51 additions & 0 deletions .gitpod.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
FROM gitpod/workspace-full-vnc

USER root

# RUN apt-get update -qqy && apt-get install -y wget curl gnupg2

# So we can install browsers and browser drivers later
RUN wget https://packages.microsoft.com/config/ubuntu/21.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
&& dpkg -i packages-microsoft-prod.deb && rm packages-microsoft-prod.deb
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
RUN mkdir -p /home/gitpod/selenium /var/run/supervisor /var/log/supervisor && \
chmod -R 777 /var/run/supervisor /var/log/supervisor

ENV DEBIAN_FRONTEND=noninteractive

# Browsers
RUN apt-get update -qqy && \
apt-get -qy install google-chrome-stable firefox && \
rm -rf /var/lib/apt/lists/* /var/cache/apt/*

# Browser Drivers
RUN CHROME_MAJOR_VERSION=$(google-chrome --version | sed -E "s/.* ([0-9]+)(\.[0-9]+){3}.*/\1/") \
&& CHROME_DRIVER_VERSION=$(wget --no-verbose -O - "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_MAJOR_VERSION}") \
&& echo "Using ChromeDriver version: "$CHROME_DRIVER_VERSION \
&& wget --no-verbose -O /tmp/chromedriver_linux64.zip https://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip \
&& rm -rf /home/gitpod/selenium/chromedriver \
&& unzip /tmp/chromedriver_linux64.zip -d /home/gitpod/selenium \
&& rm /tmp/chromedriver_linux64.zip \
&& mv /home/gitpod/selenium/chromedriver /home/gitpod/selenium/chromedriver-$CHROME_DRIVER_VERSION \
&& chmod 755 /home/gitpod/selenium/chromedriver-$CHROME_DRIVER_VERSION \
&& sudo ln -fs /home/gitpod/selenium/chromedriver-$CHROME_DRIVER_VERSION /usr/bin/chromedriver
RUN GK_VERSION="0.31.0" \
&& echo "Using GeckoDriver version: "$GK_VERSION \
&& wget --no-verbose -O /tmp/geckodriver.tar.gz https://github.com/mozilla/geckodriver/releases/download/v$GK_VERSION/geckodriver-v$GK_VERSION-linux64.tar.gz \
&& rm -rf /home/gitpod/selenium/geckodriver \
&& tar -C /home/gitpod/selenium -zxf /tmp/geckodriver.tar.gz \
&& rm /tmp/geckodriver.tar.gz \
&& mv /home/gitpod/selenium/geckodriver /home/gitpod/selenium/geckodriver-$GK_VERSION \
&& chmod 755 /home/gitpod/selenium/geckodriver-$GK_VERSION \
&& ln -fs /home/gitpod/selenium/geckodriver-$GK_VERSION /usr/bin/geckodriver

# To run browser tests
ENV DISPLAY :99.0
ENV DISPLAY_NUM 99
ENV SCREEN_WIDTH 1360
ENV SCREEN_HEIGHT 1020
ENV SCREEN_DEPTH 24
ENV SCREEN_DPI 96
ENV VNC_PORT 5900
ENV NO_VNC_PORT 7900
22 changes: 22 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
vscode:
extensions:
- ms-python.python
- bungcip.better-toml
- PKief.material-icon-theme

image:
file: .gitpod.Dockerfile

tasks:
- name: "Setup"
command: |
git config --global pull.rebase false
pip install poetry
poetry install
ports:
- port: 5900
onOpen: ignore
- port: 6080
onOpen: open-browser
- port: 10000
onOpen: ignore
17 changes: 16 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
{
"python.testing.pytestArgs": ["tests"],
"python.defaultInterpreterPath": ".venv/bin/python",
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
"python.testing.pytestEnabled": true,
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"**/*.crswap": true,
"**/*.pytest_cache": true,
"**/*__pycache__": true
},
"python.linting.enabled": true,
"python.formatting.provider": "black",
"workbench.iconTheme": "material-icon-theme"
}
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Pylenium: Easy Python Web Test Automation

- [The Mission](#the-mission-is-simple)
- [Test Example](#test-example)
- [Purpose](#purpose)
- [Quickstart](#quick-start)
- [1. Install](#1-install-pyleniumio)
- [2. Initialize](#2-initialize-pylenium)
- [3. Write a Test](#3-write-a-test)
- [4. Run the Test](#4-run-the-test)
- [Contribute](#contribute)


## The mission is simple

> Bring the best of Selenium, Cypress and Python into one package.
Expand Down Expand Up @@ -143,3 +154,21 @@ python -m pytest tests/test_google.py
```

You're all set! You should see the browser open and complete the commands we had in the test :\)

## Contribute

Pylenium uses [Gitpod](https://gitpod.io/) to make it easy to work on it from the _desktop or browser_ without having to worry about the setup like having the correct Python version installed after cloning the repo.

> 💡 With a single click, you can open the repo in your browser, make your changes, then submit a pull request!
0. If you're new to Gitpod, check out their [Getting Started](https://www.gitpod.io/docs/introduction/getting-started) docs to see how to use it
1. Visit [Pylenium's repo](https://github.com/ElSnoMan/pyleniumio) and click the `Gitpod` button to open the repo in a VS Code browser window
2. Wait for Gitpod to setup the project. You'll see things get setup from the various `.gitpod*` files at the Project Root
3. Once complete, create a new branch and start making your changes
4. When ready, submit a Pull Request!
5. Reviewers will see your CI pipeline and even be able to open your Gitpod instance if needed - making collaboration much easier
6. Gitpod instances are ephemeral, so you can create, share, and delete them as needed

> 🧪 By default, UI tests executed in Gitpod are headless. If you'd like to see UI tests run, open port `6080` from the bottom right corner of VS Code.
For more details and other ways to contribute to Pylenium, visit the [CONTRIBUTING.md](/CONTRIBUTING.md) doc 👀
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[pytest]
; Configuring pytest
; More info: https://docs.pytest.org/en/6.2.x/customize.html
testpaths =
tests

;Logging
; DATE FORMAT EXAMPLE: %Y-%m-%d %H:%M:%S
Expand Down

0 comments on commit 05d645a

Please sign in to comment.