Skip to content

Releases: alexfariakof/app-despesas-pessoais

Feature/Create-Default-Page-Not-Found #171

18 Jun 00:21
Compare
Choose a tag to compare
v2.0.1

Feature/Create-Default-Page-Not-Found #171

Deploy Production Version 2.0.0

15 Jun 04:14
Compare
Choose a tag to compare

Refinamento e Teste do fluxo dos Workflows #163

Workflow Build and Test

name: Build and Test
on:
  workflow_call:

  push:
    branches: 
      - main 
      - dev

  pull_request:
    types: [opened]
    branches:       
      - main

permissions:
    contents: read 
jobs:
  build_and_test:
    name: Build and Test .Net
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3

    - name: Cache .NET packages    
      uses: actions/cache@v3
      id: dotnet-cache
      with:
        path: ~/.nuget/packages
        key: dotnet-packages-${{ github.repository }}
        restore-keys: dotnet-packages-${{ github.repository }}

    - name: Setup .NET
      uses: actions/setup-dotnet@v3
      if: steps.dotnet-cache.outputs.cache-hit != 'true'
      with:
        dotnet-version: 8.0.x
    
    - name: Build and Restore App 
      run: dotnet build  ./Despesas.WebApi/Despesas.WebApi.csproj --restore
      continue-on-error: false

    - name:  Test .Net App
      run: dotnet test ./XunitTests/XUnit.Tests.csproj
      continue-on-error: false
  
  build_and_test_angular:
    name: Build and Test AngularApp
    needs: build_and_test
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Set up Node.js
        uses: actions/setup-node@v3
        with:
          node-version: '21.*.*'

      - name: Install Angular dependencies
        run: |
          npm install  [email protected]
          npm install -g @angular/core@16 @angular/cli@16
          npm install
        working-directory: AngularApp

      - name: Build Angular App
        run: npm run build
        working-directory: AngularApp

      - name: Test Angular App
        run: npm run test:coverage
        working-directory: AngularApp

  trigger_tests_sonarcloud:
    needs: build_and_test_angular
    name: Test and Analysis Code In Sonar Cloud
    uses: alexfariakof/app-despesas-pessoais/.github/workflows/test_analyse_in_Sonar_Cloud.yml@main
    secrets: inherit

Workflow Test and Analysis Code In Sonar Cloud

name: Test and Analysis Code In Sonar Cloud
on:
  workflow_call:
  push:
    branches: 
      - hotfix/*
      - feature/*
      - bugfix/*  

  pull_request:
    types: [opened, synchronize, reopened]
    branches:       
      - hotfix/*
      - feature/*
      - bugfix/*  
permissions:
    contents: read 
jobs:
  test_code_in_sonar:
    name: Test and Analysis Code In Sonar Cloud
    runs-on: windows-latest
    steps:
      - name: Set up JDK 17
        uses: actions/setup-java@v3
        with:
          java-version: 17
          distribution: 'zulu'
      
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Cache SonarCloud packages
        id: cache-sonar
        uses: actions/cache@v3        
        with:        
            path: ~\sonar\cache
            key: ${{ runner.os }}-sonar
            restore-keys: ${{ runner.os }}-sonar
      
      - name: Create if not Exist Cache Sonar Packages
        if: steps.cache-sonar.outputs.cache-hit != 'true'
        shell: powershell
        run: |
          New-Item -Path ~\sonar\cache -ItemType Directory    
        
      - name: Cache SonarCloud scanner
        id: cache-sonar-scanner
        uses: actions/cache@v3
        with:
            path: .\.sonar\scanner
            key: ${{ runner.os }}-sonar-scanner
            restore-keys: ${{ runner.os }}-sonar-scanner                
      
      - name: Install SonarCloud scanner
        if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
        shell: powershell
        run: |
          New-Item -Path ./.sonar/scanner -ItemType Directory
          dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner

      - name: Set up Node.js
        uses: actions/setup-node@v3
        with:
          node-version: '21.*.*'

      - name: Install Angular dependencies
        run: |
          npm install  [email protected]
          npm install -g @angular/core@16 @angular/cli@16
          npm install
        working-directory: AngularApp
   
      - name: Build and analyze
        env:
            GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
            SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
        shell: powershell
        run: |          
          ./.sonar/scanner/dotnet-sonarscanner begin /k:"alexfariakof_despesas-backend-api-net-core" /o:"alexfariakof" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml" /d:sonar.exclusions="**/XunitTests/**,  **/Migrations.MsSqlServer/**, **/Migrations.MySqlServer/**, **/HyperMedia/**, **/.documents/**, *.sql, **/Program.cs, **/Despesas.DataSeeders/**, **/Despesas.CrossCutting/**, **/*.spec.ts, **/main.ts, **/environment.*, **/app-routing.module.ts, **/*.js, **/test.ts" /d:sonar.cs.lcov.reportPaths="**/TestResults/coveragereport/lcov.info" /d:sonar.typescript.opencover.reportsPaths="**/coverage/clover.xml" /d:sonar.typescript.lcov.reportPaths="**/coverage/lcov.info"
           $baseDirectory =  Get-Location
           $projectAngular = (Resolve-Path -Path "$baseDirectory\AngularApp")
           $sonarProjectFile = "$projectAngular\sonar-project.properties"
           Remove-Item -Path $sonarProjectFile -Force

            dotnet tool install -g dotnet-reportgenerator-globaltool
            dotnet test ./XunitTests/XUnit.Tests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect:"XPlat Code Coverage;Format=opencover"          
          ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"

