Skip to content

Added all unit-tests to CI #20

Added all unit-tests to CI

Added all unit-tests to CI #20

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
mariadb-vector:
image: mariadb:11.7.2
env:
MARIADB_DATABASE: perfkit_db_ci
MARIADB_USER: user
MARIADB_PASSWORD: password # example value of a secret
MARIADB_ROOT_PASSWORD: password # example value of a secret
ports:
- 3306:3306
# Additional options to handle GitHub Actions environment limitations
options: >-
--health-cmd="healthcheck.sh --connect --innodb_initialized"
--health-interval=10s
--health-timeout=5s
--health-retries=3
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
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
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Install database clients
run: |
# Install PostgreSQL client
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: Test with Coverage
run: |
go test -v -coverprofile=benchmark_coverage.txt -covermode=atomic ./benchmark/...
go test -v -coverprofile=logger_coverage.txt -covermode=atomic ./logger/...
go test -v -coverprofile=restrelay_coverage.txt -covermode=atomic ./acronis-restrelay-bench/...
go test -v -coverprofile=sql_coverage.txt -covermode=atomic ./db/sql/...
go test -v -coverprofile=es_coverage.txt -covermode=atomic ./db/es/...
go test -v -coverprofile=pgmbed_coverage.txt -covermode=atomic ./db/pgmbed/...
go test -v -coverprofile=optimize_coverage.txt -covermode=atomic ./db/optimize/...
- name: Upload results to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: benchmark_coverage.txt,logger_coverage.txt,restrelay_coverage.txt,sql_coverage.txt,es_coverage.txt,pgmbed_coverage.txt,optimize_coverage.txt
fail_ci_if_error: true