Skip to content

Commit

Permalink
Configure github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mgerasimchuk committed Oct 26, 2023
1 parent ea79828 commit 28ae58a
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 14 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Test Integration
on: push

jobs:
test-integration-api:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Test Integration
run: make test-integration-api
16 changes: 16 additions & 0 deletions .github/workflows/test-unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Test Unit
on: push

jobs:
test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Test Unit
run: make test-unit
# test-integration-api:
# runs-on: ubuntu-22.04
# steps:
# - uses: actions/checkout@v3
# - name: Test Unit
# run: make test-integration-api
19 changes: 12 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
DOCKER_COMPOSE_FILENAME=deployments/docker-compose/docker-compose.yaml

start: vendor-install
docker-compose -f ${DOCKER_COMPOSE_FILENAME} down -v --remove-orphans ; docker-compose -f ${DOCKER_COMPOSE_FILENAME} up -d
start-from-scratch: vendor-install
docker-compose -f ${DOCKER_COMPOSE_FILENAME} down -v --remove-orphans ; docker-compose -f ${DOCKER_COMPOSE_FILENAME} up --build -d
docker-compose -f ${DOCKER_COMPOSE_FILENAME} up -d
start-from-scratch: stop
docker-compose --file ${DOCKER_COMPOSE_FILENAME} --profile httpapi up --remove-orphans --renew-anon-volumes --force-recreate --build -d
stop:
docker-compose -f ${DOCKER_COMPOSE_FILENAME} down
restart: stop start
logs-api:
docker-compose -f ${DOCKER_COMPOSE_FILENAME} logs -f api
logs-verifier:
docker-compose -f ${DOCKER_COMPOSE_FILENAME} logs -f verifier
test:
docker run -v $(shell pwd):/app golang:1.20.0 /bin/bash -c 'cd /app && GO111MODULE=on go test -mod vendor -covermode=count -coverprofile=assets/coverage/coverage.out -v ./... && go tool cover -html=assets/coverage/coverage.out -o=assets/coverage/coverage.html'
test-integration-api:
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'
test-integration-api: start
docker-compose -f ${DOCKER_COMPOSE_FILENAME} run test-integration-api
lint-golangci: vendor-install
docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:v1.50.1 \
golangci-lint run --timeout 5m30s -v
lint-architecture:
docker run --rm -v $(shell pwd):/app -w /app golang:1.20.0 /bin/bash -c "go install github.com/fdaines/arch-go@v1.4.2 && arch-go -v"
docker run --rm -v $(shell pwd):/app -w /app golang:1.20.0 /bin/bash \
-c "go install github.com/fdaines/arch-go@v1.4.2 && arch-go -v"
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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![Test Unit][test-unit-badge]][test-unit-url]

# Space Trouble

## Requirements
Expand Down Expand Up @@ -117,3 +119,6 @@ Technical requirements:
* Please, use github or bitbucket.

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

[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
2 changes: 0 additions & 2 deletions deployments/docker-compose/.env
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# 6 - TraceLevel
LOG_LEVEL: 4


DB_HOST: db
DB_PORT: 5432
DB_NAME: postgres
Expand All @@ -19,7 +18,6 @@ LAUNCHPAD_API_BASE_URI: "https://api.spacexdata.com"

LANDPAD_API_BASE_URI: "https://api.spacexdata.com"

HTTPSERVER:
HTTP_SERVER_PORT: 8080
# see: vendor/github.com/gin-gonic/gin/mode.go
# debug
Expand Down
14 changes: 9 additions & 5 deletions deployments/docker-compose/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ services:
api:
image: golang:1.20.0
restart: "no"
env_file:
- ./../../deployments/docker-compose/.env
depends_on:
- "db"
env_file:
- ./../../deployments/docker-compose/.env
working_dir: /app
volumes:
- ./../../:/app
ports:
Expand All @@ -16,10 +17,11 @@ services:
verifier:
image: golang:1.20.0
restart: "no"
env_file:
- ./../../deployments/docker-compose/.env
depends_on:
- "db"
env_file:
- ./../../deployments/docker-compose/.env
working_dir: /app
volumes:
- ./../../:/app
entrypoint: bash -c 'while !</dev/tcp/db/5432; do sleep 1; done; go run /app/cmd/verifier/main.go'
Expand Down Expand Up @@ -84,4 +86,6 @@ services:
SERVER_URL: "http://api:8080"
volumes:
- ./../../:/app
entrypoint: "/bin/bash -c 'go test -count=1 -v ./test/integration/api'"
entrypoint: |
/bin/bash -c 'until $$(curl --output /dev/null --silent --fail $$SERVER_URL/v1/bookings); do printf '.'; sleep 1; done &&\
go test -count=1 -v ./test/integration/api'

0 comments on commit 28ae58a

Please sign in to comment.