Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
17c6a8b
Add Github Action for running Selenium tests on Chrome
lenacohen Apr 1, 2025
c9dc565
Run on pushes to this feature branch for testing purposes
lenacohen Apr 1, 2025
176136e
Remove dot command to source run_travis script
lenacohen Apr 1, 2025
9838602
Debug: check for chromedriver in run_travis.sh
lenacohen Apr 1, 2025
78fc553
Try adding unique --user-data-dir option to Chrome webdriver
lenacohen Apr 1, 2025
21a47ad
Switch to tempfile.TemporaryDirectory()
lenacohen Apr 1, 2025
3cbd0d8
Add matrix for multiple browser jobs and test Firefox and Edge Beta i…
lenacohen Apr 1, 2025
ea7917d
Add debugging print statements to Firefox install, and add explicit u…
lenacohen Apr 1, 2025
aae8332
Check for and remove snap package
lenacohen Apr 1, 2025
b9e968b
Switch to ubuntu 22.04 to match Travis jammy distro
lenacohen Apr 1, 2025
467c45a
Try existing github actions for firefox and geckodriver setup
lenacohen Apr 2, 2025
8262f29
Fix combined step error
lenacohen Apr 2, 2025
34607fd
Add lint job
lenacohen Apr 2, 2025
56571bd
Temporarily remove Edge tests
lenacohen Apr 2, 2025
771cb7c
Try headless option and enable trace logging for geckodriver
lenacohen Apr 2, 2025
c6a6c1b
Add jobs for other versions of Firefox
lenacohen Apr 3, 2025
0ae7159
Try Firefox tests without headless argument
lenacohen Apr 3, 2025
5cda133
Add Edge Beta tests
lenacohen Apr 3, 2025
912f09e
Try adding --edge-skip-compat-layer-relaunch flag
lenacohen Apr 3, 2025
bf922a6
Try making edge headless
lenacohen Apr 3, 2025
57db217
Add Chrome stable and beta tests
lenacohen Apr 3, 2025
32e505a
Use headless Chrome
lenacohen Apr 3, 2025
337601d
Check installed path
lenacohen Apr 3, 2025
162c25b
Only verify Chrome Installation for Chrome
lenacohen Apr 3, 2025
f6536b2
Add missing step id
lenacohen Apr 3, 2025
81670f1
Overwrite system Chrome to fix Chrome Driver and Chrome version incom…
lenacohen Apr 3, 2025
25e762e
Overwrite version-specific system chrome
lenacohen Apr 3, 2025
fa8e695
Separate Github Action changes from Travis code
lenacohen Apr 4, 2025
dce23d1
Limit headless mode argument to Github Actions
lenacohen Apr 8, 2025
c61c90b
Run on pushes to mv3-chrome branch and restore color
lenacohen Apr 8, 2025
fd8dff5
Address PR feedback to simplify the config and remove Chrome steps fr…
lenacohen Apr 10, 2025
3b2eac0
Remove Travis code and references
lenacohen Apr 10, 2025
0abef94
Fix missing steps
lenacohen Apr 10, 2025
137985a
Remove Travis references from pbtest
lenacohen Apr 10, 2025
ebc7eea
Switch from --headless to Xvfb
lenacohen Apr 10, 2025
52dfebc
Restore branch limit to trigger runs only on pushes to master
lenacohen Apr 10, 2025
ab3314b
Tweak lint job
ghostwords Apr 10, 2025
e81971b
Restore ChromeDriver script (useful for local dev)
ghostwords Apr 10, 2025
b1e1b34
Tweak Selenium tests job
ghostwords Apr 10, 2025
fa21053
Tweak lint job name
ghostwords Apr 10, 2025
9b1b2c1
Tweak testing doc
ghostwords Apr 10, 2025
63d30ed
chmod +x chromedriver.sh
ghostwords Apr 10, 2025
1712190
Add a Geckodriver install script for local dev
ghostwords Apr 10, 2025
ebdf2c8
Remove stray Travis refs
ghostwords Apr 10, 2025
8ce250b
Mega nits
ghostwords Apr 10, 2025
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
98 changes: 98 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Tests

on:
push:
branches:
Comment thread
ghostwords marked this conversation as resolved.
- master
pull_request:
workflow_dispatch:

