fixed github cicd #8
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: CI/CD Pipeline for Book Tracker API | |
| on: | |
| push: | |
| branches: [ main ] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Step 1: Checkout code | |
| - name: Checkout code | |
| uses: actions/[email protected] | |
| # Step 2: Set up Go environment | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: 1.24 | |
| # Step 3: Install dependencies | |
| - name: Install Dependencies | |
| run: | | |
| go mod tidy | |
| # Step 4: Set up Docker Compose and start services | |
| - name: Set up Docker Compose and start services | |
| uses: hoverkraft-tech/[email protected] | |
| with: | |
| compose-file: "docker-compose.yml" | |
| # Step 5: Run Go Tests Inside Docker | |
| - name: Run Go Tests Inside Docker | |
| run: | | |
| docker compose exec -T app sh -c "go test -v -coverpkg=./internal/db,./internal/handlers,./internal/repository ./tests/... -coverprofile=coverage.out" | |
| # Step 6: Generate and show the coverage report | |
| - name: Generate Coverage Report | |
| run: | | |
| docker compose exec -T app sh -c "go tool cover -func=coverage.out" | |