Skip to content

Commit 41b2a34

Browse files
committed
[misc] simplify common structure
1 parent b679369 commit 41b2a34

File tree

2 files changed

+13
-146
lines changed

2 files changed

+13
-146
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -46,85 +46,29 @@ jobs:
4646
steps:
4747
- uses: actions/checkout@v4
4848

49-
- name: Add hosts entry
50-
shell: bash
51-
run: |
52-
if [ "$RUNNER_OS" == "Windows" ]; then
53-
echo "127.0.0.1 mariadb.example.com" >> /c/Windows/System32/drivers/etc/hosts
54-
else
55-
echo "127.0.0.1 mariadb.example.com" | sudo tee -a /etc/hosts
56-
fi
57-
58-
- name: Generate self-signed certificates
59-
shell: bash
60-
run: |
61-
chmod +x .github/workflows/generate-certs.sh
62-
./.github/workflows/generate-certs.sh
63-
64-
- uses: actions/setup-node@v4
49+
- name: Setup Test Environment
50+
id: setup-env
51+
uses: rusher/mariadb-test-setup@master
6552
with:
6653
node-version: ${{ matrix.node }}
67-
68-
- name: Setup MariaDB
69-
id: mariadb-install
70-
if: matrix.db-type != 'mysql'
71-
uses: rusher/action-setup-mariadb@master
72-
with:
73-
tag: ${{ matrix.db-tag }}
74-
root-password: ${{ env.TEST_DB_PASSWORD }}
75-
database: ${{ env.TEST_DB_DATABASE }}
76-
registry: ${{ matrix.db-type == 'enterprise' && 'docker.mariadb.com/enterprise-server' || (matrix.db-type == 'dev' && 'quay.io/mariadb-foundation/mariadb-devel' || '') }}
54+
db-type: ${{ matrix.db-type }}
55+
db-tag: ${{ matrix.db-tag }}
56+
test-db-password: ${{ env.TEST_DB_PASSWORD }}
57+
test-db-database: ${{ env.TEST_DB_DATABASE }}
58+
test-db-port: ${{ env.TEST_DB_PORT }}
59+
additional-conf: ${{ matrix.additional-conf || '' }}
7760
registry-user: ${{ matrix.db-type == 'enterprise' && secrets.ENTERPRISE_USER || '' }}
7861
registry-password: ${{ matrix.db-type == 'enterprise' && secrets.ENTERPRISE_TOKEN || '' }}
79-
additional-conf: |
80-
${{ matrix.additional-conf || '' }}
81-
${{ matrix.os == 'ubuntu-latest' && '--ssl-ca=/etc/mysql/conf.d/ca.crt' || '' }}
82-
${{ matrix.os == 'ubuntu-latest' && '--ssl-cert=/etc/mysql/conf.d/server.crt' || '' }}
83-
${{ matrix.os == 'ubuntu-latest' && '--ssl-key=/etc/mysql/conf.d/server.key' || '' }}
84-
conf-script-folder: ${{ github.workspace }}/.github/workflows/certs
85-
port: ${{ env.TEST_DB_PORT }}
62+
os: ${{ matrix.os }}
8663

87-
- name: Setup MySQL
88-
if: matrix.db-type == 'mysql'
89-
uses: mirromutth/[email protected]
64+
- uses: actions/setup-node@v4
9065
with:
91-
mysql version: ${{ matrix.db-tag }}
92-
mysql database: ${{ env.TEST_DB_DATABASE }}
93-
mysql root password: ${{ env.TEST_DB_PASSWORD }}
94-
95-
- name: Install dependencies
96-
run: npm install
97-
98-
- name: Debug - Check MariaDB connection
99-
shell: bash
100-
run: |
101-
echo "=== Network and Port Information ==="
102-
echo "Checking if MariaDB port is accessible..."
103-
netstat -tuln | grep :3306 || echo "Port 3306 not found in netstat"
104-
echo ""
105-
echo "Testing connection to mariadb.example.com:3306..."
106-
timeout 10 bash -c 'cat < /dev/null > /dev/tcp/mariadb.example.com/3306' && echo "✅ Connection successful" || echo "❌ Connection failed"
107-
echo ""
108-
echo "Testing connection to 127.0.0.1:3306..."
109-
timeout 10 bash -c 'cat < /dev/null > /dev/tcp/127.0.0.1/3306' && echo "✅ Connection successful" || echo "❌ Connection failed"
110-
echo ""
111-
echo "=== Environment Variables ==="
112-
echo "TEST_DB_HOST: $TEST_DB_HOST"
113-
echo "TEST_DB_PORT: $TEST_DB_PORT"
114-
echo "TEST_DB_USER: $TEST_DB_USER"
115-
echo "LOCAL_DB: $LOCAL_DB"
116-
echo "DB_TYPE: $DB_TYPE"
117-
env:
118-
TEST_DB_HOST: ${{ env.TEST_DB_HOST }}
119-
TEST_DB_PORT: ${{ env.TEST_DB_PORT }}
120-
TEST_DB_USER: ${{ env.TEST_DB_USER }}
121-
LOCAL_DB: ${{ steps.mariadb-install.outputs.database-type }}
122-
DB_TYPE: ${{ matrix.db-type }}
66+
node-version: ${{ matrix.node }}
12367

12468
- name: Run Tests
12569
run: npm run coverage:test
12670
env:
127-
LOCAL_DB: ${{ steps.mariadb-install.outputs.database-type }}
71+
LOCAL_DB: ${{ steps.setup-env.outputs.database-type }}
12872
DB_TYPE: ${{ matrix.db-type }}
12973
TEST_DB_SERVER_CERT: ${{ matrix.db-type == 'container' && './.github/workflows/certs/server.crt' || '' }}
13074

.github/workflows/generate-certs.sh

Lines changed: 0 additions & 77 deletions
This file was deleted.

0 commit comments

Comments
 (0)