Skip to content

Commit 871bf60

Browse files
authored
fixed get of socket value from php config (#31)
1 parent 9396be5 commit 871bf60

File tree

3 files changed

+87
-5
lines changed

3 files changed

+87
-5
lines changed

.github/workflows/py_analysis-coverage.yml

+81-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: (Py)Analysis & Coverage
22

33
on:
44
pull_request:
5-
types: [opened, edited, reopened, synchronize]
65
paths:
76
- 'nc_py_api/*.*'
87
- 'tests/nc_py_api/**'
@@ -324,3 +323,84 @@ jobs:
324323
file: apps/${{ env.APP_NAME }}/coverage.xml
325324
fail_ci_if_error: true
326325
verbose: true
326+
327+
tests-mysql-socket:
328+
needs: [analysis]
329+
runs-on: ubuntu-22.04
330+
name: ${{ matrix.nextcloud }} • PHP ${{ matrix.php-version }} • MySQL • SOCK
331+
if: "!contains(github.event.head_commit.message, '[docs]')"
332+
strategy:
333+
fail-fast: false
334+
matrix:
335+
php-version: [ "7.4", "8.0" ]
336+
nextcloud: [ "25.0.2" ]
337+
338+
steps:
339+
- name: Set up php ${{ matrix.php-version }}
340+
uses: shivammathur/setup-php@v2
341+
with:
342+
php-version: ${{ matrix.php-version }}
343+
extensions: mbstring, fileinfo, intl, pdo_mysql, zip, gd
344+
345+
- uses: actions/setup-python@v4
346+
with:
347+
python-version: '3.9'
348+
349+
- name: cache-nextcloud
350+
id: nextcloud_setup
351+
uses: actions/cache@v3
352+
with:
353+
path: nextcloud-${{ matrix.nextcloud }}.tar.bz2
354+
key: ${{ matrix.nextcloud }}
355+
356+
- name: Download Nextcloud
357+
if: steps.nextcloud_setup.outputs.cache-hit != 'true'
358+
run: wget -q https://download.nextcloud.com/server/releases/nextcloud-${{ matrix.nextcloud }}.tar.bz2
359+
360+
- name: Set up Nextcloud
361+
run: |
362+
sudo sed -i "s/.*port.*3306.*/port = 3307/" /etc/mysql/mysql.conf.d/mysqld.cnf
363+
sudo systemctl restart mysql.service
364+
mysql -uroot -proot -e "CREATE DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"
365+
mysql -uroot -proot -e "show databases;"
366+
tar -xjf nextcloud-${{ matrix.nextcloud }}.tar.bz2 --strip-components 1
367+
mkdir data
368+
php occ maintenance:install --verbose --database=mysql --database-name=nextcloud \
369+
--database-user=root --database-pass=root \
370+
--admin-user admin --admin-pass adminpassword
371+
php occ config:system:set debug --value=true --type=boolean
372+
php -S localhost:8080 &
373+
374+
- uses: actions/checkout@v3
375+
with:
376+
path: apps/${{ env.APP_NAME }}
377+
378+
- name: Enable App & Test Data
379+
run: |
380+
php occ app:enable ${{ env.APP_NAME }}
381+
cp -R apps/${{ env.APP_NAME }}/tests/nc_py_api/test_dir ./data/admin/files/
382+
php occ files:scan admin
383+
384+
- name: Generate coverage report
385+
working-directory: apps/${{ env.APP_NAME }}
386+
run: |
387+
python3 -m pip -v install ".[dev]"
388+
coverage run -m pytest -s && coverage xml && coverage html
389+
env:
390+
SERVER_ROOT: "../.."
391+
CPA_LOGLEVEL: debug
392+
393+
- name: HTML coverage to artifacts
394+
uses: actions/upload-artifact@v3
395+
with:
396+
name: coverage_${{ matrix.nextcloud }}_${{ matrix.php-version }}_mysql_socket
397+
path: apps/${{ env.APP_NAME }}/htmlcov
398+
if-no-files-found: error
399+
400+
- name: Upload report to Codecov
401+
uses: codecov/codecov-action@v3
402+
with:
403+
token: ${{ secrets.CODECOV_TOKEN }}
404+
file: apps/${{ env.APP_NAME }}/coverage.xml
405+
fail_ci_if_error: true
406+
verbose: true

nc_py_api/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
""" Version of Nc_Py_Api """
22

3-
__version__ = "0.0.7"
3+
__version__ = "0.0.8"

nc_py_api/config.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,18 @@ def finish_db_configuration() -> bool:
6262
if CONFIG["dbtype"] == "mysql":
6363
# when no `dbport` or `usock` found in NC config, trying php socket configuration.
6464
php_info = php_call("-r", "phpinfo();")
65-
if isinstance(php_info, str):
65+
if php_info:
6666
m_groups = re.search(
67-
r"pdo_mysql\.default_socket\s*=>\s*(.*)\s*=>\s*(.*)", php_info, flags=re.MULTILINE + re.IGNORECASE
67+
r"pdo_mysql\.default_socket\s*=>\s*(.*)\s*=>\s*(.*)",
68+
php_info.decode("utf-8").rstrip("\n"),
69+
flags=re.MULTILINE + re.IGNORECASE,
6870
)
6971
if m_groups is None:
7072
log.warning("Cant parse php info.")
7173
else:
7274
socket_path = m_groups.groups()[-1].strip()
7375
if os.path.exists(socket_path):
74-
usock = CONFIG["usock"]
76+
usock = CONFIG.get("usock", None)
7577
CONFIG["usock"] = socket_path
7678
if connection_test(CONFIG):
7779
return True

0 commit comments

Comments
 (0)