Skip to content

Commit

Permalink
Add selenium to github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
George Schneeloch committed Dec 3, 2020
1 parent 497b331 commit d8bc344
Showing 1 changed file with 122 additions and 0 deletions.
122 changes: 122 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,125 @@ jobs:
with:
file: coverage/lcov.info
fail_ci_if_error: true

selenium-tests:
runs-on: ubuntu-latest

services:
# Label used to access the service container
db:
# Docker Hub image
image: postgres:11.6
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432

redis:
image: redis:5.0.8
ports:
- 6379:6379

elastic:
image: docker.elastic.co/elasticsearch/elasticsearch:6.7.1
env:
network.host: "0.0.0.0"
http.cors.enabled: "true"
http.cors.allow-origin: "*"
rest.action.multi.allow_explicit_index: "false"
ES_JAVA_OPTS: -Xms512m -Xmx512m"
ports:
- 9200:9200

hub:
image: selenium/hub:3.141.59-mercury
env:
GRID_TIMEOUT: '3600'
ports:
- 4444:4444

chrome:
image: selenium/node-chrome:3.141.59-mercury
env:
HUB_PORT_4444_TCP_ADDR: 'hub'
HUB_PORT_4444_TCP_PORT: 4444
ports:
- 5555:5555

steps:
- uses: actions/checkout@v2

- name: Apt install
run: cat Aptfile | sudo xargs apt-get install

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.7"

- id: cache
uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt', '**/test_reqirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: pip install -r requirements.txt -r test_requirements.txt

# You must also add the Configure sysctl limits step, otherwise Elasticsearch will not be able to boot.
- name: Configure sysctl limits
run: |
sudo swapoff -a
sudo sysctl -w vm.swappiness=1
sudo sysctl -w fs.file-max=262144
sudo sysctl -w vm.max_map_count=262144
- name: Runs Elasticsearch
uses: elastic/elastic-github-actions/elasticsearch@master
with:
stack-version: 6.7.1

- name: Set up NodeJS
uses: actions/setup-node@v2-beta
with:
node-version: "10.15.1"

- name: Install JS dependencies
run: yarn install --frozen-lockfile --ignore-engines --prefer-offline

- name: Build javascript bundle
run: |
NODE_ENV=production ./webpack_if_prod.sh
- name: Tests
run: |
export MEDIA_ROOT="$(mktemp -d)"
sudo mkdir /var/media
sudo chown -R $USER:$USER /var/media
pytest ./selenium_tests
env:
DEBUG: 'False'
NODE_ENV: 'production'
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres
MICROMASTERS_SECURE_SSL_REDIRECT: 'False'
MICROMASTERS_DB_DISABLE_SSL: 'True'
ELASTICSEARCH_URL: localhost:9200
CELERY_TASK_ALWAYS_EAGER: 'True'
BROKER_URL: redis://localhost:6379/4
CELERY_RESULT_BACKEND: redis://localhost:6379/4

- name: Upload coverage to CodeCov
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
fail_ci_if_error: true

0 comments on commit d8bc344

Please sign in to comment.