Update build.yml #188
This file contains 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: Build | |
on: | |
push: | |
branches: | |
- master | |
- feature/39_coverage_conflict | |
pull_request: | |
types: [opened, synchronize, reopened] | |
jobs: | |
backend-tests: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: syg-backend | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: maven | |
- name: Build with Maven | |
run: mvn clean verify | |
frontend-tests: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: syg-frontend | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '21' # Cambia según tu versión de Node.js | |
- run: npm ci | |
- run: npm test | |
- run: npm run test:coverage | |
- run: npm run lint | |
sonarCloud: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# Backend setup and build | |
- name: Setup Java | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Build and Test Backend | |
run: mvn clean verify | |
working-directory: syg-backend | |
# Frontend setup and build | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 21 | |
- name: Install Dependencies | |
run: npm ci | |
working-directory: syg-frontend | |
- name: Run Frontend Tests | |
run: npm test | |
working-directory: syg-frontend | |
- name: Run Frontend Coverage | |
run: npm run test:coverage | |
working-directory: syg-frontend | |
# Combine coverage reports if needed | |
- name: Combine Coverage Reports | |
run: | | |
# Assuming you have tools to combine coverage reports, add those commands here | |
# For example, you might use `nyc` to combine lcov reports | |
# This step is a placeholder and should be adapted to your specific needs | |
# SonarCloud analysis | |
- name: SonarCloud Analysis | |
run: mvn org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.javascript.lcov.reportPaths=syg-frontend/coverage/lcov.info | |
env: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
working-directory: syg-backend | |
# sonarcloudBackend: | |
# name: sonarcloudBackend | |
# runs-on: ubuntu-latest | |
# defaults: | |
# run: | |
# working-directory: syg-backend | |
# steps: | |
# - uses: actions/checkout@v4 | |
# with: | |
# fetch-depth: 0 | |
# - name: Setup Java | |
# uses: actions/setup-java@v3 | |
# with: | |
# distribution: 'temurin' | |
# java-version: '17' | |
# # Build and test the project | |
# - name: Build and Test | |
# run: mvn clean verify | |
# # SonarCloud analysis | |
# - name: SonarCloud Analysis | |
# run: mvn org.sonarsource.scanner.maven:sonar-maven-plugin:sonar | |
# env: | |
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
# sonarcloudFrontend: | |
# name: sonarcloudFrontend | |
# runs-on: ubuntu-latest | |
# defaults: | |
# run: | |
# working-directory: syg-frontend | |
# steps: | |
# - uses: actions/checkout@v4 | |
# with: | |
# fetch-depth: 0 | |
# - uses: actions/setup-node@v4 | |
# with: | |
# node-version: 21 | |
# - run: npm ci | |
# - run: npm test | |
# - run: npm run test:coverage | |
# - name: SonarCloud Scan | |
# uses: sonarsource/sonarcloud-github-action@master | |
# env: | |
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
# deployment: | |
# runs-on: ubuntu-latest | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - name: Login to Azure Container Registry | |
# uses: azure/login@v1 | |
# with: | |
# creds: ${{ secrets.AZURE_SERVICE_PRINCIPAL }} | |
# - name: Delete images | |
# run: | | |
# az acr login --name ${{ secrets.AZURE_REGISTRY_NAME }} | |
# # Si las imagenes existen, eliminarlsa, si no, imprimir mensaje | |
# az acr repository show-manifests --name ${{ secrets.AZURE_REGISTRY_NAME }} --repository "syg-docker-db" --query "[?tags[0]=='0.1.0-SNAPSHOT']" > /dev/null 2>&1 \ | |
# && az acr repository delete --name ${{ secrets.AZURE_REGISTRY_NAME }} --repository "syg-docker-db" --image "0.1.0-SNAPSHOT" --yes \ | |
# || echo "Image 'syg-docker-db:0.1.0-SNAPSHOT' does not exist, skipping deletion." | |
# az acr repository show-manifests --name ${{ secrets.AZURE_REGISTRY_NAME }} --repository "syg-backend" --query "[?tags[0]=='0.1.0-SNAPSHOT']" > /dev/null 2>&1 \ | |
# && az acr repository delete --name ${{ secrets.AZURE_REGISTRY_NAME }} --repository "syg-backend" --image "0.1.0-SNAPSHOT" --yes \ | |
# || echo "Image 'syg-backend:0.1.0-SNAPSHOT' does not exist, skipping deletion." | |
# az acr repository show-manifests --name ${{ secrets.AZURE_REGISTRY_NAME }} --repository "syg-keycloak" --query "[?tags[0]=='0.1.0-SNAPSHOT']" > /dev/null 2>&1 \ | |
# && az acr repository delete --name ${{ secrets.AZURE_REGISTRY_NAME }} --repository "syg-keycloak" --image "0.1.0-SNAPSHOT" --yes \ | |
# || echo "Image 'syg-keycloak:0.1.0-SNAPSHOT' does not exist, skipping deletion." | |
# az acr repository show-manifests --name ${{ secrets.AZURE_REGISTRY_NAME }} --repository "syg-frontend" --query "[?tags[0]=='0.1.0-SNAPSHOT']" > /dev/null 2>&1 \ | |
# && az acr repository delete --name ${{ secrets.AZURE_REGISTRY_NAME }} --repository "syg-frontend" --image "0.1.0-SNAPSHOT" --yes \ | |
# || echo "Image 'syg-frontend:0.1.0-SNAPSHOT' does not exist, skipping deletion." | |
# az acr repository show-manifests --name ${{ secrets.AZURE_REGISTRY_NAME }} --repository "syg-prometheus" --query "[?tags[0]=='0.1.0-SNAPSHOT']" > /dev/null 2>&1 \ | |
# && az acr repository delete --name ${{ secrets.AZURE_REGISTRY_NAME }} --repository "syg-prometheus" --image "0.1.0-SNAPSHOT" --yes \ | |
# || echo "Image 'syg-prometheus:0.1.0-SNAPSHOT' does not exist, skipping deletion." | |
# az acr repository show-manifests --name ${{ secrets.AZURE_REGISTRY_NAME }} --repository "syg-grafana" --query "[?tags[0]=='0.1.0-SNAPSHOT']" > /dev/null 2>&1 \ | |
# && az acr repository delete --name ${{ secrets.AZURE_REGISTRY_NAME }} --repository "syg-grafana" --image "0.1.0-SNAPSHOT" --yes \ | |
# || echo "Image 'syg-grafana:0.1.0-SNAPSHOT' does not exist, skipping deletion." | |
# - name: Push images | |
# run: | | |
# docker build -f ./docker/database-mysql.Dockerfile -t ${{ secrets.AZURE_REGISTRY_NAME }}.azurecr.io/syg-docker-db:0.1.0-SNAPSHOT ./docker | |
# docker push ${{ secrets.AZURE_REGISTRY_NAME }}.azurecr.io/syg-docker-db:0.1.0-SNAPSHOT | |
# docker build -f ./syg-backend/SYG-bootstrap/src/docker/backend.Dockerfile -t ${{ secrets.AZURE_REGISTRY_NAME }}.azurecr.io/syg-backend:0.1.0-SNAPSHOT . | |
# docker push ${{ secrets.AZURE_REGISTRY_NAME }}.azurecr.io/syg-backend:0.1.0-SNAPSHOT | |
# docker build -f ./docker/keycloak/keycloak.Dockerfile -t ${{ secrets.AZURE_REGISTRY_NAME }}.azurecr.io/syg-keycloak:0.1.0-SNAPSHOT ./docker/keycloak | |
# docker push ${{ secrets.AZURE_REGISTRY_NAME }}.azurecr.io/syg-keycloak:0.1.0-SNAPSHOT | |
# docker build -f ./syg-frontend/frontend.Dockerfile -t ${{ secrets.AZURE_REGISTRY_NAME }}.azurecr.io/syg-frontend:0.1.0-SNAPSHOT . | |
# docker push ${{ secrets.AZURE_REGISTRY_NAME }}.azurecr.io/syg-frontend:0.1.0-SNAPSHOT | |
# docker build -f ./docker/prometheus.Dockerfile -t ${{ secrets.AZURE_REGISTRY_NAME }}.azurecr.io/syg-prometheus:0.1.0-SNAPSHOT ./docker | |
# docker push ${{ secrets.AZURE_REGISTRY_NAME }}.azurecr.io/syg-prometheus:0.1.0-SNAPSHOT | |
# docker build -f ./docker/grafana.Dockerfile -t ${{ secrets.AZURE_REGISTRY_NAME }}.azurecr.io/syg-grafana:0.1.0-SNAPSHOT ./docker | |
# docker push ${{ secrets.AZURE_REGISTRY_NAME }}.azurecr.io/syg-grafana:0.1.0-SNAPSHOT | |
# - name: Stop All Containers in syg resource Group | |
# run: | | |
# az container stop --name syg-docker-db --resource-group syg-demo | |
# az container stop --name syg-backend --resource-group syg-demo | |
# az container stop --name syg-keycloak --resource-group syg-demo | |
# az container stop --name syg-frontend --resource-group syg-demo | |
# az container stop --name syg-prometheus --resource-group syg-demo | |
# az container stop --name syg-grafana --resource-group syg-demo | |
# - name: Start All Containers in syg resource Group | |
# run: | | |
# az container start --name syg-docker-db --resource-group syg-demo | |
# az container start --name syg-backend --resource-group syg-demo | |
# az container start --name syg-keycloak --resource-group syg-demo | |
# az container start --name syg-frontend --resource-group syg-demo | |
# az container start --name syg-prometheus --resource-group syg-demo | |
# az container start --name syg-grafana --resource-group syg-demo | |