diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 708b1a1dd9..6a139156d6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -21,10 +21,15 @@ jobs: go-version: 1.22 - name: Build - run: go build -o product-catalog-service src/product-catalog/main.go + run: | + cd src/product-catalog + go mod download + go build -o product-catalog-service main.go - name: unit tests - run: go test src/product-catalog/... + run: | + cd src/product-catalog + go test ./... code-quality: runs-on: ubuntu-latest @@ -35,8 +40,9 @@ jobs: - name: Run golangci-lint run: | - go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.2 - golangci-lint run src/product-catalog/... + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.63.4 + cd src/product-catalog + golangci-lint run ./... docker: runs-on: ubuntu-latest @@ -60,9 +66,9 @@ jobs: uses: docker/build-push-action@v6 with: context: src/product-catalog - file: Dockerfile + file: src/product-catalog/Dockerfile push: true - tags: ${{ secrets.DOCKERHUB_USERNAME }}/product-catalog:${{github.run_id}} + tags: ${{ secrets.DOCKER_USERNAME }}/product-catalog:${{github.run_id}} updatek8s: @@ -78,7 +84,7 @@ jobs: - name: Update tag in kubernetes deployment manifest run: | - sed -i 's/image: .*/image: ${{ secrets.DOCKERHUB_USERNAME }}/product-catalog:${{github.run_id}}/' kubernetes/productcatalog/deploy.yaml + sed -i "s|image: .*|image: ${{ secrets.DOCKER_USERNAME }}/product-catalog:${{github.run_id}}|" kubernetes/productcatalog/deploy.yaml - name: Commit and push changes run: | @@ -86,7 +92,7 @@ jobs: git config --global user.name "Abhishek Veeramalla" git add kubernetes/productcatalog/deploy.yaml git commit -m "[CI]: Update product catalog image tag" - git push + git push origin HEAD:main -f diff --git a/src/product-catalog/main.go b/src/product-catalog/main.go index ae6393d994..5c632277e8 100644 --- a/src/product-catalog/main.go +++ b/src/product-catalog/main.go @@ -315,3 +315,6 @@ func createClient(ctx context.Context, svcAddr string) (*grpc.ClientConn, error) grpc.WithStatsHandler(otelgrpc.NewClientHandler()), ) } + + +