Added all unit-tests to CI #41
Workflow file for this run
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: cassandra | |
| CASSANDRA_PASSWORD: cassandra | |
| CASSANDRA_CLUSTER_NAME: test_cluster | |
| CASSANDRA_DC: datacenter1 | |
| CASSANDRA_RACK: rack1 | |
| ports: | |
| - "9042:9042" | |
| # Health check to wait until Cassandra is ready | |
| options: >- | |
| --health-cmd="cqlsh -u cassandra -p cassandra -e 'describe keyspaces' localhost 9042" | |
| --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 and netcat | |
| sudo apt-get install -y curl netcat | |
| 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: | | |
| # First wait for the port to be open | |
| until nc -z localhost 9042; do | |
| echo "Waiting for Cassandra port to be ready..." | |
| sleep 5 | |
| done | |
| # Then wait for Cassandra to be fully initialized | |
| until cqlsh -u cassandra -p cassandra -e 'describe keyspaces' localhost 9042 > /dev/null 2>&1; do | |
| echo "Waiting for Cassandra to be ready..." | |
| sleep 5 | |
| done | |
| echo "Creating Cassandra keyspace..." | |
| cqlsh -u cassandra -p cassandra -e "CREATE KEYSPACE IF NOT EXISTS perfkit_db_ci WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};" localhost 9042 | |
| - 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 |