Added all unit-tests to CI #36
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
| # 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 | |
| cassandra: | |
| image: cassandra:4.0 | |
| env: | |
| CASSANDRA_USER: admin | |
| CASSANDRA_PASSWORD: password | |
| ports: | |
| - "9042:9042" | |
| # Health check to wait until Cassandra is ready | |
| options: >- | |
| --health-cmd="cqlsh localhost 9042 --execute='describe keyspaces'" | |
| --health-interval=10s | |
| --health-timeout=5s | |
| --health-retries=10 | |
| --health-start-period=30s | |
| 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 | |
| clickhouse: | |
| image: clickhouse/clickhouse-server:24.10-alpine | |
| env: | |
| CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT: 1 | |
| CLICKHOUSE_DB: perfkit_db_ci | |
| CLICKHOUSE_USER: username | |
| CLICKHOUSE_PASSWORD: password # example value of a secret | |
| ports: | |
| - "8123:8123" | |
| - "9000:9000" | |
| 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: -Xms1g -Xmx1g | |
| xpack.security.enabled: false | |
| xpack.security.http.ssl.enabled: false | |
| xpack.security.transport.ssl.enabled: false | |
| action.auto_create_index: true | |
| ports: | |
| - 9200:9200 | |
| # Health check for Elasticsearch | |
| options: >- | |
| --health-cmd "curl -s http://127.0.0.1:9200/_cluster/health?wait_for_status=yellow&timeout=30s || exit 1" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 10 | |
| 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 | |
| # Install Cassandra client | |
| sudo apt-get install -y curl | |
| curl -fsSL https://www.apache.org/dist/cassandra/KEYS | sudo gpg --dearmor -o /usr/share/keyrings/cassandra-archive-keyring.gpg | |
| echo "deb [signed-by=/usr/share/keyrings/cassandra-archive-keyring.gpg] https://apache.jfrog.io/artifactory/cassandra-deb/ 40x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list | |
| sudo apt-get update | |
| sudo apt-get install -y cassandra-tools | |
| - name: Create Cassandra keyspace | |
| run: | | |
| # Wait for Cassandra to be ready | |
| until cqlsh -u cassandra -p cassandra localhost 9042 --execute='describe keyspaces' > /dev/null 2>&1; do | |
| echo "Waiting for Cassandra to be ready..." | |
| sleep 5 | |
| done | |
| echo "Creating Cassandra keyspace..." | |
| cqlsh -u cassandra -p cassandra localhost 9042 --execute="CREATE KEYSPACE IF NOT EXISTS perfkit_db_ci WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};" | |
| - 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=db_coverage.txt -covermode=atomic ./db/... | |
| go test -v -coverprofile=db_bench_coverage.txt -covermode=atomic ./acronis-db-bench/... | |
| - 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,db_coverage.txt,db_bench_coverage.txt | |
| fail_ci_if_error: true |