Skip to content

Commit

Permalink
Upgrade dependencies. Move coverage generating to the CI
Browse files Browse the repository at this point in the history
  • Loading branch information
mgerasimchuk committed Nov 19, 2023
1 parent 2174a45 commit 1f74917
Show file tree
Hide file tree
Showing 18 changed files with 256 additions and 852 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test Integration
name: Test (Integration)
on: push

jobs:
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/test-unit.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test Unit
name: Test (unit)
on: push

jobs:
Expand All @@ -8,3 +8,10 @@ jobs:
- uses: actions/checkout@v3
- name: Test Unit
run: make test-unit
- name: Coverage report
uses: ncruces/[email protected]
with:
badge-title: Coverage (unit)
coverage-file: assets/coverage/unit/coverage.out
report: true
output-dir: assets/coverage/unit
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ logs-verifier:
docker-compose -f ${DOCKER_COMPOSE_FILENAME} logs -f verifier
test-unit: vendor-install
docker run -v $(shell pwd):/app -w /app golang:1.20.0 /bin/bash \
-c 'go test -covermode=count -coverprofile=assets/coverage/coverage.out -v ./internal/... && go tool cover -html=assets/coverage/coverage.out -o=assets/coverage/coverage.html'
-c 'go test -covermode=count -coverprofile=assets/coverage/unit/coverage.out -v ./internal/... && go tool cover -html=assets/coverage/unit/coverage.out -o=assets/coverage/unit/coverage.html'
test-integration-api: start
if ! docker-compose -f ${DOCKER_COMPOSE_FILENAME} run test-integration-api; then \
echo "\nLogs for api from docker-compose:" ;\
Expand All @@ -28,5 +28,7 @@ lint-golangci: vendor-install
lint-architecture:
docker run --rm -v $(shell pwd):/app -w /app golang:1.20.0 /bin/bash \
-c "go install github.com/fdaines/[email protected] && arch-go -v"
generate-go:
docker run --rm -v $(shell pwd):/app -w /app golang:1.20.0 /bin/bash -c 'go install go.uber.org/mock/[email protected] && go generate ./...'
vendor-install:
@if [ -d "vendor" ]; then echo "Vendor folder already exists. Skip vendor installing."; else docker run --rm -v $(shell pwd):/app -w /app golang:1.20.0 /bin/bash -c "go mod tidy && go mod vendor"; fi
58 changes: 10 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
[![Lint Golangci][lint-golangci-badge]][lint-golangci-url]
[![Lint Architecture][lint-architecture-badge]][lint-architecture-url]
[![Test Unit][test-unit-badge]][test-unit-url]
[![Test Integration][test-integration-badge]][test-integration-url]
[![Lint Golangci](https://github.com/mgerasimchuk/space-trouble/actions/workflows/lint-golangci.yml/badge.svg)](https://github.com/mgerasimchuk/space-trouble/actions/workflows/lint-golangci.yml)
[![Lint Architecture](https://github.com/mgerasimchuk/space-trouble/actions/workflows/lint-architecture.yml/badge.svg)](https://github.com/mgerasimchuk/space-trouble/actions/workflows/lint-architecture.yml)
[![Test (unit)](https://github.com/mgerasimchuk/space-trouble/actions/workflows/test-unit.yml/badge.svg)](https://github.com/mgerasimchuk/space-trouble/actions/workflows/test-unit.yml)
[![Coverage (unit)](https://github.com/mgerasimchuk/space-trouble/wiki/assets/coverage/unit/coverage.svg)](https://raw.githack.com/wiki/mgerasimchuk/space-trouble/assets/coverage/unit/coverage.html)
[![Test (integration)](https://github.com/mgerasimchuk/space-trouble/actions/workflows/test-integration.yml/badge.svg)](https://github.com/mgerasimchuk/space-trouble/actions/workflows/test-integration.yml)

# Space Trouble

Solution for the [Space trouble challenge](#space-trouble-challenge)

## Requirements

* [Docker Engine](https://docs.docker.com/engine/) (tested on 20.10.7)
Expand Down Expand Up @@ -55,39 +58,6 @@ See data in DB:
docker-compose -f deployments/docker-compose/docker-compose.yaml run migrations-up bash -c 'psql -c "SELECT * FROM bookings"'
```

## Tests

### Unit

Run tests with generating html coverage report:

```
make test-unit
```

After executing, you can open generated [assets/coverage/coverage.html](https://htmlpreview.github.io/?https://raw.githubusercontent.com/mgerasimchuk/space-trouble/master/assets/coverage/coverage.html)
file in browser for checking coverage

### Integration

```
make test-integration
```

## Linters

### Golangci

```
make lint-golangci
```

### Architecture

```
make lint-architecture
```

## Configuration

See env file: [deployments/docker-compose/.env](deployments/docker-compose/.env)
Expand All @@ -97,9 +67,10 @@ See env file: [deployments/docker-compose/.env](deployments/docker-compose/.env)
As an architectural approach was used
- [The Clean Architecture](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html)

The project layout follows [https://github.com/golang-standards/project-layout](https://github.com/golang-standards/project-layout)
The project layout follows
- [https://github.com/golang-standards/project-layout](https://github.com/golang-standards/project-layout)

## Original Technical Task Description
## Space trouble challenge

Imagine it’s 2049 and you are working for a company called SpaceTrouble that sends people to different places in our
solar system. You are not the only one working in this industry. Your biggest competitor is a less known company called
Expand Down Expand Up @@ -144,12 +115,3 @@ Technical requirements:
* Please, use github or bitbucket.

* Commit your changes often. Do not push the whole project in one commit.

[lint-golangci-badge]: https://github.com/mgerasimchuk/space-trouble/actions/workflows/lint-golangci.yml/badge.svg
[lint-golangci-url]: https://github.com/mgerasimchuk/space-trouble/actions/workflows/lint-golangci.yml
[lint-architecture-badge]: https://github.com/mgerasimchuk/space-trouble/actions/workflows/lint-architecture.yml/badge.svg
[lint-architecture-url]: https://github.com/mgerasimchuk/space-trouble/actions/workflows/lint-architecture.yml
[test-unit-badge]: https://github.com/mgerasimchuk/space-trouble/actions/workflows/test-unit.yml/badge.svg
[test-unit-url]: https://github.com/mgerasimchuk/space-trouble/actions/workflows/test-unit.yml
[test-integration-badge]: https://github.com/mgerasimchuk/space-trouble/actions/workflows/test-integration.yml/badge.svg
[test-integration-url]: https://github.com/mgerasimchuk/space-trouble/actions/workflows/test-integration.yml
Loading

0 comments on commit 1f74917

Please sign in to comment.