Skip to content

[misc] Add SSL to CI servers #32

[misc] Add SSL to CI servers

[misc] Add SSL to CI servers #32

Workflow file for this run

---
name: Run CI Tests
on:
push:
branches: ['master', 'develop', 'feature/**', 'maintenance/**']
pull_request:
workflow_dispatch:
schedule:
# Run weekly on Sundays at 2 AM UTC
- cron: '0 2 * * 0'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
env:
TEST_DB_HOST: mariadb.example.com
TEST_DB_PORT: 3306
TEST_DB_USER: root
TEST_DB_PASSWORD: "heyPassw-!*20oRd"
TEST_DB_DATABASE: testn
jobs:
setup:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.final-matrix }}
steps:
- uses: actions/checkout@v4
- id: set-matrix
name: build matrix
uses: rusher/mariadb-test-build-matrix@main
with:
additional-matrix: '[{"name": "MariaDB 11.4", "os": "ubuntu-latest", "db-type": "community", "db-tag": "11.4", "node": 24}, {"name": "MariaDB 11.4", "os": "ubuntu-latest", "db-type": "community", "db-tag": "11.4", "node": 20}]'
ci:
name: ${{ matrix.name }}${{ matrix.node != 22 && format(' - node {0}', matrix.node) || '' }}
needs: setup
timeout-minutes: 50
strategy:
matrix: ${{ fromJSON(needs.setup.outputs.matrix) }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.continue-on-error || false }}
steps:
- uses: actions/checkout@v4
- name: Add hosts entry
shell: bash
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
echo "127.0.0.1 mariadb.example.com" >> /c/Windows/System32/drivers/etc/hosts
else
echo "127.0.0.1 mariadb.example.com" | sudo tee -a /etc/hosts
fi
- name: Generate self-signed certificates
shell: bash
run: |
chmod +x .github/workflows/generate-certs.sh
./.github/workflows/generate-certs.sh
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Setup MariaDB
id: mariadb-install
if: matrix.db-type != 'mysql'
uses: rusher/action-setup-mariadb@master
with:
tag: ${{ matrix.db-tag }}
root-password: ${{ env.TEST_DB_PASSWORD }}
database: ${{ env.TEST_DB_DATABASE }}
registry: ${{ matrix.db-type == 'enterprise' && 'docker.mariadb.com/enterprise-server' || (matrix.db-type == 'dev' && 'quay.io/mariadb-foundation/mariadb-devel' || '') }}
registry-user: ${{ matrix.db-type == 'enterprise' && secrets.ENTERPRISE_USER || '' }}
registry-password: ${{ matrix.db-type == 'enterprise' && secrets.ENTERPRISE_TOKEN || '' }}
additional-conf: |
${{ matrix.additional-conf || '' }}
${{ matrix.os == 'ubuntu-latest' && '--ssl-ca=/etc/mysql/conf.d/ca.crt' || '' }}
${{ matrix.os == 'ubuntu-latest' && '--ssl-cert=/etc/mysql/conf.d/server.crt' || '' }}
${{ matrix.os == 'ubuntu-latest' && '--ssl-key=/etc/mysql/conf.d/server.key' || '' }}
conf-script-folder: ${{ github.workspace }}/.github/workflows/certs
port: ${{ env.TEST_DB_PORT }}
- name: Setup MySQL
if: matrix.db-type == 'mysql'
uses: mirromutth/[email protected]
with:
mysql version: ${{ matrix.db-tag }}
mysql database: ${{ env.TEST_DB_DATABASE }}
mysql root password: ${{ env.TEST_DB_PASSWORD }}
- name: Install dependencies
run: npm install
- name: Debug - Check MariaDB connection
shell: bash
run: |
echo "=== Network and Port Information ==="
echo "Checking if MariaDB port is accessible..."
netstat -tuln | grep :3306 || echo "Port 3306 not found in netstat"
echo ""
echo "Testing connection to mariadb.example.com:3306..."
timeout 10 bash -c 'cat < /dev/null > /dev/tcp/mariadb.example.com/3306' && echo "✅ Connection successful" || echo "❌ Connection failed"
echo ""
echo "Testing connection to 127.0.0.1:3306..."
timeout 10 bash -c 'cat < /dev/null > /dev/tcp/127.0.0.1/3306' && echo "✅ Connection successful" || echo "❌ Connection failed"
echo ""
echo "=== Environment Variables ==="
echo "TEST_DB_HOST: $TEST_DB_HOST"
echo "TEST_DB_PORT: $TEST_DB_PORT"
echo "TEST_DB_USER: $TEST_DB_USER"
echo "LOCAL_DB: $LOCAL_DB"
echo "DB_TYPE: $DB_TYPE"
env:
TEST_DB_HOST: ${{ env.TEST_DB_HOST }}
TEST_DB_PORT: ${{ env.TEST_DB_PORT }}
TEST_DB_USER: ${{ env.TEST_DB_USER }}
LOCAL_DB: ${{ steps.mariadb-install.outputs.database-type }}
DB_TYPE: ${{ matrix.db-type }}
- name: Run Tests
run: npm run coverage:test
env:
LOCAL_DB: ${{ steps.mariadb-install.outputs.database-type }}
DB_TYPE: ${{ matrix.db-type }}
TEST_DB_SERVER_CERT: ${{ matrix.db-type == 'container' && './.github/workflows/certs/server.crt' || '' }}
- name: Download Codecov uploader
shell: bash
run: |
case "$RUNNER_OS" in
Windows)
powershell -Command Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe -Outfile codecov.exe
choco install -y --force nodejs-lts
# force refresh path
export PATH=$(cmd.exe //c "refreshenv > nul & C:\Progra~1\Git\bin\bash -c 'echo \$PATH' ")
;;
Linux)
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
ls -lrt
;;
macOS)
curl -Os https://uploader.codecov.io/latest/macos/codecov
chmod +x codecov
ls -lrt
;;
esac
- name: Generate Coverage Report
shell: bash
run: |
npm run coverage:create
case "$RUNNER_OS" in
Windows)
./codecov.exe --disable=gcov --token=${{ secrets.CODECOV_TOKEN }}
;;
Linux|macOS)
./codecov --disable=gcov --token=${{ secrets.CODECOV_TOKEN }}
;;
esac
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}