-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Implement Inventory (Product) microservice with full CRUD, Helm chart, ArgoCD, and CI/CD #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
devin-ai-integration
wants to merge
1
commit into
main
Choose a base branch
from
feature/inventory-microservice-decomposition
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| name: Inventory Service CI/CD | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - 'src/Services/Product/**' | ||
| - 'src/Shared/**' | ||
| - 'deploy/helm/inventory-service/**' | ||
| pull_request: | ||
| branches: [main] | ||
| paths: | ||
| - 'src/Services/Product/**' | ||
| - 'src/Shared/**' | ||
| - 'deploy/helm/inventory-service/**' | ||
|
|
||
| env: | ||
| REGISTRY: ghcr.io | ||
| IMAGE_NAME: ${{ github.repository_owner }}/inventory-service | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup .NET | ||
| uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: '8.0.x' | ||
|
|
||
| - name: Restore dependencies | ||
| run: dotnet restore src/Services/Product/Product.API/Product.API.csproj | ||
|
|
||
| - name: Build | ||
| run: dotnet build src/Services/Product/Product.API/Product.API.csproj --no-restore --configuration Release | ||
|
|
||
| - name: Test | ||
| run: | | ||
| if [ -d "src/Services/Product/Product.Tests" ]; then | ||
| dotnet test src/Services/Product/Product.Tests --no-build --configuration Release | ||
| else | ||
| echo "No test project found, skipping tests" | ||
| fi | ||
|
|
||
| docker: | ||
| runs-on: ubuntu-latest | ||
| needs: build | ||
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Log in to Container Registry | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ${{ env.REGISTRY }} | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Build and push Docker image | ||
| uses: docker/build-push-action@v5 | ||
| with: | ||
| context: ./src | ||
| file: ./src/Services/Product/Product.API/Dockerfile | ||
| push: true | ||
| tags: | | ||
| ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} | ||
| ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | ||
|
|
||
| helm-lint: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Helm | ||
| uses: azure/setup-helm@v3 | ||
| with: | ||
| version: v3.13.0 | ||
|
|
||
| - name: Lint Helm chart | ||
| run: helm lint deploy/helm/inventory-service | ||
|
|
||
| deploy-dev: | ||
| runs-on: ubuntu-latest | ||
| needs: [build, docker] | ||
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
| environment: dev | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Deploy to dev | ||
| run: | | ||
| echo "Triggering ArgoCD sync for inventory-service-dev" | ||
| # ArgoCD CLI sync would go here | ||
| # argocd app sync inventory-service-dev --server $ARGOCD_SERVER | ||
|
|
||
| deploy-staging: | ||
| runs-on: ubuntu-latest | ||
| needs: [build, docker, deploy-dev] | ||
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
| environment: staging | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Deploy to staging | ||
| run: | | ||
| echo "Triggering ArgoCD sync for inventory-service-staging" | ||
| # ArgoCD CLI sync would go here | ||
| # argocd app sync inventory-service-staging --server $ARGOCD_SERVER | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| apiVersion: argoproj.io/v1alpha1 | ||
| kind: Application | ||
| metadata: | ||
| name: inventory-service-dev | ||
| namespace: argocd | ||
| spec: | ||
| project: default | ||
| source: | ||
| repoURL: https://github.com/Cognition-Partner-Workshops/app_dotnet_angular_containerized_decomposition_microservices | ||
| targetRevision: main | ||
| path: deploy/helm/inventory-service | ||
| helm: | ||
| valueFiles: | ||
| - values-dev.yaml | ||
| destination: | ||
| server: https://kubernetes.default.svc | ||
| namespace: dev | ||
| syncPolicy: | ||
| automated: | ||
| prune: true | ||
| selfHeal: true | ||
| syncOptions: | ||
| - CreateNamespace=true |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| apiVersion: argoproj.io/v1alpha1 | ||
| kind: Application | ||
| metadata: | ||
| name: inventory-service-staging | ||
| namespace: argocd | ||
| spec: | ||
| project: default | ||
| source: | ||
| repoURL: https://github.com/Cognition-Partner-Workshops/app_dotnet_angular_containerized_decomposition_microservices | ||
| targetRevision: main | ||
| path: deploy/helm/inventory-service | ||
| helm: | ||
| valueFiles: | ||
| - values-staging.yaml | ||
| destination: | ||
| server: https://kubernetes.default.svc | ||
| namespace: staging | ||
| syncPolicy: | ||
| syncOptions: | ||
| - CreateNamespace=true |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| apiVersion: v2 | ||
| name: inventory-service | ||
| description: Helm chart for the Inventory (Product) microservice | ||
| type: application | ||
| version: 0.1.0 | ||
| appVersion: "1.0.0" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| apiVersion: v1 | ||
| kind: ConfigMap | ||
| metadata: | ||
| name: {{ include "inventory-service.fullname" . }}-config | ||
| labels: | ||
| app: {{ include "inventory-service.name" . }} | ||
| data: | ||
| ASPNETCORE_ENVIRONMENT: {{ .Values.env.ASPNETCORE_ENVIRONMENT | quote }} | ||
| ASPNETCORE_URLS: {{ .Values.env.ASPNETCORE_URLS | quote }} | ||
| Logging__LogLevel__Default: {{ .Values.logging.level | quote }} |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: {{ include "inventory-service.fullname" . }} | ||
| labels: | ||
| app: {{ include "inventory-service.name" . }} | ||
| chart: {{ .Chart.Name }}-{{ .Chart.Version }} | ||
| spec: | ||
| {{- if not .Values.autoscaling.enabled }} | ||
| replicas: {{ .Values.replicaCount }} | ||
| {{- end }} | ||
| selector: | ||
| matchLabels: | ||
| app: {{ include "inventory-service.name" . }} | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app: {{ include "inventory-service.name" . }} | ||
| spec: | ||
| containers: | ||
| - name: {{ .Chart.Name }} | ||
| image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" | ||
| imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
| ports: | ||
| - name: http | ||
| containerPort: {{ .Values.service.port }} | ||
| protocol: TCP | ||
| envFrom: | ||
| - configMapRef: | ||
| name: {{ include "inventory-service.fullname" . }}-config | ||
| - secretRef: | ||
| name: {{ include "inventory-service.fullname" . }}-secret | ||
| livenessProbe: | ||
| httpGet: | ||
| path: /healthz | ||
| port: http | ||
| initialDelaySeconds: 15 | ||
| periodSeconds: 20 | ||
| readinessProbe: | ||
| httpGet: | ||
| path: /healthz | ||
| port: http | ||
| initialDelaySeconds: 5 | ||
| periodSeconds: 10 | ||
| resources: | ||
| {{- toYaml .Values.resources | nindent 12 }} | ||
|
|
||
| {{- define "inventory-service.name" -}} | ||
| {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} | ||
| {{- end -}} | ||
|
|
||
| {{- define "inventory-service.fullname" -}} | ||
| {{- if .Values.fullnameOverride -}} | ||
| {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} | ||
| {{- else -}} | ||
| {{- $name := default .Chart.Name .Values.nameOverride -}} | ||
| {{- printf "%s" $name | trunc 63 | trimSuffix "-" -}} | ||
| {{- end -}} | ||
| {{- end -}} |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| {{- if .Values.autoscaling.enabled }} | ||
| apiVersion: autoscaling/v2 | ||
| kind: HorizontalPodAutoscaler | ||
| metadata: | ||
| name: {{ include "inventory-service.fullname" . }} | ||
| labels: | ||
| app: {{ include "inventory-service.name" . }} | ||
| spec: | ||
| scaleTargetRef: | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| name: {{ include "inventory-service.fullname" . }} | ||
| minReplicas: {{ .Values.autoscaling.minReplicas }} | ||
| maxReplicas: {{ .Values.autoscaling.maxReplicas }} | ||
| metrics: | ||
| - type: Resource | ||
| resource: | ||
| name: cpu | ||
| target: | ||
| type: Utilization | ||
| averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} | ||
| {{- end }} |
44 changes: 44 additions & 0 deletions
44
deploy/helm/inventory-service/templates/networkpolicy.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| {{- if .Values.networkPolicy.enabled }} | ||
| apiVersion: networking.k8s.io/v1 | ||
| kind: NetworkPolicy | ||
| metadata: | ||
| name: {{ include "inventory-service.fullname" . }} | ||
| labels: | ||
| app: {{ include "inventory-service.name" . }} | ||
| spec: | ||
| podSelector: | ||
| matchLabels: | ||
| app: {{ include "inventory-service.name" . }} | ||
| policyTypes: | ||
| - Ingress | ||
| - Egress | ||
| ingress: | ||
| - from: | ||
| - podSelector: | ||
| matchLabels: | ||
| app: api-gateway | ||
| ports: | ||
| - protocol: TCP | ||
| port: {{ .Values.service.port }} | ||
| egress: | ||
| - to: | ||
| - podSelector: | ||
| matchLabels: | ||
| app: postgresql | ||
| ports: | ||
| - protocol: TCP | ||
| port: {{ .Values.postgresql.port }} | ||
| - to: | ||
| - podSelector: | ||
| matchLabels: | ||
| app: rabbitmq | ||
| ports: | ||
| - protocol: TCP | ||
| port: {{ .Values.rabbitmq.port }} | ||
| - to: [] | ||
| ports: | ||
| - protocol: TCP | ||
| port: 53 | ||
| - protocol: UDP | ||
| port: 53 | ||
| {{- end }} |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| apiVersion: v1 | ||
| kind: Secret | ||
| metadata: | ||
| name: {{ include "inventory-service.fullname" . }}-secret | ||
| labels: | ||
| app: {{ include "inventory-service.name" . }} | ||
| type: Opaque | ||
| data: | ||
| ConnectionStrings__DefaultConnection: {{ printf "Host=%s;Port=%s;Database=%s;Username=%s;Password=changeme" .Values.postgresql.host (toString .Values.postgresql.port) .Values.postgresql.database .Values.postgresql.username | b64enc | quote }} |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: {{ include "inventory-service.fullname" . }} | ||
| labels: | ||
| app: {{ include "inventory-service.name" . }} | ||
| spec: | ||
| type: {{ .Values.service.type }} | ||
| ports: | ||
| - port: {{ .Values.service.port }} | ||
| targetPort: http | ||
| protocol: TCP | ||
| name: http | ||
| selector: | ||
| app: {{ include "inventory-service.name" . }} |
16 changes: 16 additions & 0 deletions
16
deploy/helm/inventory-service/templates/servicemonitor.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| {{- if .Values.serviceMonitor.enabled }} | ||
| apiVersion: monitoring.coreos.com/v1 | ||
| kind: ServiceMonitor | ||
| metadata: | ||
| name: {{ include "inventory-service.fullname" . }} | ||
| labels: | ||
| app: {{ include "inventory-service.name" . }} | ||
| spec: | ||
| selector: | ||
| matchLabels: | ||
| app: {{ include "inventory-service.name" . }} | ||
| endpoints: | ||
| - port: http | ||
| path: {{ .Values.serviceMonitor.path }} | ||
| interval: {{ .Values.serviceMonitor.interval }} | ||
| {{- end }} |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| replicaCount: 1 | ||
|
|
||
| image: | ||
| tag: "latest" | ||
|
|
||
| env: | ||
| ASPNETCORE_ENVIRONMENT: Development | ||
| ASPNETCORE_URLS: "http://+:5004" | ||
|
|
||
| logging: | ||
| level: Debug | ||
|
|
||
| autoscaling: | ||
| enabled: false | ||
|
|
||
| resources: | ||
| limits: | ||
| cpu: 250m | ||
| memory: 256Mi | ||
| requests: | ||
| cpu: 50m | ||
| memory: 64Mi |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| replicaCount: 2 | ||
|
|
||
| image: | ||
| tag: "latest" | ||
|
|
||
| env: | ||
| ASPNETCORE_ENVIRONMENT: Staging | ||
| ASPNETCORE_URLS: "http://+:5004" | ||
|
|
||
| logging: | ||
| level: Information | ||
|
|
||
| autoscaling: | ||
| enabled: true | ||
| minReplicas: 2 | ||
| maxReplicas: 5 | ||
| targetCPUUtilizationPercentage: 70 | ||
|
|
||
| resources: | ||
| limits: | ||
| cpu: 500m | ||
| memory: 512Mi | ||
| requests: | ||
| cpu: 100m | ||
| memory: 128Mi |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 CI test step uses --no-build but the test project was never built
The test step at line 41 runs
dotnet test src/Services/Product/Product.Tests --no-build --configuration Release. The--no-buildflag requires the project to already be compiled, but the preceding build step (line 36) only buildsProduct.API.csproj, not the test project. If the test directory exists,dotnet testwill fail because no compiled test assemblies are found. Either remove--no-buildor add a build step for the test project.Was this helpful? React with 👍 or 👎 to provide feedback.