Skip to content

Added all unit-tests to CI #12

Added all unit-tests to CI

Added all unit-tests to CI #12

Workflow file for this run

# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Go
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
services:
# Database service containers
postgres:
image: ankane/pgvector:v0.5.1
env:
POSTGRES_USER: root
POSTGRES_PASSWORD: password
POSTGRES_DB: perfkit_pg_vector_db_ci
ports:
- 5432:5432
# Health check to wait until postgres is ready
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
cassandra:
image: cassandra:4.0
env:
CASSANDRA_USER: admin
CASSANDRA_PASSWORD: password
ports:
- 9042:9042
# Health check for Cassandra
options: >-
--health-cmd "cqlsh --debug -e 'select * from system.local' || exit 1"
--health-interval 30s
--health-timeout 10s
--health-retries 5
clickhouse:
image: clickhouse/clickhouse-server:23.9.1.1854-alpine
env:
CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT: 1
CLICKHOUSE_DB: perfkit_db_ci
CLICKHOUSE_USER: username
CLICKHOUSE_PASSWORD: password
ports:
- 8123:8123
- 9000:9000
# Health check for ClickHouse
options: >-
--health-cmd "wget --no-verbose --tries=1 --spider http://localhost:8123/ping || exit 1"
--health-interval 10s
--health-timeout 5s
--health-retries 5
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.15.1
env:
node.name: es-test
cluster.name: es-docker-cluster
bootstrap.memory_lock: true
discovery.type: single-node
ES_JAVA_OPTS: -Xms512m -Xmx512m
xpack.security.enabled: false
xpack.security.http.ssl.enabled: false
xpack.security.transport.ssl.enabled: false
ports:
- 9200:9200
# Health check for Elasticsearch
options: >-
--health-cmd "curl -s http://localhost:9200/_cluster/health || exit 1"
--health-interval 20s
--health-timeout 10s
--health-retries 5
mariadb-vector:
image: mariadb:11.7.2-ubu2404
env:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: perfkit_db_ci
MYSQL_USER: user
MYSQL_PASSWORD: password
# Disable features that cause warnings in GitHub Actions
MARIADB_INNODB_USE_NATIVE_AIO: "0"
ports:
- 3306:3306
# Health check for MariaDB
options: >-
--health-cmd "mysqladmin ping -h localhost -u root -ppassword"
--health-interval 10s
--health-timeout 5s
--health-retries 10
--health-start-period 30s
opensearch:
image: opensearchproject/opensearch:2.17.0
env:
node.name: os-test
discovery.type: single-node
OPENSEARCH_JAVA_OPTS: -Xms512m -Xmx512m
OPENSEARCH_INITIAL_ADMIN_PASSWORD: ScoRpi0n$
ports:
- 9201:9200
- 9600:9600
# Health check for OpenSearch
options: >-
--health-cmd "curl -s http://localhost:9200/_cluster/health || exit 1"
--health-interval 20s
--health-timeout 10s
--health-retries 5
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Install PostgreSQL client
run: sudo apt-get update && sudo apt-get install -y postgresql-client
- name: Create vector extension
run: PGPASSWORD=password psql -h localhost -U root -d perfkit_pg_vector_db_ci -c "CREATE EXTENSION vector;"
- name: Wait for MariaDB
run: |
# Wait for MariaDB to be fully ready
for i in {1..30}; do
if mysqladmin ping -h 127.0.0.1 -u root -ppassword --silent; then
echo "MariaDB is ready"
break
fi
echo "Waiting for MariaDB to be ready... ($i/30)"
sleep 2
done
- name: Test with Coverage
run: go test -v -coverprofile=coverage.txt -covermode=atomic ./db/sql/...
- name: Upload results to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}