Merge pull request #8 from alainrk/autosavenew #81
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Pull Request | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| env: | |
| GO_VERSION: "1.24" | |
| GOLANGCI_LINT_VERSION: "v2.2.1" | |
| jobs: | |
| lint: | |
| name: Lint Code | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| cache: true | |
| - name: Install golangci-lint | |
| uses: golangci/golangci-lint-action@v7 | |
| with: | |
| version: ${{ env.GOLANGCI_LINT_VERSION }} | |
| skip-cache: true | |
| skip-pkg-cache: true | |
| skip-build-cache: true | |
| - name: Run linter | |
| run: make lint | |
| test: | |
| name: Test | |
| runs-on: ubuntu-latest | |
| needs: lint | |
| services: | |
| postgres: | |
| image: postgres:11-alpine | |
| env: | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: postgres | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| cache: true | |
| - name: Install dependencies | |
| run: | | |
| go mod download | |
| go install gotest.tools/gotestsum@latest | |
| go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest | |
| - name: Run tests | |
| env: | |
| DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable | |
| TELEGRAM_BOT_API_TOKEN: dummy_token_for_ci | |
| OPENAI_API_KEY: dummy_key_for_ci | |
| OPENAI_BASE_URL: https://api.example.com/v1 | |
| LLM_MODEL: dummy-model | |
| RUN_MODE: polling | |
| LOG_LEVEL: info | |
| run: | | |
| # Run migrations first | |
| go run ./cmd/migrate/main.go -command up | |
| make test-ci | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| file: /tmp/coverage.out | |
| flags: unittests | |
| name: codecov-umbrella | |
| fail_ci_if_error: false | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| needs: [lint, test] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| cache: true | |
| - name: Build binary | |
| env: | |
| CGO_ENABLED: 0 | |
| run: | | |
| output_name="cashout" | |
| go build -ldflags="-w -s -X main.version=${{ github.ref_name }}" \ | |
| -o=bin/${output_name} \ | |
| ./cmd/server/main.go | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: cashout | |
| path: bin/* | |
| retention-days: 7 | |
| code-quality: | |
| name: Code Quality Analysis | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| cache: true | |
| - name: Run go vet | |
| run: make vet | |
| - name: Run go mod tidy check | |
| run: | | |
| go mod tidy | |
| git diff --exit-code go.mod go.sum | |
| - name: Check code formatting | |
| run: | | |
| if [ -n "$(gofmt -l .)" ]; then | |
| echo "The following files need formatting:" | |
| gofmt -l . | |
| exit 1 | |
| fi | |
| dependency-check: | |
| name: Dependency Security Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| cache: true | |
| # https://github.com/DependencyTrack/dependency-track/issues/5371 | |
| # - name: Run Nancy dependency check | |
| # run: | | |
| # go install github.com/sonatype-nexus-community/nancy@latest | |
| # go list -json -deps ./... | nancy sleuth | |
| - name: Run govulncheck | |
| run: | | |
| go install golang.org/x/vuln/cmd/govulncheck@latest | |
| govulncheck ./... |