Skip to content
This repository has been archived by the owner on May 12, 2022. It is now read-only.

Commit

Permalink
fix: fix ci workflow to run tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aht007 committed Jan 6, 2022
1 parent 0515ea4 commit 659c786
Show file tree
Hide file tree
Showing 11 changed files with 193 additions and 25 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/bok-choy-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Bok Choy Tests

on:
push:
branches:
- master
pull_request:

jobs:
run_tests:
name: Tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
python-version: [3.8]

steps:
- uses: actions/checkout@v2
- name: setup python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Set display to virtual frame buffer
run: export DISPLAY=:99.0

- name: Set up test environment
run: |
sudo apt-get update
sudo apt-get install xvfb gettext
wget https://github.com/mozilla/geckodriver/releases/download/v0.25.0/geckodriver-v0.25.0-linux64.tar.gz
mkdir geckodriver
tar -xzf geckodriver-v0.25.0-linux64.tar.gz -C geckodriver
export PATH=$PATH:$PWD/geckodriver
export BOKCHOY_HEADLESS=true
- name: Install dependencies
run: |
pip install -r requirements/base.txt
pip install -r requirements/testing.txt
- name: Install Firefox 61.0
run: |
sudo apt-get purge firefox
wget "https://ftp.mozilla.org/pub/firefox/releases/46.0/linux-x86_64/en-US/firefox-46.0.tar.bz2"
tar -xjf firefox-46.0.tar.bz2
sudo mv firefox /opt/firefox
sudo ln -s /opt/firefox/firefox /usr/bin/firefox
- name: Run Acceptance tests
run: xvfb-run --server-args=-ac -- make test-bokchoy
env:
BOKCHOY_HEADLESS: true
49 changes: 29 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,19 @@ on:
branches:
- master
pull_request:
branches:
- '**'

jobs:
run_tests:
name: Tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-20.04
python-version:
- 3.8
toxenv: [ django22,quality ]
os: [ubuntu-20.04]
python-version: [3.8]
toxenv: [ django22, quality ]

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: setup python
uses: actions/setup-python@v2
with:
Expand All @@ -30,29 +26,42 @@ jobs:
- name: Set display to virtual frame buffer
run: export DISPLAY=:99.0



- name: Install npm dependencies
run: npm install
- name: Set up test environment
run: |
sudo apt-get update
sudo apt-get install xvfb gettext
wget https://github.com/mozilla/geckodriver/releases/download/v0.25.0/geckodriver-v0.25.0-linux64.tar.gz
mkdir geckodriver
tar -xzf geckodriver-v0.25.0-linux64.tar.gz -C geckodriver
export PATH=$PATH:$PWD/geckodriver
export BOKCHOY_HEADLESS=true
- name: Install dependencies
run: |
pip install -r requirements/base.txt
pip install -r requirements/testing.txt
- name: Run Python and Quality Tests
- name: Install Firefox 61.0
run: |
sudo apt-get purge firefox
wget "https://ftp.mozilla.org/pub/firefox/releases/46.0/linux-x86_64/en-US/firefox-46.0.tar.bz2"
tar -xjf firefox-46.0.tar.bz2
sudo mv firefox /opt/firefox
sudo ln -s /opt/firefox/firefox /usr/bin/firefox
- name: Run Pytest
if: matrix.python-version == '3.8' && matrix.toxenv=='django22'
run: make test-python

- name: Run Quality Tests
if: matrix.python-version == '3.8' && matrix.toxenv=='quality'
env:
TOXENV: ${{ matrix.toxenv }}
run: tox

- name: Run Js/Bokchoy tests
uses: browser-actions/setup-firefox@latest
with:
firefox-version: '46.0'
run: make test

- name: Run Coverage
if: matrix.python-version == '3.8' && matrix.toxenv=='django22'
if: matrix.python-version == '3.8' && matrix.toxenv=='quality'
uses: codecov/codecov-action@v2
with:
fail_ci_if_error: true

29 changes: 29 additions & 0 deletions .github/workflows/js-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Node CI

on:
push:
branches:
- master
pull_request:

jobs:
run_tests:
name: Tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]

steps:
- uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 12

- name: Install npm dependencies
run: npm install

