Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions .github/workflows/defifundr-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: DefiFundr CI

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

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

- name: Install golangci-lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2

- name: Lint code
run: |
export PATH=$PATH:$(go env GOPATH)/bin
golangci-lint run --timeout=5m

test:
name: Test
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15-alpine
env:
POSTGRES_USER: root
POSTGRES_PASSWORD: secret
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Postgres is used but migration test in ci is not done

POSTGRES_DB: defi
ports:
- 5433:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use version of golang used in the project or upgrade project to current version

cache: true

- name: Install dependencies
run: go mod download

- name: Run tests
run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
env:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check previous CI implementation. Use similar strategies, avoid exposing sensitive data in CI implementation

DB_SOURCE: postgresql://root:secret@localhost:5433/defi?sslmode=disable

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.txt
fail_ci_if_error: false

build:
name: Build
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- name: Checkout code
uses: actions/checkout@v3

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

- name: Build application
run: go build -v -o defifundr_backend ./cmd/api

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: defifundr-backend
path: defifundr_backend
retention-days: 5
39 changes: 39 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
linters:
enable:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reduce sensitivity of linter for now

- gofmt
- govet
- goimports
- gosec
- gosimple
- ineffassign
- misspell
- staticcheck
- unconvert
- unparam
- unused
- revive
- errcheck

linters-settings:
gofmt:
simplify: true
goimports:
local-prefixes: "github.com/DefiFundr-Labs/defifundr_backend"
revive:
rules:
- name: exported
arguments:
- disableStutteringCheck

run:
timeout: 5m
issues-exit-code: 1
tests: true

issues:
max-issues-per-linter: 0
max-same-issues: 0
exclude-rules:
- path: _test\.go
linters:
- gosec
Loading