Repository: ClearcodeHQ/pytest-mysql (language: python)

Issue:
Run tests on OSX
Run tests and see if there are any issues with running tests on osx


Discussion / hints:
Tests failing on macOS 11.6

```
ERROR tests/test_mysql.py::test_mysql - MySQLdb._exceptions.OperationalError: (2002, "Can't connect to local MySQL server through socket '/private/var/folders/rj/jsz7qk590z1dmrn8x6zbczb00000gn/T/pytest-of-ramazan/pytest-11/pytest-mysql-my' (2)")
ERROR tests/test_mysql.py::test_mysql_test_without_cursor - MySQLdb._exceptions.OperationalError: (2002, "Can't connect to local MySQL server through socket '/private/var/folders/rj/jsz7qk590z1dmrn8x6zbczb00000gn/T/pytest-of-ramazan/pytest-11/pytest-mysql-my' (2)")
ERROR tests/test_mysql.py::test_mysql_newfixture - MySQLdb._exceptions.OperationalError: (2002, "Can't connect to local MySQL server through socket '/private/var/folders/rj/jsz7qk590z1dmrn8x6zbczb00000gn/T/pytest-of-ramazan/pytest-11/pytest-mysql-my' (2)")
ERROR tests/test_mysql.py::test_random_port - MySQLdb._exceptions.OperationalError: (2002, "Can't connect to local MySQL server through socket '/private/var/folders/rj/jsz7qk590z1dmrn8x6zbczb00000gn/T/pytest-of-ramazan/pytest-11/pytest-mysql-my' (2)")
ERROR tests/test_mysqlnoproc.py::test_mysql_noproc - MySQLdb._exceptions.OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: NO)")
ERROR tests/test_mysqlnoproc.py::test_mysql_noproc - subprocess.CalledProcessError: Command 'mysqladmin --socket=/private/var/folders/rj/jsz7qk590z1dmrn8x6zbczb00000gn/T/pytest-of-ramazan/pytest-11/pytest-mysql-mysql_rand_proc0/mysql.47031.sock --user=root shutdown' returned non-zero exit status 1.
```
in my case the overly long path that osx uses by default as a tempdir caused the mysql server to fail to start. 

you can work around this by running `pytest --basetemp=/tmp/pytest`

```
2022-01-05T00:05:59.792572Z 0 [ERROR] [MY-010267] [Server] The socket file path is too long (> 103): /private/var/folders/ks/w4v3szn557z1vkxyt8j52nzh0000gn/T/pytest-of-ben/pytest-18/pytest-mysql-mysql_proc_wg_static_db0/mysql.33307.sock
```

Fix patch:
diff --git a/newsfragments/245.misc.rst b/newsfragments/245.misc.rst
new file mode 100644
index 00000000..0981da81
--- /dev/null
+++ b/newsfragments/245.misc.rst
@@ -0,0 +1,1 @@
+Run tests on CI on macosx
\ No newline at end of file


Test patch:
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index e64a6784..ce8f68e7 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -7,7 +7,7 @@ on:
     branches: [ main ]
 
 jobs:
-  tests:
+  tests-mysql-linux:
     runs-on: ubuntu-latest
     strategy:
       fail-fast: true
@@ -29,16 +29,14 @@ jobs:
 
     steps:
     - uses: actions/checkout@v3
-    - name: Verify MySQL connection
-      run: |
-        while ! mysqladmin ping -h"127.0.0.1" -P"3333" --silent; do
-          sleep 1
-        done
+    - uses: ankane/setup-mysql@v1
+      with:
+        mysql-version: 8.0
     - name: Set up Python ${{ matrix.python-version }}
       uses: actions/setup-python@v4
       with:
         python-version: ${{ matrix.python-version }}
-    - name: Install MySQL
+    - name: Check MySQL Version
       run: mysqld --version
     - name: Run test
       uses: fizyk/actions-reuse/.github/actions/pipenv@v1.7.0
@@ -66,9 +64,9 @@ jobs:
         fail_ci_if_error: false
         token: ${{ secrets.CODECOV_TOKEN }}
 
-  tests-mariadb:
+  tests-mariadb-linux:
     runs-on: ubuntu-latest
-    needs: [tests]
+    needs: [tests-mysql-linux]
     strategy:
       fail-fast: true
       matrix:
@@ -88,22 +86,15 @@ jobs:
 
     steps:
     - uses: actions/checkout@v3
-    - name: Verify MariaDB connection
-      run: |
-        while ! mysqladmin ping -h"127.0.0.1" -P"3333" --silent; do
-          sleep 1
-        done
+    - uses: ankane/setup-mariadb@v1
+      with:
+        mariadb-version: "10.10"
     - name: Set up Python ${{ matrix.python-version }}
       uses: actions/setup-python@v4
       with:
         python-version: ${{ matrix.python-version }}
-    - name: Install MariaDB
-      run: |
-        sudo apt remove mysql-server
-        sudo apt autoremove -y
-        sudo apt update
-        sudo apt install mariadb-server
-        mysqld --version
+    - name: Check MySQL Version
+      run: mysqld --version
     - name: Run test
       uses: fizyk/actions-reuse/.github/actions/pipenv@v1.7.0
       with:
@@ -129,3 +120,59 @@ jobs:
         env_vars: OS, PYTHON
         fail_ci_if_error: false
         token: ${{ secrets.CODECOV_TOKEN }}
+
+  tests-mysql-macosx:
+    runs-on: macos-latest
+    needs: [tests-mysql-linux]
+    strategy:
+      fail-fast: true
+      matrix:
+        python-version: [3.9, "3.10", "3.11"]
+    env:
+      OS: macos-latest
+      PYTHON: ${{ matrix.python-version }}
+    steps:
+    - uses: actions/checkout@v3
+    - uses: ankane/setup-mysql@v1
+      with:
+        mysql-version: 8.0
+    - name: Set up Python ${{ matrix.python-version }}
+      uses: actions/setup-python@v4
+      with:
+        python-version: ${{ matrix.python-version }}
+    - name: Check MySQL Version
+      run: mysqld --version
+    - name: Run test
+      uses: fizyk/actions-reuse/.github/actions/pipenv@v1.7.0
+      with:
+        python-version: ${{ matrix.python-version }}
+        pipenv-install-options: "--skip-lock"
+        command: pytest -n 0 -k "not mysqlnoproc" --cov-report=xml --mysql-user=root --basetemp=/tmp/pytest_mysql
+
+  tests-mariadb-macosx:
+    runs-on: macos-latest
+    needs: [tests-mysql-macosx, tests-mariadb-linux]
+    strategy:
+      fail-fast: true
+      matrix:
+        python-version: [3.9, "3.10", "3.11"]
+    env:
+      OS: macos-latest
+      PYTHON: ${{ matrix.python-version }}
+    steps:
+    - uses: actions/checkout@v3
+    - uses: ankane/setup-mariadb@v1
+      with:
+        mariadb-version: "10.10"
+    - name: Set up Python ${{ matrix.python-version }}
+      uses: actions/setup-python@v4
+      with:
+        python-version: ${{ matrix.python-version }}
+    - name: Check MySQL Version
+      run: mysqld --version
+    - name: Run test
+      uses: fizyk/actions-reuse/.github/actions/pipenv@v1.7.0
+      with:
+        python-version: ${{ matrix.python-version }}
+        pipenv-install-options: "--skip-lock"
+        command: pytest --mysql-user=$USER -n 0 -k "not mysqlnoproc" --cov-report=xml --basetemp=/tmp/pytest_mysql