From 45ae5ff44aec08dac66916bbe412b31b64b4f836 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elza=20Sim=C3=B5es?= Date: Sun, 22 Sep 2024 15:06:16 -0400 Subject: [PATCH] add github actions file (#1) * 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 --- .github/workflows/go.yml | 31 +++++++++++++++++++++++++++++++ Makefile | 5 +++-- docker-compose.yml | 4 +++- 3 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/go.yml 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