Skip to content

Commit

Permalink
ci: 👷 some changes in ci and formating code (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdihadeli authored Aug 8, 2023
1 parent 6defd6c commit 89ee497
Show file tree
Hide file tree
Showing 168 changed files with 4,794 additions and 3,139 deletions.
46 changes: 30 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ name: CI

on:
push:
branches: ["main", "develop"]
branches: ["main"]
paths-ignore: [ "*.md", "docs", "deploy", "config", ".github", "scripts" ]

pull_request:
branches: ["main", "develop"]
branches: ["main"]
paths-ignore: [ "*.md", "docs", "deploy", "config", ".github", "scripts" ]

jobs:
build:
build-test:
runs-on: ubuntu-latest
if: |
contains(github.event.commits[0].message, '[skip ci]') == false &&
contains(github.event.commits[0].message, '[ci skip]') == false
steps:
- uses: actions/checkout@v3

Expand All @@ -17,25 +23,33 @@ jobs:
uses: actions/setup-go@v3
with:
go-version: 1.20.x
id: go

- name: Cache go modules
id: cache
uses: actions/cache@preview
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: make install-dependencies

# 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 ./...
run: make build

# 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: Unit Tests
run: make unit-test

- name: Catalogs Read Service Tests
working-directory: ./services/catalogs_write/catalogs_read
run: go test -v ./... -race
- name: Integration Tests
run: make integration-test

- name: Order Service Tests
working-directory: ./services/orders
run: go test -v ./... -race
- name: End-To-End Tests
run: make e2e-test
16 changes: 11 additions & 5 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
tags:
- v*
branches:
- develop
- main
pull_request:
permissions:
Expand All @@ -16,15 +15,22 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

# https://github.com/actions/setup-go/issues/326
- uses: actions/setup-go@v3
with:
go-version: '1.19'
- uses: actions/checkout@v3
go-version: 1.20.x

- name: Get dependencies
run: make install-dependencies

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.29
version: latest
skip-pkg-cache: true
skip-build-cache: true

# Optional: working directory, useful for monorepos
# working-directory: somedir
Expand Down
128 changes: 68 additions & 60 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,85 +1,93 @@
.PHONY: install-tools
install-tools:
./scripts/install-tools.sh
@./scripts/install-tools.sh

.PHONY: run
run:
@./scripts/run.sh catalogs_write
@./scripts/run.sh catalogs_read
@./scripts/run.sh orders
.PHONY: run-catalogs-write-service
run-catalogs-write-service:
@./scripts/run.sh catalog_write_service

.PHONY: run-catalog-read-service
run-catalog-read-service:
@./scripts/run.sh catalog_read_service

.PHONY: run-order-service
run-order-service:
@./scripts/run.sh order_service

.PHONY: build
build:
@./scripts/build.sh catalogs_write
@./scripts/build.sh catalogs_read
@./scripts/build.sh orders
@./scripts/build.sh pkg
@./scripts/build.sh catalog_write_service
@./scripts/build.sh catalog_read_service
@./scripts/build.sh order_service

.PHONY: install-dependencies
install-dependencies:
@./scripts/install-dependencies.sh pkg
@./scripts/install-dependencies.sh catalog_write_service
@./scripts/install-dependencies.sh catalog_read_service
@./scripts/install-dependencies.sh order_service

.PHONY: docker
docker-compose_infra_up:
@echo Starting infrastructure docker-compose
docker-compose -f deployments/docker-compose/docker-compose.infrastructure.yaml up --build
.PHONY: docker-compose-infra-up
docker-compose-infra-up:
@docker-compose -f deployments/docker-compose/docker-compose.infrastructure.yaml up --build -d

docker-compose_infra_down:
@echo Stoping infrastructure docker-compose
docker-compose -f deployments/docker-compose/docker-compose.infrastructure.yaml down
docker-compose-infra-down:
@docker-compose -f deployments/docker-compose/docker-compose.infrastructure.yaml down

.PHONY: openapi
openapi:
@./scripts/openapi.sh catalogs_write
@./scripts/openapi.sh catalogs_read
@./scripts/openapi.sh orders
@./scripts/openapi.sh catalog_write_service
@./scripts/openapi.sh catalog_read_service
@./scripts/openapi.sh order_service

# https://stackoverflow.com/questions/13616033/install-protocol-buffers-on-windows
.PHONY: proto
proto:
@./scripts/proto.sh catalogs_write
@./scripts/proto.sh catalogs_read
@./scripts/proto.sh orders

.PHONY: unit_test
unit_test:
@./scripts/test.sh catalogs_write unit
@./scripts/test.sh catalogs_read unit
@./scripts/test.sh orders unit
@./scripts/test.sh pkg unit

.PHONY: integration_test
integration_test:
@./scripts/test.sh catalogs_write integration
@./scripts/test.sh catalogs_read integration
@./scripts/test.sh orders integration
@./scripts/test.sh pkg integration

.PHONY: e2e_test
e2e_test:
@./scripts/test.sh catalogs_write e2e
@./scripts/test.sh catalogs_read e2e
@./scripts/test.sh orders e2e

.PHONY: load_test
load_test:
@./scripts/test.sh catalogs_write load-test
@./scripts/test.sh catalogs_read load-test
@./scripts/test.sh orders load-test
@./scripts/proto.sh catalog_write_service
@./scripts/proto.sh order_service

.PHONY: unit-test
unit-test:
@./scripts/test.sh catalog_write_service unit
@./scripts/test.sh catalog_read_service unit
@./scripts/test.sh order_service unit

.PHONY: integration-test
integration-test:
@./scripts/test.sh catalog_write_service integration
@./scripts/test.sh catalog_read_service integration
@./scripts/test.sh order_service integration

.PHONY: e2e-test
e2e-test:
@./scripts/test.sh catalog_write_service e2e
@./scripts/test.sh catalog_read_service e2e
@./scripts/test.sh order_service e2e

#.PHONY: load-test
#load-test:
# @./scripts/test.sh catalogs_write load-test
# @./scripts/test.sh catalogs_read load-test
# @./scripts/test.sh orders load-test

.PHONY: format
format:
@./scripts/format.sh catalogs_write
@./scripts/format.sh catalogs_read
@./scripts/format.sh orders
@./scripts/format.sh catalog_write_service
@./scripts/format.sh catalog_read_service
@./scripts/format.sh order_service
@./scripts/format.sh pkg

.PHONY: lint
lint:
@./scripts/lint.sh catalogs_write
@./scripts/lint.sh catalogs_read
@./scripts/lint.sh orders
@./scripts/lint.sh catalog_write_service
@./scripts/lint.sh catalog_read_service
@./scripts/lint.sh order_service
@./scripts/lint.sh pkg

.PHONY: c4
c4:
cd tools/c4 && go mod tidy && sh generate.sh
#.PHONY: c4
#c4:
# cd tools/c4 && go mod tidy && sh generate.sh

# https://medium.com/yemeksepeti-teknoloji/mocking-an-interface-using-mockery-in-go-afbcb83cc773
# https://vektra.github.io/mockery/latest/running/
Expand All @@ -92,6 +100,6 @@ pkg-mocks:

.PHONY: services-mocks
services-mocks:
cd internal/services/catalogs_write && mockery --output mocks --all
cd internal/services/catalogs_read && mockery --output mocks --all
cd internal/services/orders && mockery --output mocks --all
cd internal/services/catalog_write_service && mockery --output mocks --all
cd internal/services/catalog_read_service && mockery --output mocks --all
cd internal/services/order_service && mockery --output mocks --all
Empty file removed api/openapi/.gitkeep
Empty file.
Loading

0 comments on commit 89ee497

Please sign in to comment.