frontend(deps): bump the npm_and_yarn group across 1 directory with 7 updates #134
Workflow file for this run
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 | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| env: | |
| GO_VERSION: '1.25.11' | |
| COVERAGE_THRESHOLD: 4 | |
| jobs: | |
| test: | |
| name: Test & Coverage | |
| runs-on: ubuntu-latest | |
| services: | |
| mysql: | |
| image: mysql:8.0 | |
| env: | |
| MYSQL_ROOT_PASSWORD: testpass | |
| MYSQL_DATABASE: gogent_test | |
| ports: | |
| - 3306:3306 | |
| options: >- | |
| --health-cmd="mysqladmin ping" | |
| --health-interval=10s | |
| --health-timeout=5s | |
| --health-retries=3 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| - name: Cache Go modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cache/go-build | |
| ~/go/pkg/mod | |
| key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go- | |
| - name: Install dependencies | |
| run: go mod download | |
| - name: Install sqlc | |
| run: go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest | |
| - name: Generate database code | |
| run: sqlc generate | |
| - name: Run tests with coverage | |
| run: | | |
| go test -v -race -coverprofile=coverage.out -covermode=atomic ./... | |
| go tool cover -html=coverage.out -o coverage.html | |
| - name: Display coverage report | |
| run: | | |
| echo "π Test Coverage Report" | |
| echo "========================" | |
| go tool cover -func=coverage.out | tail -n 10 | |
| echo "========================" | |
| - name: Check coverage threshold | |
| run: | | |
| COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//') | |
| echo "## π Test Coverage Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "| Metric | Value |" >> $GITHUB_STEP_SUMMARY | |
| echo "|--------|-------|" >> $GITHUB_STEP_SUMMARY | |
| echo "| **Total Coverage** | ${COVERAGE}% |" >> $GITHUB_STEP_SUMMARY | |
| echo "| **Threshold** | ${COVERAGE_THRESHOLD}% |" >> $GITHUB_STEP_SUMMARY | |
| if (( $(echo "$COVERAGE >= 80" | bc -l) )); then | |
| STATUS="π’ Excellent" | |
| elif (( $(echo "$COVERAGE >= 70" | bc -l) )); then | |
| STATUS="π‘ Good" | |
| elif (( $(echo "$COVERAGE >= 60" | bc -l) )); then | |
| STATUS="π Fair" | |
| else | |
| STATUS="π΄ Needs Improvement" | |
| fi | |
| echo "| **Status** | $STATUS |" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "::notice title=Test Coverage::Coverage is ${COVERAGE}% (Threshold: ${COVERAGE_THRESHOLD}%)" | |
| if (( $(echo "$COVERAGE < $COVERAGE_THRESHOLD" | bc -l) )); then | |
| echo "::error title=Coverage Below Threshold::Coverage ${COVERAGE}% is below threshold ${COVERAGE_THRESHOLD}%" | |
| exit 1 | |
| else | |
| echo "β Coverage ${COVERAGE}% meets threshold ${COVERAGE_THRESHOLD}%" | |
| fi | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| file: ./coverage.out | |
| flags: unittests | |
| name: codecov-umbrella | |
| fail_ci_if_error: false | |
| security: | |
| name: Security Scan | |
| 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 }} | |
| - name: Install dependencies | |
| run: go mod download | |
| - name: Install sqlc | |
| run: go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest | |
| - name: Generate database code | |
| run: sqlc generate | |
| - name: Install govulncheck | |
| run: go install golang.org/x/vuln/cmd/govulncheck@latest | |
| - name: Run vulnerability scan | |
| run: govulncheck ./... | |
| - name: Install gosec | |
| run: go install github.com/securego/gosec/v2/cmd/gosec@latest | |
| - name: Run Gosec Security Scanner | |
| run: gosec -fmt sarif -out gosec.sarif -exclude-generated -exclude=G101,G112,G115,G201,G202,G401,G501,G706 -exclude-dir=proto -exclude-dir=internal/db ./... || true | |
| continue-on-error: true | |
| - name: Upload SARIF file | |
| uses: github/codeql-action/upload-sarif@v3 | |
| if: always() | |
| with: | |
| sarif_file: gosec.sarif | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| needs: [test, security] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| - name: Install dependencies | |
| run: go mod download | |
| - name: Install sqlc | |
| run: go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest | |
| - name: Generate database code | |
| run: sqlc generate | |
| - name: Build backend | |
| run: | | |
| go build -ldflags="-s -w" -o bin/gogent ./cmd/gogent | |
| ls -la bin/ | |
| - name: Build frontend | |
| run: | | |
| cd frontend | |
| yarn install --frozen-lockfile | |
| npx expo export --platform web --output-dir dist | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-artifacts | |
| path: | | |
| bin/gogent | |
| frontend/dist/ | |
| docker: | |
| name: Docker Build | |
| runs-on: ubuntu-latest | |
| needs: [build] | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: build-artifacts | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build backend Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./Dockerfile.backend | |
| push: false | |
| tags: gogent-backend:latest | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Build frontend Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ./frontend | |
| file: ./frontend/Dockerfile | |
| push: false | |
| tags: gogent-frontend:latest | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| dependency-scan: | |
| name: Dependency Scan | |
| 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 }} | |
| - name: Install dependencies | |
| run: go mod download | |
| - name: Install sqlc | |
| run: go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest | |
| - name: Generate database code | |
| run: sqlc generate | |
| - name: Run dependency review | |
| uses: actions/dependency-review-action@v4 | |
| if: github.event_name == 'pull_request' | |
| - name: Check for outdated dependencies | |
| run: | | |
| go list -u -m all | grep '\[' || echo "All dependencies are up to date" | |
| lint: | |
| name: Lint | |
| 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 }} | |
| - name: Install dependencies | |
| run: go mod download | |
| - name: Install sqlc | |
| run: go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest | |
| - name: Generate database code | |
| run: sqlc generate | |
| - name: golangci-lint | |
| uses: golangci/golangci-lint-action@v8 | |
| with: | |
| version: v2.12.2 | |
| args: --timeout=5m | |
| notify: | |
| name: Notify | |
| runs-on: ubuntu-latest | |
| needs: [test, security, build, docker, dependency-scan, lint] | |
| if: always() | |
| steps: | |
| - name: Notify on success | |
| if: ${{ needs.test.result == 'success' && needs.security.result == 'success' && needs.build.result == 'success' }} | |
| run: echo "β All checks passed successfully!" | |
| - name: Notify on failure | |
| if: ${{ needs.test.result == 'failure' || needs.security.result == 'failure' || needs.build.result == 'failure' }} | |
| run: echo "β Some checks failed. Please review the logs." |