-
Notifications
You must be signed in to change notification settings - Fork 573
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
98 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,13 +22,16 @@ jobs: | |
use-git: | ||
type: boolean | ||
default: false | ||
use-mysql: | ||
set-data-path: | ||
type: boolean | ||
default: false | ||
use-sqlite: | ||
type: boolean | ||
default: false | ||
use-postgresql: | ||
type: boolean | ||
default: false | ||
use-sqlite: | ||
use-mysql: | ||
type: boolean | ||
default: false | ||
steps: | ||
|
@@ -60,6 +63,35 @@ jobs: | |
command: | | ||
python3 -m venv venv | ||
- when: | ||
condition: <<parameters.set-data-path>> | ||
steps: | ||
- run: | ||
name: Set DATABASE_URL to sqlite | ||
command: | | ||
printf "\nDATA_PATH = '"$DATA_PATH"'\n" >> scrapydweb_settings_v8.py | ||
- when: | ||
condition: <<parameters.use-sqlite>> | ||
steps: | ||
- run: | ||
name: Set DATABASE_URL to sqlite | ||
command: | | ||
printf "\nDATABASE_URL = '"$DATABASE_URL"'\n" >> scrapydweb_settings_v8.py | ||
- when: | ||
condition: <<parameters.use-postgresql>> | ||
steps: | ||
- run: | ||
name: Setup PSQL Databases | ||
command: | | ||
# https://discuss.circleci.com/t/multiple-postgres-databases-in-circleci-2-0/23089 | ||
# createdb: could not connect to database template1: FATAL: role "circleci" does not exist | ||
# sudo apt install -y postgresql-client | ||
# createdb -h localhost scrapydweb_apscheduler -O circleci | ||
- run: | ||
name: Set DATABASE_URL to postgresql | ||
command: | | ||
# postgres://[email protected]:5432 | ||
printf "\nDATABASE_URL = '"$DATABASE_URL"'\n" >> scrapydweb_settings_v8.py | ||
- when: | ||
condition: <<parameters.use-mysql>> | ||
steps: | ||
|
@@ -90,31 +122,7 @@ jobs: | |
command: | | ||
# mysql://user:[email protected]:3306 | ||
printf "\nDATABASE_URL = '"$DATABASE_URL"'\n" >> scrapydweb_settings_v8.py | ||
cat scrapydweb_settings_v8.py | ||
- when: | ||
condition: <<parameters.use-postgresql>> | ||
steps: | ||
- run: | ||
name: Setup PSQL Databases | ||
command: | | ||
# https://discuss.circleci.com/t/multiple-postgres-databases-in-circleci-2-0/23089 | ||
# createdb: could not connect to database template1: FATAL: role "circleci" does not exist | ||
# sudo apt install -y postgresql-client | ||
# createdb -h localhost scrapydweb_apscheduler -O circleci | ||
- run: | ||
name: Set DATABASE_URL to postgresql | ||
command: | | ||
# postgres://[email protected]:5432 | ||
printf "\nDATABASE_URL = '"$DATABASE_URL"'\n" >> scrapydweb_settings_v8.py | ||
cat scrapydweb_settings_v8.py | ||
- when: | ||
condition: <<parameters.use-sqlite>> | ||
steps: | ||
- run: | ||
name: Set DATABASE_URL to sqlite | ||
command: | | ||
printf "\nDATABASE_URL = '"$DATABASE_URL"'\n" >> scrapydweb_settings_v8.py | ||
cat scrapydweb_settings_v8.py | ||
- run: | ||
name: Install dependencies | ||
command: | | ||
|
@@ -160,13 +168,16 @@ jobs: | |
- run: | ||
name: Generate report | ||
command: | | ||
touch scrapydweb_settings_v8.py | ||
cat scrapydweb_settings_v8.py | ||
echo $DATA_PATH | ||
echo $DATABASE_URL | ||
. venv/bin/activate | ||
coverage report | ||
coverage html | ||
coverage xml | ||
coveralls | ||
ls -la | ||
coveralls | ||
- store_artifacts: | ||
path: htmlcov | ||
- store_artifacts: | ||
|
@@ -184,6 +195,7 @@ jobs: | |
- image: circleci/python:2.7 | ||
environment: | ||
SCRAPYDWEB_TESTMODE: True | ||
DATA_PATH: '/home/circleci/repo/scrapydweb_data' | ||
DATABASE_URL: 'sqlite:////home/circleci/repo/scrapydweb_database' | ||
py27-postgresql: | ||
<<: *test-template | ||
|
@@ -224,6 +236,7 @@ jobs: | |
- image: circleci/python:3.6 | ||
environment: | ||
SCRAPYDWEB_TESTMODE: True | ||
DATA_PATH: '/home/circleci/repo/scrapydweb_data' | ||
DATABASE_URL: 'sqlite:////home/circleci/repo/scrapydweb_database' | ||
py37-git-postgresql: | ||
<<: *test-template | ||
|
@@ -266,6 +279,7 @@ workflows: | |
is-py27: true | ||
- py27-sqlite: | ||
is-py27: true | ||
set-data-path: true | ||
use-sqlite: true | ||
- py27-postgresql: | ||
is-py27: true | ||
|
@@ -274,9 +288,10 @@ workflows: | |
is-py27: true | ||
use-mysql: true | ||
|
||
- py36-sqlite: | ||
use-postgresql: true | ||
- py37 | ||
- py36-sqlite: | ||
set-data-path: true | ||
use-sqlite: true | ||
- py37-git-postgresql: | ||
use-git: true | ||
use-postgresql: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -309,13 +309,17 @@ | |
# for getting more information about how ScrapydWeb works, especially while debugging. | ||
VERBOSE = False | ||
|
||
# The default is '', which means saving data of Jobs and Timer Tasks in the Python directory using SQLite. | ||
# The default is '', which means saving all program data in the Python directory. | ||
# e.g. 'C:/Users/username/scrapydweb_data' or '/home/username/scrapydweb_data' | ||
DATA_PATH = '' | ||
|
||
# The default is '', which means saving data of Jobs and Timer Tasks in DATA_PATH using SQLite. | ||
# The data could be also saved in MySQL or PostgreSQL backend in order to improve concurrency. | ||
# To use MySQL backend, run command: pip install --upgrade pymysql | ||
# To use PostgreSQL backend, run command: pip install --upgrade psycopg2 | ||
# e.g. | ||
# 'mysql://username:[email protected]:3306' | ||
# 'postgres://username:[email protected]:5432' | ||
# 'sqlite:///c:/Users/username' | ||
# 'sqlite:///C:/Users/username' | ||
# 'sqlite:////home/username' | ||
DATABASE_URL = '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# coding: utf-8 | ||
import os | ||
import re | ||
|
||
from scrapydweb.vars import APSCHEDULER_DATABASE_URI, DATA_PATH, DATABASE_PATH, ROOT_DIR | ||
|
||
|
||
def test_option_data_path(app): | ||
data_path = os.environ.get('DATA_PATH', '') | ||
if data_path and os.environ.get('TEST_ON_CIRCLECI', 'False').lower() == 'true': | ||
assert not os.path.isdir(os.path.join(ROOT_DIR, 'data', 'database')) | ||
assert os.path.isdir(os.path.join(data_path or DATA_PATH, 'database')) | ||
|
||
|
||
def test_option_database_url(app): | ||
database_url = os.environ.get('DATABASE_URL', 'sqlite:///' + DATABASE_PATH) | ||
assert APSCHEDULER_DATABASE_URI.startswith(database_url) | ||
assert app.config['SQLALCHEMY_DATABASE_URI'].startswith(database_url) | ||
for value in app.config['SQLALCHEMY_BINDS'].values(): | ||
assert value.startswith(database_url) | ||
|
||
m = re.match(r'sqlite:///(.+)$', database_url) | ||
assert os.path.isdir(m.group(1) if m else DATABASE_PATH) |