Skip to content

Commit

Permalink
add github actions file (#1)
Browse files Browse the repository at this point in the history
* add github actions file

* add golangci/golangci-lint-actions@v6

* add golangci/golangci-lint-actions@v6

* fix actions

* fix golangci/golangci-lint-action@v6

* fix controllers

* fix database

* add secrets

* fix run syntax
  • Loading branch information
elzasimoes authored Sep 22, 2024
1 parent 0fa44f9 commit 45ae5ff
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Integração Contínua

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:

ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'

- name: Inicia banco
run: docker compose up -d postgres

- name: Lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.59
args: controllers/ database/ models/ routes/

- name: Test
run: DB_HOST=${{ secrets.DB_HOST }} DB_PASSWORD=${{ secrets.DB_PASSWORD }} DB_USER=${{ secrets.DB_USER }} DB_NAME=${{ secrets.DB_NAME }} DB_PORT=${{ secrets.DB_PORT }} go test -v main_test.go
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ test:
docker compose exec app go test main_test.go

start:
docker compose up -d
docker compose up -d

ci: start lint test
ci:
start lint test



4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ services:
- POSTGRES_USER=root
- POSTGRES_PASSWORD=root
- POSTGRES_DB=root
ports:
- 5432:5432
volumes:
- ./postgres-data:/var/lib/postgresql/data

Expand All @@ -22,7 +24,7 @@ services:
depends_on:
- postgres
environment:
- DB_HOST=postgres
- DB_HOST=localhost
- DB_USER=root
- DB_PASSWORD=root
- DB_NAME=root
Expand Down

0 comments on commit 45ae5ff

Please sign in to comment.