Run CI Tests #240
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| name: Run CI Tests | |
| on: | |
| push: | |
| 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 | |
| if: | | |
| github.event_name != 'schedule' || | |
| github.ref == 'refs/heads/main' || | |
| startsWith(github.ref, 'refs/heads/develop') || | |
| startsWith(github.ref, 'refs/heads/maintenance/3.2') || | |
| startsWith(github.ref, 'refs/heads/maintenance/3.3') || | |
| startsWith(github.ref, 'refs/heads/maintenance/3.4') | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.final-matrix }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - id: set-matrix | |
| name: build matrix | |
| uses: mariadb-corporation/connector-ci-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}, {"name": "MariaDB 11.4 - DENO", "os": "ubuntu-latest", "db-type": "community", "db-tag": "11.4", "deno": "v2.x"}]' | |
| ci: | |
| name: ${{ matrix.name }}${{ !matrix.deno && 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: Setup Test Environment | |
| id: setup-env | |
| uses: mariadb-corporation/connector-ci-setup@master | |
| with: | |
| node-version: ${{ matrix.node }} | |
| db-type: ${{ matrix.db-type }} | |
| db-tag: ${{ matrix.db-tag }} | |
| test-db-password: ${{ env.TEST_DB_PASSWORD }} | |
| test-db-database: ${{ env.TEST_DB_DATABASE }} | |
| test-db-port: ${{ env.TEST_DB_PORT }} | |
| additional-conf: ${{ matrix.additional-conf || '' }} | |
| registry-user: ${{ matrix.db-type == 'enterprise' && secrets.ENTERPRISE_USER || (secrets.DOCKER_TOKEN != '' && secrets.DOCKER_LOGIN || '') }} | |
| registry-password: ${{ matrix.db-type == 'enterprise' && secrets.ENTERPRISE_TOKEN || secrets.DOCKER_TOKEN }} | |
| os: ${{ matrix.os }} | |
| - uses: actions/setup-node@v4 | |
| if: ${{ !matrix.deno }} | |
| with: | |
| node-version: ${{ matrix.node }} | |
| - name: Setup Deno | |
| uses: denoland/setup-deno@v2 | |
| if: ${{ matrix.deno }} | |
| with: | |
| deno-version: ${{ matrix.deno }} | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Run Tests node | |
| if: ${{ !matrix.deno }} | |
| run: npm run coverage:test | |
| env: | |
| LOCAL_DB: ${{ steps.setup-env.outputs.database-type }} | |
| DB_TYPE: ${{ matrix.db-type }} | |
| TEST_DB_SERVER_CERT: ${{ matrix.db-type == 'container' && './.github/workflows/certs/ca_server.crt' || '' }} | |
| DB_VERSION: ${{ matrix.db-tag }} | |
| TEST_TRACE: 'true' | |
| LOCAL_SOCKET_AVAILABLE: ${{ steps.setup-env.outputs.database-type }} | |
| - name: Run Tests deno | |
| if: ${{ matrix.deno }} | |
| continue-on-error: true | |
| run: | | |
| deno task test | |
| env: | |
| LOCAL_DB: ${{ steps.setup-env.outputs.database-type }} | |
| DB_TYPE: ${{ matrix.db-type }} | |
| TEST_DB_SERVER_CERT: ${{ matrix.db-type == 'container' && './.github/workflows/certs/ca_server.crt' || '' }} | |
| DB_VERSION: ${{ matrix.db-tag }} | |
| TEST_TRACE: 'true' | |
| LOCAL_SOCKET_AVAILABLE: ${{ steps.setup-env.outputs.database-type }} | |
| - name: Download Codecov uploader | |
| if: ${{ !matrix.deno }} | |
| 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 | |
| if: ${{ !matrix.deno }} | |
| 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 }} |