chore(deps-dev): bump typescript-eslint from 8.34.1 to 8.36.0 in /client #108
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: Continuous Integration | |
on: | |
push: | |
branches: [main, develop] | |
pull_request: | |
branches: [main, develop] | |
types: [opened, synchronize, reopened] | |
env: | |
DOTNET_VERSION: "8.0.x" | |
NODE_VERSION: "18.x" | |
DOCKER_BUILDKIT: 1 | |
jobs: | |
detect-changes: | |
runs-on: ubuntu-latest | |
outputs: | |
backend: ${{ steps.changes.outputs.backend }} | |
frontend: ${{ steps.changes.outputs.frontend }} | |
docker: ${{ steps.changes.outputs.docker }} | |
k8s: ${{ steps.changes.outputs.k8s }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dorny/paths-filter@v2 | |
id: changes | |
with: | |
filters: | | |
backend: | |
- 'Services/**' | |
- 'ApiGateways/**' | |
- 'Infrastructure/**' | |
- '*.sln' | |
- '**/*.csproj' | |
frontend: | |
- 'client/**' | |
docker: | |
- 'docker-compose*.yml' | |
- '**/Dockerfile' | |
k8s: | |
- 'Deployments/**' | |
code-quality: | |
runs-on: ubuntu-latest | |
needs: detect-changes | |
if: needs.detect-changes.outputs.backend == 'true' | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: Cache NuGet packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.nuget/packages | |
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} | |
restore-keys: | | |
${{ runner.os }}-nuget- | |
- name: Restore dependencies | |
run: dotnet restore Ecommerce.sln | |
- name: Build solution | |
run: dotnet build Ecommerce.sln --no-restore --configuration Release | |
- name: Run tests | |
run: dotnet test Ecommerce.sln --no-build --configuration Release --verbosity normal --collect:"XPlat Code Coverage" --results-directory ./coverage | |
- name: Create coverage directory | |
run: mkdir -p coverage | |
- name: Find coverage files | |
run: find ./coverage -name "*.xml" -type f -exec ls -la {} \; | |
- name: Code Coverage Report | |
uses: irongut/[email protected] | |
continue-on-error: true | |
with: | |
filename: coverage/**/coverage.cobertura.xml | |
badge: true | |
fail_below_min: true | |
format: markdown | |
hide_branch_rate: false | |
hide_complexity: true | |
indicators: true | |
output: both | |
thresholds: "60 80" | |
- name: Add Coverage PR Comment | |
if: github.event_name == 'pull_request' | |
run: | | |
if [ -f "code-coverage-results.md" ]; then | |
echo "Posting code coverage results to PR" | |
gh pr comment ${{ github.event.pull_request.number }} --body-file code-coverage-results.md | |
else | |
echo "No code coverage results file found - skipping PR comment" | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
security-scan: | |
runs-on: ubuntu-latest | |
permissions: | |
actions: read | |
contents: read | |
security-events: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Run Trivy vulnerability scanner | |
uses: aquasecurity/trivy-action@master | |
with: | |
scan-type: "fs" | |
scan-ref: "." | |
format: "sarif" | |
output: "trivy-results.sarif" | |
- name: Upload Trivy scan results to GitHub Security tab | |
uses: github/codeql-action/upload-sarif@v3 | |
with: | |
sarif_file: "trivy-results.sarif" | |
# Initialize CodeQL before analysis | |
- name: Initialize CodeQL | |
uses: github/codeql-action/init@v3 | |
with: | |
languages: csharp, javascript | |
# Autobuild attempts to build any compiled languages | |
- name: Autobuild | |
uses: github/codeql-action/autobuild@v3 | |
# Run CodeQL Analysis for both languages | |
- name: Run CodeQL Analysis | |
uses: github/codeql-action/analyze@v3 | |
frontend-quality: | |
runs-on: ubuntu-latest | |
needs: detect-changes | |
if: needs.detect-changes.outputs.frontend == 'true' | |
defaults: | |
run: | |
working-directory: ./client | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
cache: "npm" | |
cache-dependency-path: client/package-lock.json | |
- name: Install dependencies | |
run: npm install --legacy-peer-deps || npm ci --legacy-peer-deps | |
- name: Lint | |
run: npm run lint | |
continue-on-error: true | |
- name: Run tests | |
run: npm run test:ci | |
continue-on-error: true | |
- name: Build | |
run: npm run build | |
docker-build: | |
runs-on: ubuntu-latest | |
needs: [code-quality, frontend-quality] | |
if: always() && (needs.code-quality.result == 'success' || needs.code-quality.result == 'skipped') && (needs.frontend-quality.result == 'success' || needs.frontend-quality.result == 'skipped') | |
strategy: | |
matrix: | |
service: | |
[ | |
{ name: "catalog-api", path: "Services/Catalog/Catalog.API" }, | |
{ name: "basket-api", path: "Services/Basket/Basket.API" }, | |
{ name: "discount-api", path: "Services/Discount/Discount.API" }, | |
{ name: "ordering-api", path: "Services/Ordering/Ordering.API" }, | |
{ name: "ocelot-gateway", path: "ApiGateways/Ocelot.ApiGateway" }, | |
] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./${{ matrix.service.path }}/Dockerfile | |
push: false | |
tags: ${{ matrix.service.name }}:ci-${{ github.run_number }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
integration-tests: | |
runs-on: ubuntu-latest | |
needs: docker-build | |
if: github.event_name == 'pull_request' | |
continue-on-error: true | |
services: | |
redis: | |
image: redis:alpine | |
ports: | |
- 6379:6379 | |
postgres: | |
image: postgres:13 | |
env: | |
POSTGRES_DB: discountdb | |
POSTGRES_USER: admin | |
POSTGRES_PASSWORD: Password@1 | |
ports: | |
- 5432:5432 | |
mongodb: | |
image: mongo:latest | |
ports: | |
- 27017:27017 | |
rabbitmq: | |
image: rabbitmq:3-management-alpine | |
ports: | |
- 5672:5672 | |
- 15672:15672 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: Run integration tests | |
run: | | |
# Make sure TestResults directory exists | |
mkdir -p ./TestResults | |
# Run test with solution file explicitly specified | |
dotnet test Ecommerce.sln \ | |
--configuration Release \ | |
--filter "Category=Integration" \ | |
--logger "trx;LogFileName=integration-tests.trx" \ | |
--results-directory ./TestResults || true | |
# List the test results to confirm they exist | |
ls -la ./TestResults || echo "No test results generated" | |
- name: Publish test results | |
uses: dorny/test-reporter@v2 | |
if: always() | |
continue-on-error: true | |
with: | |
name: Integration Tests | |
path: ./TestResults/*.trx | |
reporter: dotnet-trx | |
fail-on-error: false | |
helm-lint: | |
runs-on: ubuntu-latest | |
needs: detect-changes | |
if: needs.detect-changes.outputs.k8s == 'true' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Helm | |
uses: azure/setup-helm@v3 | |
with: | |
version: "latest" | |
- name: Lint Helm charts | |
run: | | |
for chart in Deployments/helm/*/; do | |
if [ -f "$chart/Chart.yaml" ]; then | |
echo "Linting $chart" | |
helm lint "$chart" | |
fi | |
done | |
- name: Validate Kubernetes manifests | |
run: | | |
# Simple check for YAML syntax without requiring kubectl API server | |
for manifest in Deployments/k8s/**/*.yaml; do | |
if [ -f "$manifest" ]; then | |
echo "Checking $manifest" | |
grep -v "^#" "$manifest" | python3 -c "import sys, yaml; yaml.safe_load(sys.stdin)" && echo "✓ $manifest is valid YAML" || echo "✗ YAML validation failed for $manifest" | |
fi | |
done | |
notify-status: | |
runs-on: ubuntu-latest | |
permissions: | |
issues: write | |
pull-requests: write | |
needs: [code-quality, frontend-quality, docker-build, helm-lint] | |
if: always() | |
steps: | |
- name: Notify PR status | |
if: github.event_name == 'pull_request' | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const status = '${{ needs.code-quality.result }}' === 'success' && | |
'${{ needs.frontend-quality.result }}' === 'success' && | |
'${{ needs.docker-build.result }}' === 'success' && | |
'${{ needs.helm-lint.result }}' === 'success' ? '✅' : '❌'; | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `${status} CI Pipeline completed. Check the [Actions tab](${context.payload.repository.html_url}/actions/runs/${context.runId}) for details.` | |
}); |