From 66db28978404e5f086daf1149990685f23c798a0 Mon Sep 17 00:00:00 2001 From: mehdihadeli Date: Fri, 28 Jul 2023 00:24:16 +0330 Subject: [PATCH] refactor: :recycle: some refactoring --- .github/workflows/ci.yml | 62 +++++++++---------- .../docker-compose.infrastructure.yaml | 16 ++++- .../eventstoredb/eventstoredb_container.go | 2 + 3 files changed, 48 insertions(+), 32 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 471af36b..126c4969 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,40 +2,40 @@ name: CI on: push: - branches: [ "main", "develop" ] + branches: ["main", "develop"] pull_request: - branches: [ "main", "develop" ] + branches: ["main", "develop"] jobs: - build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: 1.19 - - # https://pkg.go.dev/cmd/go#hdr-Compile_packages_and_dependencies - # https://pkg.go.dev/cmd/go#hdr-Package_lists_and_patterns - - name: Build - run: go build.sh -v ./... - - # https://go.dev/doc/articles/race_detector - # https://dev.to/s0xzwasd/run-tests-with-race-flag-in-goland-512j - - name: Building-Blocks Tests - run: go test -v ./... -race - - - name: Catalogs Write Service Tests - working-directory: ./services/catalogs_write/catalogs_write - run: go test -v ./... -race - - - name: Catalogs Read Service Tests - working-directory: ./services/catalogs_write/catalogs_read - run: go test -v ./... -race - - - name: Order Service Tests - working-directory: ./services/orders - run: go test -v ./... -race + - uses: actions/checkout@v3 + + # https://github.com/actions/setup-go/issues/326 + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.20.x + + # https://pkg.go.dev/cmd/go#hdr-Compile_packages_and_dependencies + # https://pkg.go.dev/cmd/go#hdr-Package_lists_and_patterns + - name: Build + run: go build -v ./... + + # https://go.dev/doc/articles/race_detector + # https://dev.to/s0xzwasd/run-tests-with-race-flag-in-goland-512j + - name: Building-Blocks Tests + run: go test -v ./... -race + + - name: Catalogs Write Service Tests + working-directory: ./services/catalogs_write/catalogs_write + run: go test -v ./... -race + + - name: Catalogs Read Service Tests + working-directory: ./services/catalogs_write/catalogs_read + run: go test -v ./... -race + + - name: Order Service Tests + working-directory: ./services/orders + run: go test -v ./... -race diff --git a/deployments/docker-compose/docker-compose.infrastructure.yaml b/deployments/docker-compose/docker-compose.infrastructure.yaml index 0c58c2dd..0802eab9 100644 --- a/deployments/docker-compose/docker-compose.infrastructure.yaml +++ b/deployments/docker-compose/docker-compose.infrastructure.yaml @@ -5,6 +5,7 @@ services: rabbitmq: image: rabbitmq:management container_name: rabbitmq + pull_policy: if_not_present restart: on-failure ports: - ${RABBITMQ_HOST_PORT:-5672}:${RABBITMQ_PORT:-5672} @@ -16,6 +17,7 @@ services: prometheus: image: prom/prometheus:latest + pull_policy: if_not_present container_name: prometheus restart: on-failure user: root @@ -30,6 +32,7 @@ services: node_exporter: container_name: node_exporter + pull_policy: if_not_present restart: on-failure image: prom/node-exporter ports: @@ -39,6 +42,7 @@ services: grafana: container_name: grafana + pull_policy: if_not_present restart: on-failure image: grafana/grafana ports: @@ -48,6 +52,7 @@ services: postgres: image: postgres:latest + pull_policy: if_not_present container_name: postgres restart: on-failure ports: @@ -59,8 +64,11 @@ services: networks: - store + # https://developer.redis.com/howtos/quick-start + # redis-stack is a image with redis modules enabled like JSON module redis: - image: redis:latest + image: redis/redis-stack:latest + pull_policy: if_not_present restart: on-failure container_name: redis ports: @@ -124,6 +132,7 @@ services: mongo: image: mongo + pull_policy: if_not_present container_name: mongo restart: on-failure # https://docs.docker.com/compose/environment-variables/env-file/#parameter-expansion @@ -137,6 +146,7 @@ services: jaeger: container_name: jaeger + pull_policy: if_not_present restart: on-failure image: jaegertracing/all-in-one:latest ports: @@ -148,6 +158,7 @@ services: zipkin: image: openzipkin/zipkin:latest + pull_policy: if_not_present restart: on-failure container_name: zipkin ports: @@ -157,6 +168,7 @@ services: otel-collector: image: otel/opentelemetry-collector-contrib-dev:latest + pull_policy: if_not_present command: ["--config=/etc/otel-collector-config.yaml", ""] volumes: - ./otel-collector-config.yaml:/etc/otel-collector-config.yaml @@ -176,8 +188,10 @@ services: # https://developers.eventstore.com/server/v21.10/installation.html#insecure-single-node # https://hub.docker.com/r/eventstore/eventstore/tags # https://stackoverflow.com/questions/65272764/ports-are-not-available-listen-tcp-0-0-0-0-50070-bind-an-attempt-was-made-to + # EVENTSTORE_MEM_DB=true, it tells the EventStoreDB container to use an in-memory database, which means that any data stored in EventStoreDB will not be persisted between container restarts. Once the container is stopped or restarted, all data will be lost. eventstore: image: eventstore/eventstore:latest + pull_policy: if_not_present container_name: eventstore restart: on-failure environment: diff --git a/internal/pkg/test/containers/testcontainer/eventstoredb/eventstoredb_container.go b/internal/pkg/test/containers/testcontainer/eventstoredb/eventstoredb_container.go index f24e801d..26061d29 100644 --- a/internal/pkg/test/containers/testcontainer/eventstoredb/eventstoredb_container.go +++ b/internal/pkg/test/containers/testcontainer/eventstoredb/eventstoredb_container.go @@ -129,11 +129,13 @@ func (g *eventstoredbTestContainers) getRunOptions( ExposedPorts: g.defaultOptions.Ports, WaitingFor: wait.ForListeningPort(nat.Port(g.defaultOptions.Ports[0])), Hostname: g.defaultOptions.Host, + // we use `EVENTSTORE_IN_MEM` for use eventstoredb in-memory mode in tests Env: map[string]string{ "EVENTSTORE_START_STANDARD_PROJECTIONS": "false", "EVENTSTORE_INSECURE": "true", "EVENTSTORE_ENABLE_EXTERNAL_TCP": "true", "EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP": "true", + //"EVENTSTORE_IN_MEM": "true", }, }