From c29cadecdaddc7458ef1b22a4ec4964fc9344f9a Mon Sep 17 00:00:00 2001 From: elza Date: Sun, 22 Sep 2024 14:22:48 -0400 Subject: [PATCH 1/9] add github actions file --- .github/workflows/go.yml | 28 ++++++++++++++++++++++++++++ Makefile | 5 +++-- 2 files changed, 31 insertions(+), 2 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..b9ee247 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,28 @@ +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 + run: docker run --rm -itv $(pwd):/app -w /app golangci/golangci-lint golangci-lint run controllers/ database/ models/ routes/ + + - name: Test + run: 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 From 3bd7eca0bba16d62bd5910aa087cda47e52deb60 Mon Sep 17 00:00:00 2001 From: elza Date: Sun, 22 Sep 2024 14:33:51 -0400 Subject: [PATCH 2/9] add golangci/golangci-lint-actions@v6 --- .github/workflows/go.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index b9ee247..5bec02b 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -22,7 +22,9 @@ jobs: run: docker compose up -d postgres - name: Lint - run: docker run --rm -itv $(pwd):/app -w /app golangci/golangci-lint golangci-lint run controllers/ database/ models/ routes/ + uses: golangci/golangci-lint-actions@v6 + with: + version: v1.59 - name: Test run: go test -v main_test.go \ No newline at end of file From 77b06793d8f8a514f5a026941a84216ebfc983db Mon Sep 17 00:00:00 2001 From: elza Date: Sun, 22 Sep 2024 14:35:09 -0400 Subject: [PATCH 3/9] add golangci/golangci-lint-actions@v6 --- .github/workflows/go.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 5bec02b..45785cb 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -25,6 +25,7 @@ jobs: uses: golangci/golangci-lint-actions@v6 with: version: v1.59 + args: controlers/ database/ models/ routes/ - name: Test run: go test -v main_test.go \ No newline at end of file From 299fffce5d8352ede950d4919509b92f85da269a Mon Sep 17 00:00:00 2001 From: elza Date: Sun, 22 Sep 2024 14:38:31 -0400 Subject: [PATCH 4/9] fix actions --- .github/workflows/go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 45785cb..ee6afbe 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -22,7 +22,7 @@ jobs: run: docker compose up -d postgres - name: Lint - uses: golangci/golangci-lint-actions@v6 + uses: actions/golangci/golangci-lint-actions@v6 with: version: v1.59 args: controlers/ database/ models/ routes/ From 7a26f01b8e692a4314d3b3b5c3032300d6b73260 Mon Sep 17 00:00:00 2001 From: elza Date: Sun, 22 Sep 2024 14:41:06 -0400 Subject: [PATCH 5/9] fix golangci/golangci-lint-action@v6 --- .github/workflows/go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index ee6afbe..aa139d8 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -22,7 +22,7 @@ jobs: run: docker compose up -d postgres - name: Lint - uses: actions/golangci/golangci-lint-actions@v6 + uses: golangci/golangci-lint-action@v6 with: version: v1.59 args: controlers/ database/ models/ routes/ From 785dac5f21411e516110e4b4ec53004408ed612e Mon Sep 17 00:00:00 2001 From: elza Date: Sun, 22 Sep 2024 14:42:55 -0400 Subject: [PATCH 6/9] fix controllers --- .github/workflows/go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index aa139d8..4a451fe 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -25,7 +25,7 @@ jobs: uses: golangci/golangci-lint-action@v6 with: version: v1.59 - args: controlers/ database/ models/ routes/ + args: controllers/ database/ models/ routes/ - name: Test run: go test -v main_test.go \ No newline at end of file From 21717e15bbb7ca297fc41515fa87763f16310aed Mon Sep 17 00:00:00 2001 From: elza Date: Sun, 22 Sep 2024 14:51:26 -0400 Subject: [PATCH 7/9] fix database --- docker-compose.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 From 88eeb2026d1ec93079b89dd97467900ef1b2ef03 Mon Sep 17 00:00:00 2001 From: elza Date: Sun, 22 Sep 2024 14:58:00 -0400 Subject: [PATCH 8/9] add secrets --- .github/workflows/go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 4a451fe..63a4b88 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -28,4 +28,4 @@ jobs: args: controllers/ database/ models/ routes/ - name: Test - run: go test -v main_test.go \ No newline at end of file + 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 From 734a6869a9f905d40c8b24f0b211132d75d52bbc Mon Sep 17 00:00:00 2001 From: elza Date: Sun, 22 Sep 2024 15:02:30 -0400 Subject: [PATCH 9/9] fix run syntax --- .github/workflows/go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 63a4b88..2270f88 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -28,4 +28,4 @@ jobs: 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 + 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