jobs:
lint:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Run ESLint
run: |
# "--production" to skip installing devDependencies modules
npm ci --production || exit 1
make lint

selenium:
runs-on: ubuntu-22.04
continue-on-error: true
strategy:
matrix:
job: [firefox, firefox-beta, firefox-nightly, firefox-esr, edge-beta]
include:
- job: firefox
INFO: "Firefox"
BROWSER: "firefox"
FIREFOX_VERSION: "latest"
- job: firefox-beta
INFO: "Firefox Beta"
BROWSER: "firefox"
FIREFOX_VERSION: "latest-beta"
- job: firefox-nightly
INFO: "Firefox Nightly"
BROWSER: "firefox"
FIREFOX_VERSION: "latest-nightly"
- job: firefox-esr
INFO: "Firefox ESR"
BROWSER: "firefox"
FIREFOX_VERSION: "latest-esr"
- job: edge-beta
INFO: "Edge Beta"
BROWSER: "microsoft-edge-beta"

env:
INFO: ${{ matrix.INFO }}
BROWSER: ${{ matrix.BROWSER }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install Python dependencies
run: pip install -r tests/requirements.txt

- name: Set up Firefox
if: ${{ matrix.BROWSER == 'firefox' }}
uses: browser-actions/setup-firefox@v1
with:
firefox-version: ${{ matrix.FIREFOX_VERSION }}

- name: Install Geckodriver
if: ${{ matrix.BROWSER == 'firefox' }}
uses: browser-actions/setup-geckodriver@latest

- name: Set up Edge
if: ${{ matrix.BROWSER == 'microsoft-edge-beta' }}
uses: browser-actions/setup-edge@v1
with:
edge-version: beta

- name: Install Edge WebDriver
if: ${{ matrix.BROWSER == 'microsoft-edge-beta' }}
run: ./scripts/edge_webdriver.sh

- name: Install Xvfb
run: sudo apt-get install -y xvfb

- name: Run Tests
run: |
type "$BROWSER" >/dev/null 2>&1 || {
echo "$BROWSER seems to be missing!"
exit 1
}
echo "Found $("$BROWSER" --version)"
xvfb-run --auto-servernum pytest --capture=no --color=yes --verbose --durations=10 tests/selenium
36 changes: 0 additions & 36 deletions .travis.yml

This file was deleted.

13 changes: 4 additions & 9 deletions doc/tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ There are two types of tests:
* [Unit tests](/doc/tests.md#unit-tests) for exercising isolated units of code
* [Functional tests](/doc/tests.md#functional-tests) for verifying high-level extension functionality

[Travis CI](/doc/tests.md#travis-ci) runs unit and functional tests on every pull request on Chrome, Firefox and Edge.
[GitHub Actions](/doc/tests.md#github-actions-ci) runs unit and functional tests on every pull request on Chrome, Firefox and Edge.

## Travis CI
## GitHub Actions CI

Every pull request runs the [full suite of tests on Travis CI](https://app.travis-ci.com/github/EFForg/privacybadger/branches). We test on latest stable Chrome and Firefox releases, as well as on Chrome Beta, Edge Beta, Firefox Beta and Firefox ESR.

See [`.travis.yml`](/.travis.yml) for Travis configuration, [`scripts/setup_travis.sh`](/scripts/setup_travis.sh) for test setup, and [`scripts/run_travis.sh`](/scripts/run_travis.sh) for test execution procedures.
Every pull request runs the full suite of tests on GitHub Actions. See [`test.yml`](/.github/workflows/test.yml) for the GitHub Actions configuration.

We use [ESLint](https://eslint.org) to flag potential JavaScript errors and style issues. Please see our [developer guide](/doc/develop.md#lint-your-changes) for setup instructions.

Expand All @@ -38,7 +36,7 @@ Do verify that removing or mutating the code being tested produces failed assert
Our [functional tests](/tests/selenium/) are written in Python and driven by [Selenium](https://selenium-python.readthedocs.io/) and [pytest](https://docs.pytest.org/en/latest/).

- To run them in Chrome, you need to [install `chromedriver`](http://chromedriver.chromium.org/getting-started)
- For Firefox, you need to [install `geckodriver`](https://github.com/EFForg/privacybadger/blob/1550b9efb64c1d5e276361e3940f402c3ec87afc/scripts/setup_travis.sh#L21-L50)
- For Firefox, you need to [install `geckodriver`](/scripts/geckodriver.sh)
- For Microsoft Edge, [install Microsoft Edge WebDriver](https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/)

You also need to [install the Python packages](https://snarky.ca/a-quick-and-dirty-guide-on-how-to-install-packages-for-python/) specified in [`/tests/requirements.txt`](/tests/requirements.txt).
Expand All @@ -56,9 +54,6 @@ $ BROWSER=/Applications/Firefox.app/Contents/MacOS/firefox-bin pytest -v tests/
$ BROWSER=/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome pytest -v tests/
```

For more information, see our Travis CI [setup](/scripts/setup_travis.sh) and
[run](/scripts/run_travis.sh) scripts.


### Invocation examples

Expand Down
2 changes: 1 addition & 1 deletion scripts/chromedriver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ wget -q -O "$TEMPDIR/chromedriver.zip" "$chromedriver_url" \

# check that chromedriver is now present
type chromedriver >/dev/null 2>&1 || {
echo "Failed to install ChromeDriver!"
echo "Failed to install ChromeDriver"
exit 1
}

Expand Down
21 changes: 21 additions & 0 deletions scripts/edge_webdriver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

edge_version_major=$(microsoft-edge-beta --product-version | cut -d . -f 1)
edgedriver_version_url="https://msedgedriver.azureedge.net/LATEST_RELEASE_${edge_version_major}_LINUX"
edgedriver_version=$(curl -s "$edgedriver_version_url" | tr -d "\0\r\n" | cut -c 3-)
if [ -z "$edgedriver_version" ]; then
echo "Failed to retrieve Edge WebDriver version!"
exit 1
fi

echo "Installing Edge WebDriver version $edgedriver_version ..."
wget "https://msedgedriver.azureedge.net/${edgedriver_version}/edgedriver_linux64.zip"
unzip edgedriver_linux64.zip
sudo mv msedgedriver /usr/local/bin/
sudo chmod a+x /usr/local/bin/msedgedriver

# check that Edge WebDriver is now present
type msedgedriver >/dev/null 2>&1 || {
echo "Failed to install Edge WebDriver"
exit 1
}
30 changes: 30 additions & 0 deletions scripts/geckodriver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

# Install the latest version of geckodriver
version=$(curl -sI https://github.com/mozilla/geckodriver/releases/latest | grep -i "^Location: " | sed 's/.*\///' | tr -d '\r')

# check that we got something
if [ -z "$version" ]; then
echo "Failed to determine the latest Geckodriver version!"
exit 1
fi

# Geckodriver distribution is MacOS or Linux specific
os="$(uname -s)"
if [[ $os == "Darwin" ]]; then
os_dist="macos.tar.gz"
else
os_dist="linux64.tar.gz"
fi

echo "Setting up Geckodriver version $version ..."
url="https://github.com/mozilla/geckodriver/releases/download/${version}/geckodriver-${version}-${os_dist}"
wget -q -O /tmp/geckodriver.tar.gz "$url"
sudo tar -xvf /tmp/geckodriver.tar.gz -C /usr/local/bin/
sudo chmod a+x /usr/local/bin/geckodriver

# check that geckodriver is now present
type geckodriver >/dev/null 2>&1 || {
echo "Failed to install Geckodriver"
exit 1
}
40 changes: 0 additions & 40 deletions scripts/run_travis.sh

This file was deleted.

102 changes: 0 additions & 102 deletions scripts/setup_travis.sh

This file was deleted.

6 changes: 3 additions & 3 deletions tests/selenium/pbtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def fix_chrome_extension_id(self):

@property
def wants_xvfb(self):
if self.on_travis or bool(int(os.environ.get('ENABLE_XVFB', 0))):
if self.on_github_actions or bool(int(os.environ.get('ENABLE_XVFB', 0))):
try:
Xvfb
except NameError:
Expand All @@ -155,8 +155,8 @@ def wants_xvfb(self):
return False

@property
def on_travis(self):
if "TRAVIS" in os.environ:
def on_github_actions(self):
if "GITHUB_ACTIONS" in os.environ:
return True
return False

Expand Down