ci: stronger macOS workaround for cmd package test binary #478
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: CI | |
| on: [push, pull_request] | |
| jobs: | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.22' | |
| - name: golangci-lint | |
| uses: golangci/golangci-lint-action@v6 | |
| with: | |
| version: latest | |
| - name: govulncheck (informational) | |
| continue-on-error: true | |
| run: | | |
| go install golang.org/x/vuln/cmd/govulncheck@latest | |
| govulncheck ./... | |
| - name: Copyright check | |
| run: ./scripts/sanity_check.sh copyright | |
| test: | |
| name: Test (Go ${{ matrix.go-version }}, ${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| go-version: ['1.22', '1.23'] | |
| os: [ubuntu-latest, macos-latest] | |
| env: | |
| GO111MODULE: on | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ matrix.go-version }} | |
| - name: Install libraries (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libncurses6 libaio1t64 libnuma1 bash-completion | |
| - name: Unit tests | |
| run: ./test/go-unit-tests.sh | |
| pxc-test: | |
| name: PXC deployment (${{ matrix.pxc-version }}) | |
| runs-on: ubuntu-22.04 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - pxc-version: '8.0.27-18.1' | |
| pxc-tarball-glibc: '2.17' | |
| pxc-download-series: 'Percona-XtraDB-Cluster-LATEST' | |
| pxc-download-version: 'Percona-XtraDB-Cluster-8.0.27' | |
| - pxc-version: '8.4.8-8.1' | |
| pxc-tarball-glibc: '2.35' | |
| pxc-download-series: 'Percona-XtraDB-Cluster-84' | |
| pxc-download-version: 'Percona-XtraDB-Cluster-8.4.8' | |
| env: | |
| GO111MODULE: on | |
| SANDBOX_BINARY: ${{ github.workspace }}/opt/mysql | |
| PXC_VERSION: ${{ matrix.pxc-version }} | |
| PXC_TARBALL_GLIBC: ${{ matrix.pxc-tarball-glibc }} | |
| PXC_DOWNLOAD_SERIES: ${{ matrix.pxc-download-series }} | |
| PXC_DOWNLOAD_VERSION: ${{ matrix.pxc-download-version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.22' | |
| - name: Install system libraries | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libaio1 libnuma1 libncurses5 libldap-2.5-0 socat | |
| - name: Provide LDAP compatibility shim | |
| run: | | |
| sudo ldconfig | |
| LDAP_LIB=$(ldconfig -p | awk ' | |
| /libldap[^ ]*\.so\./ && $NF !~ /libldap_r-2\.4\.so\.2$/ { | |
| print $NF | |
| exit | |
| }') | |
| if [ -z "$LDAP_LIB" ] || [ ! -e "$LDAP_LIB" ]; then | |
| LDAP_LIB=$(find /usr/lib /lib -type f -name 'libldap*.so*' ! -name 'libldap_r-2.4.so.2' | sort | head -1) | |
| fi | |
| if [ -z "$LDAP_LIB" ] || [ ! -e "$LDAP_LIB" ]; then | |
| echo "Unable to locate a libldap shared object" >&2 | |
| ldconfig -p | grep ldap >&2 || true | |
| find /usr/lib /lib -name 'libldap*.so*' | sort >&2 || true | |
| exit 1 | |
| fi | |
| sudo ln -sf "$LDAP_LIB" /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2 | |
| sudo ln -sf "$LDAP_LIB" /lib/x86_64-linux-gnu/libldap_r-2.4.so.2 | |
| sudo ldconfig | |
| - name: Build dbdeployer | |
| run: go build -o dbdeployer . | |
| - name: Download and unpack PXC | |
| run: | | |
| TARBALL="Percona-XtraDB-Cluster_${PXC_VERSION}_Linux.x86_64.glibc${PXC_TARBALL_GLIBC}-minimal.tar.gz" | |
| URL="https://downloads.percona.com/downloads/${PXC_DOWNLOAD_SERIES}/${PXC_DOWNLOAD_VERSION}/binary/tarball/$TARBALL" | |
| mkdir -p "$SANDBOX_BINARY" | |
| curl -L -f --retry 5 --retry-all-errors --retry-delay 2 -o "/tmp/$TARBALL" "$URL" | |
| ./dbdeployer unpack "/tmp/$TARBALL" --sandbox-binary="$SANDBOX_BINARY" | |
| - name: Test PXC replication deployment | |
| run: | | |
| VERSION=$(ls "$SANDBOX_BINARY" | head -1) | |
| ./dbdeployer deploy replication "$VERSION" --topology=pxc --sandbox-binary="$SANDBOX_BINARY" | |
| SBDIR=$(ls -d ~/sandboxes/pxc_msb_*) | |
| echo "Waiting for PXC nodes to be ready..." | |
| for i in $(seq 1 30); do | |
| "$SBDIR/check_nodes" && break | |
| sleep 2 | |
| done | |
| "$SBDIR/check_nodes" | |
| # Extra safety: ensure the primary node is ready for application use | |
| # before running grants (already waited inside deploy) and before DML. | |
| for i in $(seq 1 30); do | |
| "$SBDIR/n1" -BN -e "SHOW STATUS LIKE 'wsrep_ready';" 2>/dev/null | grep -qi 'ON' && break | |
| echo " Waiting for wsrep_ready on n1... ($i/30)" | |
| sleep 2 | |
| done | |
| "$SBDIR/n1" -e "CREATE DATABASE ci_test; USE ci_test; CREATE TABLE t1(id INT PRIMARY KEY, val VARCHAR(50)); INSERT INTO t1 VALUES (1, 'pxc_ci_test');" | |
| for i in $(seq 1 10); do | |
| RESULT=$("$SBDIR/n3" -BN -e "SELECT val FROM ci_test.t1;" 2>/dev/null) || true | |
| echo "$RESULT" | grep -q "pxc_ci_test" && break | |
| sleep 2 | |
| done | |
| echo "$RESULT" | grep -q "pxc_ci_test" | |
| ./dbdeployer delete all --skip-confirm | |
| - name: Cleanup | |
| if: always() | |
| run: | | |
| ./dbdeployer delete all --skip-confirm 2>/dev/null || true | |
| pkill -9 -u "$USER" mysqld 2>/dev/null || true | |
| mariadb-galera-test: | |
| name: MariaDB Galera (${{ matrix.mariadb-galera-version }}) | |
| runs-on: ubuntu-22.04 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - mariadb-galera-version: '10.11.16' | |
| legacy-openssl: true | |
| - mariadb-galera-version: '11.8.6' | |
| legacy-openssl: true | |
| env: | |
| GO111MODULE: on | |
| SANDBOX_BINARY: ${{ github.workspace }}/opt/mysql | |
| MARIADB_GALERA_VERSION: ${{ matrix.mariadb-galera-version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.22' | |
| - name: Install system libraries | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libaio1 libnuma1 libncurses5 libldap-2.5-0 socat | |
| - name: Install legacy OpenSSL 1.0 | |
| if: ${{ matrix.legacy-openssl }} | |
| run: | | |
| echo "deb [trusted=yes] http://archive.ubuntu.com/ubuntu bionic-security main" | sudo tee /etc/apt/sources.list.d/bionic-security.list | |
| sudo apt-get update | |
| sudo apt-get install -y libssl1.0.0 | |
| - name: Provide LDAP compatibility shim | |
| run: | | |
| sudo ldconfig | |
| LDAP_LIB=$(ldconfig -p | awk ' | |
| /libldap[^ ]*\.so\./ && $NF !~ /libldap_r-2\.4\.so\.2$/ { | |
| print $NF | |
| exit | |
| }') | |
| if [ -z "$LDAP_LIB" ] || [ ! -e "$LDAP_LIB" ]; then | |
| LDAP_LIB=$(find /usr/lib /lib -type f -name 'libldap*.so*' ! -name 'libldap_r-2.4.so.2' | sort | head -1) | |
| fi | |
| if [ -z "$LDAP_LIB" ] || [ ! -e "$LDAP_LIB" ]; then | |
| echo "Unable to locate a libldap shared object" >&2 | |
| ldconfig -p | grep ldap >&2 || true | |
| find /usr/lib /lib -name 'libldap*.so*' | sort >&2 || true | |
| exit 1 | |
| fi | |
| sudo ln -sf "$LDAP_LIB" /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2 | |
| sudo ln -sf "$LDAP_LIB" /lib/x86_64-linux-gnu/libldap_r-2.4.so.2 | |
| sudo ldconfig | |
| - name: Build dbdeployer | |
| run: go build -o dbdeployer . | |
| - name: Download and unpack MariaDB Galera tarball | |
| run: | | |
| TARBALL="mariadb-${MARIADB_GALERA_VERSION}-linux-systemd-x86_64.tar.gz" | |
| URL="https://archive.mariadb.org/mariadb-${MARIADB_GALERA_VERSION}/bintar-linux-systemd-x86_64/$TARBALL" | |
| mkdir -p "$SANDBOX_BINARY" | |
| curl -L -f --retry 5 --retry-all-errors --retry-delay 2 -o "/tmp/$TARBALL" "$URL" | |
| ./dbdeployer unpack "/tmp/$TARBALL" --sandbox-binary="$SANDBOX_BINARY" | |
| - name: Test MariaDB Galera replication deployment | |
| run: | | |
| VERSION=$(ls "$SANDBOX_BINARY" | head -1) | |
| ./dbdeployer deploy replication "$VERSION" --topology=galera --sandbox-binary="$SANDBOX_BINARY" | |
| SBDIR=$(ls -d ~/sandboxes/galera_msb_*) | |
| echo "Waiting for Galera nodes to be ready..." | |
| for i in $(seq 1 30); do | |
| "$SBDIR/check_nodes" && break | |
| sleep 2 | |
| done | |
| "$SBDIR/check_nodes" | |
| # Ensure the primary is application-ready before grants/DML | |
| for i in $(seq 1 30); do | |
| "$SBDIR/n1" -BN -e "SHOW STATUS LIKE 'wsrep_ready';" 2>/dev/null | grep -qi 'ON' && break | |
| echo " Waiting for wsrep_ready on n1... ($i/30)" | |
| sleep 2 | |
| done | |
| "$SBDIR/n1" -e "CREATE DATABASE ci_test; USE ci_test; CREATE TABLE t1(id INT PRIMARY KEY, val VARCHAR(50)); INSERT INTO t1 VALUES (1, 'galera_ci_test');" | |
| for i in $(seq 1 10); do | |
| RESULT=$("$SBDIR/n3" -BN -e "SELECT val FROM ci_test.t1;" 2>/dev/null) || true | |
| echo "$RESULT" | grep -q "galera_ci_test" && break | |
| sleep 2 | |
| done | |
| echo "$RESULT" | grep -q "galera_ci_test" | |
| ./dbdeployer delete all --skip-confirm | |
| - name: Cleanup | |
| if: always() | |
| run: | | |
| ./dbdeployer delete all --skip-confirm 2>/dev/null || true | |
| pkill -9 -u "$USER" mysqld 2>/dev/null || true | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| needs: [lint, test, pxc-test, mariadb-galera-test] | |
| env: | |
| GO111MODULE: on | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.22' | |
| - name: Build | |
| run: ./scripts/build.sh linux | |
| - name: Verify executable | |
| run: | | |
| version=$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//') | |
| if [ -z "$version" ]; then version="dev"; fi | |
| test -f "dbdeployer-${version}.linux" || exit 1 |