Skip to content

Commit

Permalink
feat: release and parsers for sonar (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matheusafonsouza committed Dec 6, 2024
1 parent bb7cc46 commit 18f671c
Show file tree
Hide file tree
Showing 14 changed files with 9,307 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"presets": [
["@babel/preset-env", { "targets": { "esmodules": true } }], // It's the name of the lib you installed
["@babel/preset-react", { "runtime": "automatic" }], // It's the name of the lib you installed
"@babel/preset-typescript" // It's the name of the lib you installed
]
}
27 changes: 27 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Solve Documentação (texto)


## Issues

- Resolve (# numero )

## Descrição

Descrição

## Tipos de mudança

- [ ] Bugfix
- [ ] Melhoria de funcionalidade
- [ ] Nova funcionalidade
- [] Documentação

## Checklist

- [] Lint e testes passaram localmente com minhas mudanças
- [] Eu adicionei testes que provam que minha correção é eficaz ou que minha feature funciona
- [] Adicionei informações necessárias na documentação (se precisar)

## Observações adicionais

Nenhuma constatação
24 changes: 24 additions & 0 deletions .github/workflows/code-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Push Sonar Metrics
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install dependencies
run: npm install
- name: Test and coverage
run: npm run cov --maxWorkers=2 --runInBand
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
51 changes: 51 additions & 0 deletions .github/workflows/metrics.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Export de métricas

on:
pull_request:
branches:
- main
- develop
types: [ closed ]

jobs:
release:
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'NOT RELEASE') == false
runs-on: "ubuntu-latest"
environment: actions

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install dotenv
run: pip install python-dotenv packaging pandas

- name: Cria arquivo .env
run: |
touch ./sonar_scripts/.env
echo GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} >> ./sonar_scripts/.env
echo RELEASE_MAJOR=${{ contains(github.event.pull_request.labels.*.name, 'MAJOR RELEASE') }} >> ./sonar_scripts/.env
echo RELEASE_MINOR=${{ contains(github.event.pull_request.labels.*.name, 'MINOR RELEASE') }} >> ./sonar_scripts/.env
echo RELEASE_FIX=${{ contains(github.event.pull_request.labels.*.name, 'FIX RELEASE') }} >> ./sonar_scripts/.env
echo DEVELOP=${{ contains(github.event.pull_request.labels.*.name, 'DEVELOP') }} >> ./sonar_scripts/.env
echo REPO=${{ github.event.repository.name }} >> ./sonar_scripts/.env
echo REPO_DOC=${{ secrets.REPO_DOC }} >> ./sonar_scripts/.env
- name: Criar diretório
run: mkdir -p analytics-raw-data

- name: Coletar métricas no SonarCloud
run: python ./sonar_scripts/parser.py

- name: Envia métricas para repo de Doc
run: |
git config --global user.email "${{secrets.USER_EMAIL}}"
git config --global user.name "${{secrets.USER_NAME}}"
git clone --single-branch --branch main "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/fga-eps-mds/${{ secrets.REPO_DOC }}" doc
mkdir -p doc/analytics-raw-data
cp -R analytics-raw-data/*.json doc/analytics-raw-data
cd doc
git add .
git commit -m "Adicionando métricas do repositório ${{ github.event.repository.name }} ${{ github.ref_name }}"
git push
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ dist-ssr
*.njsproj
*.sln
*.sw?

coverage/
reports/
20 changes: 20 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export default {
testEnvironment: "jest-environment-jsdom", // Same name of the lib you installed
setupFilesAfterEnv: ["<rootDir>/jest.setup.ts"], // The file you created to extend jest config and "implement" the jest-dom environment in the jest globals
moduleNameMapper: {
"\\.(gif|ttf|eot|svg|png)$": "<rootDir>/test/__mocks__/fileMock.js", // The global stub for weird files
"\\.(css|less|sass|scss)$": "identity-obj-proxy", // The mock for style related files
"^@/(.*)$": "<rootDir>/src/$1", // [optional] Are you using aliases?
},
reporters: [
'default',
[
'jest-sonar',
{
outputDirectory: 'reports',
outputName: 'sonar-report.xml',
},
],
],
testMatch: ['<rootDir>/test/**/*.(test|spec).ts?(x)'],
};
1 change: 1 addition & 0 deletions jest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "@testing-library/jest-dom";
Loading

0 comments on commit 18f671c

Please sign in to comment.