Skip to content

Commit

Permalink
Use makefile to pass var from github action to docker-compose
Browse files Browse the repository at this point in the history
  • Loading branch information
suprjinx committed Aug 17, 2023
1 parent 759b1cf commit ea96774
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,17 @@ jobs:
with:
go-version: "1.21"

- name: Run Integration Tests
- name: Run Integration Tests (Sqlite)
run: make service-test
env:
DOCKER_BUILDKIT: 1
FML_DATABASE_URI: sqlite://fasttrack-test.db

- name: Run Integration Tests (Postgres)
run: make service-test
env:
DOCKER_BUILDKIT: 1
FML_DATABASE_URI: postgres://postgres:postgres@postgres/postgres

python-integration-tests:
if: github.event_name == 'schedule' || github.event_name == 'push' || github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ endif
ARCHIVE_NAME=dist/fasttrackml_$(shell go env GOOS | sed s/darwin/macos/)_$(shell go env GOARCH | sed s/amd64/x86_64/).$(ARCHIVE_EXT)
ARCHIVE_FILES=$(APP) LICENSE README.md

ifeq ($(FML_DATABASE_URI),)
FML_DATABASE_URI := "sqlite://fasttrackml.db"
endif
#
# Default target (help)
#
Expand Down Expand Up @@ -152,7 +155,7 @@ service-start: service-build service-start-dependencies ## start service in dock
@sleep 5
@echo ">>> Starting service."
@echo ">>> Starting up service container."
@docker-compose up -d service
@docker-compose up -e FML_DATABASE_URI -d service

.PHONY: service-stop
service-stop: ## stop service in docker.
Expand All @@ -166,7 +169,7 @@ service-restart: service-stop service-start ## restart service in docker
service-test: service-stop service-start ## run tests over the service in docker.
@echo ">>> Running tests over service."
@docker-compose \
run integration-tests
run -e FML_DATABASE_URI integration-tests

.PHONY: service-clean
service-clean: ## clean service in docker.
Expand Down
8 changes: 3 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ services:

integration-tests:
image: golang:1.21
command: >-
sh -c
"FML_DATABASE_URI=postgres://postgres:postgres@postgres/postgres make test-go-integration &&
FML_DATABASE_URI=sqlite://fasttrackml-test.db make test-go-integration"
command: make test-go-integration
volumes:
- .:/go/src
- go-cache:/go/pkg
Expand All @@ -42,9 +39,10 @@ services:
- service
environment:
FML_SERVICE_URI: http://service:5000
FML_DATABASE_URI: postgres://postgres:postgres@postgres/postgres
FML_S3_ENDPOINT_URI: http://minio:9000
AWS_ACCESS_KEY_ID: "user"
AWS_SECRET_ACCESS_KEY: "password"

volumes:
go-cache:
go-cache:

0 comments on commit ea96774

Please sign in to comment.