-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e2a126
commit 7928949
Showing
4 changed files
with
56 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
lint: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.22.3' | ||
cache: true | ||
- uses: actions/checkout@v3 | ||
- name: golangci-lint | ||
uses: golangci/[email protected] | ||
with: | ||
version: latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,33 @@ | ||
COMPOSE_TEST_FILE="${PWD}/docker-compose-test.yaml" | ||
|
||
fmt: | ||
go fmt ./... | ||
COMPOSE_FILE=${COMPOSE_TEST_FILE} docker compose run --rm --remove-orphans api go fmt | ||
.PHONY:fmt | ||
|
||
lint: fmt | ||
golangci-lint run -v | ||
COMPOSE_FILE=${COMPOSE_TEST_FILE} docker compose run --rm --remove-orphans api golangci-lint run -v | ||
.PHONY:lint | ||
|
||
vet: lint | ||
go vet ./... | ||
.PHONY:vet | ||
|
||
build: | ||
docker build . -t "url-short:latest" | ||
docker build . -t "url-short:latest" | ||
.PHONY:build | ||
|
||
build/test: | ||
docker build . -t "url-short:test" --target tester | ||
.PHONY:build/test | ||
|
||
run: | ||
docker compose up -d | ||
docker compose up -d | ||
.PHONY:run | ||
|
||
stop: | ||
docker compose down | ||
docker compose down | ||
.PHONY:stop | ||
|
||
test: | ||
docker build . -t "url-short:test" --target tester | ||
docker run -t "url-short:test" | ||
COMPOSE_FILE=${COMPOSE_TEST_FILE} docker compose run --rm --remove-orphans api go test ./... | ||
.PHONY:test | ||
|
||
migrate: | ||
goose -dir sql/schema postgres "postgres://url_short:password@localhost:5002/url_short" up | ||
goose -dir sql/schema postgres "postgres://url_short:password@localhost:5002/url_short" up | ||
.PHONY:migrate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: '3.1' | ||
|
||
services: | ||
api: | ||
image: url-short:test | ||
env_file: | ||
- .env | ||
volumes: | ||
- ./:/opt/url-short | ||
|