Skip to content

Commit 28bfbe4

Browse files
committed
[misc] simplify common structure
(cherry picked from commit 67663d6)
1 parent 71b9807 commit 28bfbe4

File tree

2 files changed

+26
-149
lines changed

2 files changed

+26
-149
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -46,87 +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-
env:
98-
LOCAL_DB: ${{ steps.mariadb-install.outputs.database-type }}
99-
100-
- name: Debug - Check MariaDB connection
101-
shell: bash
102-
run: |
103-
echo "=== Network and Port Information ==="
104-
echo "Checking if MariaDB port is accessible..."
105-
netstat -tuln | grep :3306 || echo "Port 3306 not found in netstat"
106-
echo ""
107-
echo "Testing connection to mariadb.example.com:3306..."
108-
timeout 10 bash -c 'cat < /dev/null > /dev/tcp/mariadb.example.com/3306' && echo "✅ Connection successful" || echo "❌ Connection failed"
109-
echo ""
110-
echo "Testing connection to 127.0.0.1:3306..."
111-
timeout 10 bash -c 'cat < /dev/null > /dev/tcp/127.0.0.1/3306' && echo "✅ Connection successful" || echo "❌ Connection failed"
112-
echo ""
113-
echo "=== Environment Variables ==="
114-
echo "TEST_DB_HOST: $TEST_DB_HOST"
115-
echo "TEST_DB_PORT: $TEST_DB_PORT"
116-
echo "TEST_DB_USER: $TEST_DB_USER"
117-
echo "LOCAL_DB: $LOCAL_DB"
118-
echo "DB_TYPE: $DB_TYPE"
119-
env:
120-
TEST_DB_HOST: ${{ env.TEST_DB_HOST }}
121-
TEST_DB_PORT: ${{ env.TEST_DB_PORT }}
122-
TEST_DB_USER: ${{ env.TEST_DB_USER }}
123-
LOCAL_DB: ${{ steps.mariadb-install.outputs.database-type }}
124-
DB_TYPE: ${{ matrix.db-type }}
66+
node-version: ${{ matrix.node }}
12567

12668
- name: Run Tests
12769
run: npm run coverage:test
12870
env:
129-
LOCAL_DB: ${{ steps.mariadb-install.outputs.database-type }}
71+
LOCAL_DB: ${{ steps.setup-env.outputs.database-type }}
13072
DB_TYPE: ${{ matrix.db-type }}
13173
TEST_DB_SERVER_CERT: ${{ matrix.db-type == 'container' && './.github/workflows/certs/server.crt' || '' }}
13274

@@ -153,4 +95,16 @@ jobs:
15395
esac
15496
15597
- name: Generate Coverage Report
156-
run: npm run coverage:report
98+
shell: bash
99+
run: |
100+
npm run coverage:create
101+
case "$RUNNER_OS" in
102+
Windows)
103+
./codecov.exe --disable=gcov --token=${{ secrets.CODECOV_TOKEN }}
104+
;;
105+
Linux|macOS)
106+
./codecov --disable=gcov --token=${{ secrets.CODECOV_TOKEN }}
107+
;;
108+
esac
109+
env:
110+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/generate-certs.sh

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

0 commit comments

Comments
 (0)