Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 30 additions & 34 deletions .github/workflows/ci-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ on:
push:
branches:
- main
- "develop-*"
- develop-1

pull_request:
branches:
- main
- "develop-*"
types: [opened, synchronize, reopened]
- develop-1
types:
- opened
- synchronize
- reopened

workflow_dispatch:

permissions:
Expand All @@ -21,53 +26,44 @@ concurrency:
cancel-in-progress: true

jobs:
commit-build:
name: "Estágio 1: qualidade e build"
frontend-ci:
name: Tests, Build and SonarCloud
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Checkout do código
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Checkout repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
with:
fetch-depth: 0

- name: Configurar Node.js
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: npm
cache-dependency-path: package-lock.json

- name: Instalar dependências
- name: Install dependencies
run: npm ci

- name: Executar análise estática com ESLint
- name: Run ESLint
run: npm run lint

- name: Gerar build de produção
run: npm run build
- name: Run tests with coverage
run: npm run test:coverage

secondary-build:
name: "Estágio 2: análise no SonarCloud"
runs-on: ubuntu-latest
timeout-minutes: 10
needs: commit-build
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build production application
run: npm run build

steps:
- name: Checkout do código
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
fetch-depth: 0
- name: Verify coverage report
run: |
test -f coverage/lcov.info
echo "LCOV coverage report generated successfully."
ls -lh coverage/lcov.info

- name: Executar análise no SonarCloud
if: env.SONAR_TOKEN != ''
uses: SonarSource/sonarqube-scan-action@7006c4492b2e0ee0f816d36501671557c97f5995 # v8.1.0
- name: Run SonarCloud analysis
uses: SonarSource/sonarqube-scan-action@7006c4492b2e0ee0f816d36501671557c97f5995
env:
SONAR_TOKEN: ${{ env.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Informar ausência do token do SonarCloud
if: env.SONAR_TOKEN == ''
run: echo "::notice::SonarCloud não executado porque o secret SONAR_TOKEN não está disponível."
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@ dist-ssr
*.njsproj
*.sln
*.sw?

# Relatórios gerados pelos testes
coverage/

# PyCharm / JetBrains
.idea/
22 changes: 13 additions & 9 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import { defineConfig, globalIgnores } from 'eslint/config'
import js from "@eslint/js";
import globals from "globals";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import { defineConfig, globalIgnores } from "eslint/config";

export default defineConfig([
globalIgnores(['dist', 'ignore']),
globalIgnores(["dist", "ignore", "coverage"]),
{
files: ['**/*.{js,jsx}'],
files: ["**/*.{js,jsx}"],
extends: [
js.configs.recommended,
reactHooks.configs.flat.recommended,
reactRefresh.configs.vite,
],
languageOptions: {
globals: globals.browser,
parserOptions: { ecmaFeatures: { jsx: true } },
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
},
])
]);
Loading
Loading