Skip to content

Commit

Permalink
fixed get of socket value from php config (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
bigcat88 authored Dec 18, 2022
1 parent 9396be5 commit 871bf60
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 5 deletions.
82 changes: 81 additions & 1 deletion .github/workflows/py_analysis-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: (Py)Analysis & Coverage

on:
pull_request:
types: [opened, edited, reopened, synchronize]
paths:
- 'nc_py_api/*.*'
- 'tests/nc_py_api/**'
Expand Down Expand Up @@ -324,3 +323,84 @@ jobs:
file: apps/${{ env.APP_NAME }}/coverage.xml
fail_ci_if_error: true
verbose: true

tests-mysql-socket:
needs: [analysis]
runs-on: ubuntu-22.04
name: ${{ matrix.nextcloud }} • PHP ${{ matrix.php-version }} • MySQL • SOCK
if: "!contains(github.event.head_commit.message, '[docs]')"
strategy:
fail-fast: false
matrix:
php-version: [ "7.4", "8.0" ]
nextcloud: [ "25.0.2" ]

steps:
- name: Set up php ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, fileinfo, intl, pdo_mysql, zip, gd

- uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: cache-nextcloud
id: nextcloud_setup
uses: actions/cache@v3
with:
path: nextcloud-${{ matrix.nextcloud }}.tar.bz2
key: ${{ matrix.nextcloud }}

- name: Download Nextcloud
if: steps.nextcloud_setup.outputs.cache-hit != 'true'
run: wget -q https://download.nextcloud.com/server/releases/nextcloud-${{ matrix.nextcloud }}.tar.bz2

- name: Set up Nextcloud
run: |
sudo sed -i "s/.*port.*3306.*/port = 3307/" /etc/mysql/mysql.conf.d/mysqld.cnf
sudo systemctl restart mysql.service
mysql -uroot -proot -e "CREATE DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"
mysql -uroot -proot -e "show databases;"
tar -xjf nextcloud-${{ matrix.nextcloud }}.tar.bz2 --strip-components 1
mkdir data
php occ maintenance:install --verbose --database=mysql --database-name=nextcloud \
--database-user=root --database-pass=root \
--admin-user admin --admin-pass adminpassword
php occ config:system:set debug --value=true --type=boolean
php -S localhost:8080 &
- uses: actions/checkout@v3
with:
path: apps/${{ env.APP_NAME }}

- name: Enable App & Test Data
run: |
php occ app:enable ${{ env.APP_NAME }}
cp -R apps/${{ env.APP_NAME }}/tests/nc_py_api/test_dir ./data/admin/files/
php occ files:scan admin
- name: Generate coverage report
working-directory: apps/${{ env.APP_NAME }}
run: |
python3 -m pip -v install ".[dev]"
coverage run -m pytest -s && coverage xml && coverage html
env:
SERVER_ROOT: "../.."
CPA_LOGLEVEL: debug

- name: HTML coverage to artifacts
uses: actions/upload-artifact@v3
with:
name: coverage_${{ matrix.nextcloud }}_${{ matrix.php-version }}_mysql_socket
path: apps/${{ env.APP_NAME }}/htmlcov
if-no-files-found: error

- name: Upload report to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: apps/${{ env.APP_NAME }}/coverage.xml
fail_ci_if_error: true
verbose: true
2 changes: 1 addition & 1 deletion nc_py_api/_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
""" Version of Nc_Py_Api """

__version__ = "0.0.7"
__version__ = "0.0.8"
8 changes: 5 additions & 3 deletions nc_py_api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,18 @@ def finish_db_configuration() -> bool:
if CONFIG["dbtype"] == "mysql":
# when no `dbport` or `usock` found in NC config, trying php socket configuration.
php_info = php_call("-r", "phpinfo();")
if isinstance(php_info, str):
if php_info:
m_groups = re.search(
r"pdo_mysql\.default_socket\s*=>\s*(.*)\s*=>\s*(.*)", php_info, flags=re.MULTILINE + re.IGNORECASE
r"pdo_mysql\.default_socket\s*=>\s*(.*)\s*=>\s*(.*)",
php_info.decode("utf-8").rstrip("\n"),
flags=re.MULTILINE + re.IGNORECASE,
)
if m_groups is None:
log.warning("Cant parse php info.")
else:
socket_path = m_groups.groups()[-1].strip()
if os.path.exists(socket_path):
usock = CONFIG["usock"]
usock = CONFIG.get("usock", None)
CONFIG["usock"] = socket_path
if connection_test(CONFIG):
return True
Expand Down

0 comments on commit 871bf60

Please sign in to comment.