diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 29f2ff1..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,105 +0,0 @@ -version: 2.1 - -orbs: - aws-ecr: circleci/aws-ecr@8.2.1 - go: circleci/go@1.9.0 - kubernetes: circleci/kubernetes@1.3.1 - helm: circleci/helm@2.0.1 - -jobs: - build_lint_tests: - machine: - image: ubuntu-2204:2024.01.1 - resource_class: large - steps: - - go/install: - version: "1.21.4" - - checkout - - run: - name: Print Go environment - command: "go env" - - restore_cache: # restores saved cache if no changes are detected since last run - keys: - - go-mod-v6-{{ checksum "go.sum" }} - - add_ssh_keys - - run: - name: Build Staking API Service - command: make build - - save_cache: - key: go-mod-v6-{{ checksum "go.sum" }} - paths: - - "/home/circleci/.go_workspace/pkg/mod" - # TODO: https://github.com/babylonchain/staking-api-service/issues/29 - # - run: - # name: Lint - # command: | - # curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.55.2 - # ./bin/golangci-lint run - - run: - name: Run tests - command: | - make tests - - build_docker: - machine: - image: ubuntu-2204:2024.01.1 - resource_class: large - steps: - - checkout - - add_ssh_keys - - aws-ecr/build-image: - push-image: false - dockerfile: Dockerfile - path: ./contrib/images/staking-api-service/ - build-path: ./ - tag: "$CIRCLE_SHA1,$CIRCLE_TAG" - repo: "staking-api-service" - - run: - name: Save Docker image to export it to workspace - command: | - docker save $(docker image ls --format '{{.Repository}}:{{.Tag}}') > /tmp/staking-api-service.tar - - persist_to_workspace: - root: /tmp - paths: - - staking-api-service.tar - - push_docker: - machine: - image: ubuntu-2204:2024.01.1 - resource_class: large - steps: - - add_ssh_keys - - attach_workspace: - at: /tmp - - run: - name: Load Docker image from workspace - command: | - docker load -i /tmp/staking-api-service.tar - - aws-ecr/ecr-login: - aws-access-key-id: AWS_ACCESS_KEY_ID - aws-secret-access-key: AWS_SECRET_ACCESS_KEY - region: "$AWS_REGION" - - aws-ecr/push-image: - registry-id: AWS_ECR_REGISTRY_ID - region: "$AWS_REGION" - repo: "staking-api-service" - tag: "$CIRCLE_SHA1,$CIRCLE_TAG" - -workflows: - CICD: - jobs: - - build_lint_tests - - build_docker: - filters: - tags: - only: /.*/ - - push_docker: - requires: - - build_docker - filters: - tags: - only: /.*/ - branches: - only: - - main - - dev diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..facc47c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,21 @@ +name: ci + +on: + pull_request: + branches: + - '**' + +jobs: + lint_test: + uses: babylonchain/.github/.github/workflows/reusable_go_lint_test.yml@v0.1.0 + with: + run-unit-tests: true + run-integration-tests: false + run-lint: false + + docker_pipeline: + uses: babylonchain/.github/.github/workflows/reusable_docker_pipeline.yml@v0.1.0 + secrets: inherit + with: + publish: false + dockerfile: ./contrib/images/staking-api-service/Dockerfile \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..8c080e2 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,25 @@ +name: docker_publish + +on: + push: + branches: + - 'main' + - 'dev' + tags: + - '*' + +jobs: + lint_test: + uses: babylonchain/.github/.github/workflows/reusable_go_lint_test.yml@v0.1.0 + with: + run-unit-tests: true + run-integration-tests: false + run-lint: false + + docker_pipeline: + needs: ["lint_test"] + uses: babylonchain/.github/.github/workflows/reusable_docker_pipeline.yml@v0.1.0 + secrets: inherit + with: + publish: true + dockerfile: ./contrib/images/staking-api-service/Dockerfile \ No newline at end of file diff --git a/Makefile b/Makefile index 8108483..95d02aa 100644 --- a/Makefile +++ b/Makefile @@ -59,7 +59,7 @@ run-unprocessed-events-replay-local: generate-mock-interface: cd internal/db && mockery --name=DBClient --output=../../tests/mocks --outpkg=dbmock --filename=mock_db_client.go -tests: +test: ./bin/local-startup.sh; go test -v -cover -p 1 ./... -count=1 diff --git a/bin/local-startup.sh b/bin/local-startup.sh index 5e49df8..6931560 100755 --- a/bin/local-startup.sh +++ b/bin/local-startup.sh @@ -7,7 +7,7 @@ if [ $(docker ps -q -f name=^/${MONGO_CONTAINER_NAME}$) ]; then else echo "Starting MongoDB" # Start MongoDB - docker-compose up mongodb -d + docker-compose up -d mongodb fi # Check if the RabbitMQ container is already running @@ -17,5 +17,6 @@ if [ $(docker ps -q -f name=^/${RABBITMQ_CONTAINER_NAME}$) ]; then else echo "Starting RabbitMQ" # Start RabbitMQ - docker-compose up rabbitmq -d + docker-compose up -d rabbitmq + sleep 10 fi \ No newline at end of file