From 3bff986ac4a53724b728f4efcae9995d725b0ace Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Mon, 27 Nov 2023 18:46:46 +0100 Subject: [PATCH] [CI] Add CRDB integration test Signed-off-by: Knut Ahlers --- .github/workflows/integration-crdb.yml | 61 ++++++++++++ .github/workflows/integration-mariadb.yml | 64 +++++++++++++ .github/workflows/integration-mysql.yml | 64 +++++++++++++ .github/workflows/integration-postgres.yml | 54 +++++++++++ .github/workflows/test-and-build.yml | 102 --------------------- 5 files changed, 243 insertions(+), 102 deletions(-) create mode 100644 .github/workflows/integration-crdb.yml create mode 100644 .github/workflows/integration-mariadb.yml create mode 100644 .github/workflows/integration-mysql.yml create mode 100644 .github/workflows/integration-postgres.yml diff --git a/.github/workflows/integration-crdb.yml b/.github/workflows/integration-crdb.yml new file mode 100644 index 0000000..2c39345 --- /dev/null +++ b/.github/workflows/integration-crdb.yml @@ -0,0 +1,61 @@ +--- + +name: integration-crdb +on: + push: + branches: + - master + +permissions: + contents: write + +jobs: + test: + defaults: + run: + shell: bash + + container: + image: luzifer/archlinux + env: + CGO_ENABLED: 0 + GOPATH: /go + + runs-on: ubuntu-latest + + services: + crdb: + image: luzifer/crdb-gh-service + + steps: + - name: Enable custom AUR package repo + run: echo -e "[luzifer]\nSigLevel = Never\nServer = https://archrepo.hub.luzifer.io/\$arch" >>/etc/pacman.conf + + - name: Install required packages + run: | + pacman -Syy --noconfirm \ + cockroachdb-bin \ + git \ + go \ + make + + - uses: actions/checkout@v3 + + - name: Marking workdir safe + run: git config --global --add safe.directory /__w/twitch-bot/twitch-bot + + - name: Set up CRDB service + run: | + cockroach sql --host crdb --insecure <>/etc/pacman.conf + + - name: Install required packages + run: | + pacman -Syy --noconfirm \ + git \ + go \ + make \ + mariadb-clients + + - uses: actions/checkout@v3 + + - name: Marking workdir safe + run: git config --global --add safe.directory /__w/twitch-bot/twitch-bot + + - name: Set up MariaDB service + run: | + mariadb -h mariadb -u root --password=root-pass <>/etc/pacman.conf + + - name: Install required packages + run: | + pacman -Syy --noconfirm \ + git \ + go \ + make \ + mariadb-clients + + - uses: actions/checkout@v3 + + - name: Marking workdir safe + run: git config --global --add safe.directory /__w/twitch-bot/twitch-bot + + - name: Set up MySQL service + run: | + mariadb -h mysql -u root --password=root-pass <>/etc/pacman.conf + + - name: Install required packages + run: | + pacman -Syy --noconfirm \ + git \ + go \ + make + + - uses: actions/checkout@v3 + + - name: Marking workdir safe + run: git config --global --add safe.directory /__w/twitch-bot/twitch-bot + + - name: Run tests against PostgreSQL + env: + GO_TEST_DB_ENGINE: postgres + GO_TEST_DB_DSN: host=postgres user=postgres password=twitch-bot-pass dbname=postgres port=5432 sslmode=disable timezone=UTC + run: make test + +... diff --git a/.github/workflows/test-and-build.yml b/.github/workflows/test-and-build.yml index 6b83d26..d8fb820 100644 --- a/.github/workflows/test-and-build.yml +++ b/.github/workflows/test-and-build.yml @@ -85,106 +85,4 @@ jobs: draft: false generateReleaseNotes: false - database-integration: - # Only execute db-server integration tests when sqlite based tests did run successfully - needs: [test-and-build] - - defaults: - run: - shell: bash - - container: - image: luzifer/archlinux - env: - CGO_ENABLED: 0 - GOPATH: /go - - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - database: [mariadb, mysql, postgres] - - services: - mariadb: - image: mariadb:11 - env: - MYSQL_PASSWORD: twitch-bot-pass - MYSQL_ROOT_PASSWORD: root-pass - MYSQL_USER: twitch-bot - - mysql: - image: mysql:8 - env: - MYSQL_PASSWORD: twitch-bot-pass - MYSQL_ROOT_PASSWORD: root-pass - MYSQL_USER: twitch-bot - - postgres: - image: postgres:15 - env: - POSTGRES_PASSWORD: twitch-bot-pass - - steps: - - name: Enable custom AUR package repo - run: echo -e "[luzifer]\nSigLevel = Never\nServer = https://archrepo.hub.luzifer.io/\$arch" >>/etc/pacman.conf - - - name: Install required packages - run: | - pacman -Syy --noconfirm \ - docker \ - git \ - go \ - make \ - mariadb-clients - - - uses: actions/checkout@v3 - - - name: Marking workdir safe - run: git config --global --add safe.directory /__w/twitch-bot/twitch-bot - - # --- MySQL - - - name: Set up MySQL service - if: matrix.database == 'mysql' - run: | - mariadb -h mysql -u root --password=root-pass <