Workflow Deploy Development Project in AWS

name: Deploy Development Project in AWS
on:
  push:
    branches:
      - staging
      
permissions:
    contents: read 
jobs:
  trigger_build_and_test:
    name: Triggered Deploy Dev
    uses: alexfariakof/app-despesas-pessoais/.github/workflows/build_and_test.yml@main
    secrets: inherit     
        
  deploy_dev:
    needs: trigger_build_and_test
    name: Docker Build and Publish in Development
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      
      - name: Build Docker image
        env:
          DOCKER_CLI_AGGREGATE: 1  
        run: |          
            docker-compose -f docker-compose.dev.yml build
        continue-on-error: false

      - name: Push Docker image to Docker Hub
        env:
          DOCKER_LOGIN: ${{ secrets.DOCKER_LOGIN }}
          DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
          DOCKER_CLI_AGGREGATE: 1  
        run: |
            docker login -u ${{ secrets.DOCKER_LOGIN }} -p ${{ secrets.DOCKER_PASSWORD }}    
            docker push alexfariakof/api-despesas-backend-netcore-dev-img
        continue-on-error: false
        
      - name: Execute SSH Commands into EC2 
        env:
          EC2_HOST: ${{ secrets.EC2_HOST }}
          EC2_USERNAME: ${{ secrets.EC2_USERNAME }}
          AWS_SSH_KEY: ${{ secrets.AWS_SSH_KEY }}
        uses: appleboy/ssh-action@master
        with:
          host: ${{ secrets.EC2_HOST }}
          username: ${{ secrets.EC2_USERNAME }}
          key: ${{ secrets.AWS_SSH_KEY }}
          port: 22
          script: |            
            ./scripts/dp-api.dev.sh
          continue-on-error: false

#  trigger_e2e_tests:
#    needs: deploy_dev
#    name: Tests End-to-End Triggered
#    uses: alexfariakof/app-despesas-pessoais/.github/workflows/tests_E2E.yml@main
#    secrets: inherit

Workflow Deploy Production Project in AWS

name: Deploy Production Project in AWS
on:
  push:
    tags:
      - v*.*.*

jobs:
  trigger_build_and_test:
    name: Triggered Deploy Prod
    uses: alexfariakof/app-despesas-pessoais/.github/workflows/build_and_test.yml@main
    secrets: inherit     
        
  deploy:
    needs: trigger_build_and_test
    name: Docker Build and Publish in Production
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      
      - name: Build Docker image
        env:
          DOCKER_CLI_AGGREGATE: 1  
        run: |          
            docker-compose -f docker-compose.prod.yml build
        continue-on-error: false

      - name: Push Docker image to Docker Hub
        env:
          DOCKER_LOGIN: ${{ secrets.DOCKER_LOGIN }}
          DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
          DOCKER_CLI_AGGREGATE: 1  
        run: |
            docker login -u ${{ secrets.DOCKER_LOGIN }} -p ${{ secrets.DOCKER_PASSWORD }}    
            docker push ${{ secrets.DOCKER_IMAGE }}
        continue-on-error: false
        
      - name: Execute SSH Commands into EC2 
        env:
          EC2_HOST: ${{ secrets.EC2_HOST }}
          EC2_USERNAME: ${{ secrets.EC2_USERNAME }}
          AWS_SSH_KEY: ${{ secrets.AWS_SSH_KEY }}

        uses: appleboy/ssh-action@master
        with:
          host: ${{ secrets.EC2_HOST }}
          username: ${{ secrets.EC2_USERNAME }}
          key: ${{ secrets.AWS_SSH_KEY }}
          port: 22
          script: |            
            ./scripts/dp-api.prod.sh
          continue-on-error: false

Workflow Tests End-to-End

  • Disabled to "Review, Refacotry and Implementation new Features and Strategies"
name: Tests End-to-End
on:
  workflow_call:
    secrets:
      ENV_PAT:
        required: true
  
  pull_request:
    types: [opened, synchronize, reopened]
    branches:
      - staging

jobs:
  trigger-tests-e2e:
    runs-on: ubuntu-latest
    steps:
      - name: Trigger Workflow End-to-End
        ...
Read more