- name: Run Js tests
run: make test-js
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,5 @@ acceptance_tests/*.png
node_modules/

testserver/local_settings.py

venv
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ clean: ## delete generated byte code and coverage reports

upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade
upgrade: ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in
pip install -q pip-tools
pip install -q -r requirements/pip_tools.txt
pip-compile --rebuild --upgrade --allow-unsafe -o requirements/pip.txt requirements/pip.in
pip-compile --upgrade -o requirements/pip_tools.txt requirements/pip_tools.in
pip-compile --upgrade -o requirements/base.txt requirements/base.in
pip-compile --upgrade -o requirements/testing.txt requirements/testing.in
# Let tox control the Django version for tests
Expand All @@ -45,7 +47,7 @@ test-js: ## run tests using npm
-./node_modules/gulp/bin/gulp.js test

test-python: clean ## run tests using pytest and generate coverage report
$(TOX)pytest
$(TOX)pytest --ignore=testserver/test/acceptance

test-bokchoy: ## run tests using bokchoy
bash ./run_bokchoy_tests.sh
Expand Down
12 changes: 12 additions & 0 deletions requirements/constraints.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Version constraints for pip-installation.
#
# This file doesn't install any packages. It specifies version constraints
# that will be applied if a package is needed.
#
# When pinning something here, please provide an explanation of why. Ideally,
# link to other information that will help people in the future to remove the
# pin when possible. Writing an issue against the offending project and
# linking to it here is good.

# This file contains all common constraints for edx-repos
-c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt
5 changes: 5 additions & 0 deletions requirements/pip.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Core dependencies for installing other packages

pip
setuptools
wheel
14 changes: 14 additions & 0 deletions requirements/pip.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# This file is autogenerated by pip-compile
# To update, run:
#
# make upgrade
#
wheel==0.37.1
# via -r requirements/pip.in

# The following packages are considered to be unsafe in a requirements file:
pip==21.3.1
# via -r requirements/pip.in
setuptools==60.2.0
# via -r requirements/pip.in
4 changes: 4 additions & 0 deletions requirements/pip_tools.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Dependencies to run compile tools
-c constraints.txt

pip-tools # Contains pip-compile, used to generate pip requirements files
20 changes: 20 additions & 0 deletions requirements/pip_tools.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# This file is autogenerated by pip-compile
# To update, run:
#
# make upgrade
#
click==8.0.3
# via pip-tools
pep517==0.12.0
# via pip-tools
pip-tools==6.4.0
# via -r requirements/pip_tools.in
tomli==2.0.0
# via pep517
wheel==0.37.1
# via pip-tools

# The following packages are considered to be unsafe in a requirements file:
# pip
# setuptools
23 changes: 20 additions & 3 deletions testserver/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
'rest_framework.throttling.UserRateThrottle',
),
'DEFAULT_THROTTLE_RATES': {
'user': '10/sec',
'user': '100/sec',
}
}

Expand Down Expand Up @@ -175,7 +175,9 @@
# msg type 'open-edx.edx_notifications.lib.tests.test_publisher'
# to /path/to/{param1}/url/{param2} with param subsitutations
# that are passed in with the message
'testserver.*': '/resolved_path/{param1}/url/{param2}',
'open-edx.edx_notifications.lib.tests.test_publisher': '/path/to/{param1}/url/{param2}',
'open-edx.edx_notifications.lib.tests.*': '/alternate/path/to/{param1}/url/{param2}',
'open-edx-edx_notifications.lib.*': '/third/way/to/get/to/{param1}/url/{param2}',
}

# list all known channel providers
Expand Down Expand Up @@ -217,7 +219,18 @@
'null': {
'class': 'edx_notifications.channels.null.NullNotificationChannel',
'options': {}
}
},
'parse-push': {
'class': 'edx_notifications.channels.parse_push.ParsePushNotificationChannelProvider',
'options': {
'application_id': 'test_id',
'rest_api_key': 'test_rest_api_key',
}
},
'urban-airship': {
'class': 'edx_notifications.channels.urban_airship.UrbanAirshipNotificationChannelProvider',
'options': {}
},
}

TEMPLATE_CONTEXT_PROCESSORS = (
Expand Down Expand Up @@ -259,6 +272,10 @@

NOTIFICATION_SITE_NAME = "http://localhost:8000/"

# Constants to set how long (in days) old READ and UNREAD notifications can remain in the system before being purged.
NOTIFICATION_PURGE_READ_OLDER_THAN_DAYS = 30
NOTIFICATION_PURGE_UNREAD_OLDER_THAN_DAYS = 60

try:
from local_settings import *
except Exception:
Expand Down

0 comments on commit 659c786

Please sign in to comment.