Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
zesje
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
157
Issues
157
List
Boards
Labels
Service Desk
Milestones
Merge Requests
14
Merge Requests
14
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zesje
zesje
Commits
548d1547
Commit
548d1547
authored
Apr 21, 2020
by
Adrià Labay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
run mysql as gitlab service
parent
8c034ff2
Pipeline
#33322
passed with stages
in 7 minutes and 14 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
12 deletions
+24
-12
.gitlab-ci.yml
.gitlab-ci.yml
+7
-3
migrations/alembic.ini
migrations/alembic.ini
+0
-3
package.json
package.json
+4
-4
tests/conftest.py
tests/conftest.py
+13
-2
No files found.
.gitlab-ci.yml
View file @
548d1547
...
...
@@ -54,10 +54,14 @@ lint_py:
test_py
:
<<
:
*python_packages
stage
:
test
services
:
-
mysql:5.7
variables
:
MYSQL_DATABASE
:
"
course_dev"
MYSQL_ALLOW_EMPTY_PASSWORD
:
"
yes"
script
:
-
yarn mysql-create
-
yarn test:mysql-start && yarn test:py:cov
-
yarn mysql-stop
-
echo "SELECT 'OK';" | mysql -uroot -h mysql "course_dev"
-
yarn test:py:cov
artifacts
:
paths
:
-
cov.html/
...
...
migrations/alembic.ini
View file @
548d1547
...
...
@@ -8,9 +8,6 @@
# the 'revision' command, regardless of autogenerate
# revision_environment = false
# path to migration scripts
script_location
=
.
# Logging configuration
[loggers]
...
...
package.json
View file @
548d1547
...
...
@@ -15,7 +15,7 @@
"lint:js"
:
"standard --verbose | snazzy"
,
"test:js"
:
"jest"
,
"lint:py"
:
"flake8"
,
"test:py"
:
"
python3 -m pytest -v -W error::RuntimeWarning
"
,
"test:py"
:
"
yarn test:mysql-start && python3 -m pytest -v -W error::RuntimeWarning; yarn mysql-stop
"
,
"start"
:
"ZESJE_SETTINGS=$(pwd)/zesje_dev_cfg.py python3 zesje"
,
"analyze"
:
"webpack --config webpack.prod.js --profile --json > stats.json; webpack-bundle-analyzer stats.json zesje/static"
,
"migrate"
:
"mysql -uroot <$(pwd)/myinit.sql; FLASK_APP=zesje.wsgi:app flask db upgrade"
,
...
...
@@ -23,9 +23,9 @@
"prepare-migration"
:
"ZESJE_SETTINGS=$(pwd)/zesje_dev_cfg.py FLASK_APP=zesje.wsgi:app flask db migrate"
,
"test:py:cov"
:
"python3 -m pytest -v -W error::RuntimeWarning --cov=zesje --cov-report=xml:cov.xml --cov-report=html:cov.html --cov-report=term tests/"
,
"migrate-down"
:
"FLASK_APP=zesje.wsgi:app flask db downgrade"
,
"mysql-create"
:
"if [ ! -d
\"
$(pwd)/data-dev/mysql
\"
]; then mysqld --defaults-file=my.cnf --initialize-insecure; else echo
\"
MySql already exists. Skipping.
\"
; fi"
,
"mysql-start"
:
"mysqld_safe --defaults-file=
my.cnf --gdb --init-file=/app
/myinit.sql &"
,
"dev:mysql-start"
:
"mysqld_safe --defaults-file=my.cnf --gdb --init-file=$(pwd)/myinit.sql"
,
"mysql-create"
:
"if [ ! -d
\"
$(pwd)/data-dev/mysql
\"
]; then mysqld --defaults-file=
$(pwd)/
my.cnf --initialize-insecure; else echo
\"
MySql already exists. Skipping.
\"
; fi"
,
"mysql-start"
:
"mysqld_safe --defaults-file=
$(pwd)/my.cnf --gdb --init-file=$(pwd)
/myinit.sql &"
,
"dev:mysql-start"
:
"mysqld_safe --defaults-file=
$(pwd)/
my.cnf --gdb --init-file=$(pwd)/myinit.sql"
,
"test:mysql-start"
:
"mysqld_safe --defaults-file=my.cnf --gdb --init-file=$(pwd)/myinit_test.sql &"
,
"mysql-stop"
:
"mysqladmin -uroot shutdown"
},
...
...
tests/conftest.py
View file @
548d1547
...
...
@@ -5,6 +5,7 @@ import pytest
from
flask
import
Flask
from
pathlib
import
Path
import
sys
import
MySQLdb
sys
.
path
.
insert
(
0
,
str
(
Path
.
cwd
()))
...
...
@@ -18,6 +19,16 @@ def datadir():
return
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
'data'
)
@
pytest
.
fixture
(
scope
=
"module"
)
def
db_host
():
try
:
MySQLdb
.
connect
(
'localhost'
,
"root"
,
""
,
"course_dev"
)
except
Exception
:
return
'mysql'
return
'localhost'
# Returns a Flask app with only the config initialized
@
pytest
.
fixture
(
scope
=
"module"
)
def
config_app
():
...
...
@@ -30,12 +41,12 @@ def config_app():
# Return a mock DB which can be used in the testing enviroment
# Module scope ensures it is ran only once
@
pytest
.
fixture
(
scope
=
"module"
)
def
db_app
(
config_app
):
def
db_app
(
config_app
,
db_host
):
app
=
config_app
db
.
init_app
(
app
)
app
.
config
.
update
(
SQLALCHEMY_DATABASE_URI
=
f
'mysql://root:@
localhost
/course_dev'
)
app
.
config
.
update
(
SQLALCHEMY_DATABASE_URI
=
f
'mysql://root:@
{
db_host
}
/course_dev'
)
with
TemporaryDirectory
()
as
temp_dir
:
app
.
config
.
update
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment