GAIA-199 rota de health check #117
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 | |
| - production | |
| pull_request: | |
| branches: | |
| - main | |
| - production | |
| jobs: | |
| # Validate if the branch is allowed to be merged or not | |
| validate-branches: | |
| name: "Validate Branch Rules" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: "Check Main -> Production Merge" | |
| if: github.base_ref == 'production' && github.head_ref != 'main' | |
| run: | | |
| echo "ERRO: Pull requests para 'production' só podem ser feitos a partir da branch 'main'." | |
| echo "Este PR está vindo da branch '${{ github.head_ref }}', o que não é permitido." | |
| exit 1 | |
| - name: "Block Production -> Main Merge" | |
| if: github.base_ref == 'main' && github.head_ref == 'production' | |
| run: | | |
| echo "ERRO: A branch 'production' não pode ser mesclada de volta na 'main'." | |
| echo "Hotfixes devem ser feitos em uma branch separada e mesclados tanto em 'main' quanto em 'production'." | |
| exit 1 | |
| - name: "Approve valid merge" | |
| if: (github.base_ref == 'production' && github.head_ref == 'main') || (github.base_ref == 'main' && github.head_ref != 'production') | |
| run: echo "Tudo correto, pode prosseguir!" | |
| build: | |
| name: "Build Application" | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Cache Node.js modules | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.npm | |
| key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-node- | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Generate Prisma client | |
| run: npx prisma generate --schema=src/infra/database/prisma/schema.prisma | |
| - name: Build application | |
| run: npm run build | |
| typecheck: | |
| name: "Type Check" | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| needs: build | |
| if: github.event_name == 'pull_request' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Cache Node.js modules | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.npm | |
| key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-node- | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Generate Prisma client | |
| run: npx prisma generate --schema=src/infra/database/prisma/schema.prisma | |
| - name: Run type check | |
| run: npm run typecheck | |
| unit-tests: | |
| name: "Run Unit Tests" | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| needs: [build, typecheck] | |
| if: github.event_name == 'pull_request' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Cache Node.js modules | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.npm | |
| key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-node- | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run unit tests | |
| run: npm run test | |
| # integration-tests: | |
| # name: "Run Integration Tests" | |
| # runs-on: ubuntu-latest | |
| # timeout-minutes: 5 | |
| # needs: [unit-tests] | |
| # if: github.event_name == 'pull_request' | |
| # steps: | |
| # - name: Checkout repository | |
| # uses: actions/checkout@v4 | |
| # - name: Setup Node.js | |
| # uses: actions/setup-node@v4 | |
| # with: | |
| # node-version: 20 | |
| # - name: Cache Node.js modules | |
| # uses: actions/cache@v3 | |
| # with: | |
| # path: ~/.npm | |
| # key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
| # restore-keys: | | |
| # ${{ runner.os }}-node- | |
| # - name: Generate Prisma client | |
| # run: npx prisma generate --schema=src/infra/database/prisma/schema.prisma | |
| # - name: Install dependencies | |
| # run: npm ci | |
| # - name: Run integration tests | |
| # run: npm run test:e2e |