diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..2270f88 --- /dev/null +++ b/.github/workflows/go.yml @@ -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 \ No newline at end of file diff --git a/Makefile b/Makefile index 3cfe603..0580a77 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index 58ee897..5151d33 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,6 +5,8 @@ services: - POSTGRES_USER=root - POSTGRES_PASSWORD=root - POSTGRES_DB=root + ports: + - 5432:5432 volumes: - ./postgres-data:/var/lib/postgresql/data @@ -22,7 +24,7 @@ services: depends_on: - postgres environment: - - DB_HOST=postgres + - DB_HOST=localhost - DB_USER=root - DB_PASSWORD=root - DB_NAME=root