-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[config] - Configura CI e relatório do Sonar
- Loading branch information
1 parent
5c5f38c
commit 17865dd
Showing
12 changed files
with
1,094 additions
and
416 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
name: front-ci | ||
|
||
on: | ||
push: | ||
branches: [main, devel] | ||
pull_request: | ||
branches: | ||
- main | ||
- devel | ||
types: [opened, synchronize, reopened] | ||
|
||
jobs: | ||
|
||
# ------------------------ TO DO: ADICIONAR BIBLIOTECAS DE ESTILIZACAO DE CODIGO (ES-LINT E PRETTIER) --------------------------------- | ||
|
||
# format: | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - name: Checkout code | ||
# uses: actions/checkout@v3 | ||
|
||
# - name: Use Node.js 20.x | ||
# uses: actions/setup-node@v3 | ||
# with: | ||
# node-version: 20.x | ||
|
||
# - name: 📬 Caching | ||
# uses: actions/cache@v3 | ||
# with: | ||
# path: | | ||
# ${{ github.workspace }}/node_modules | ||
# ${{ github.workspace }}/dist | ||
# key: ${{ runner.os }}-vite-${{ hashFiles('*/package-lock.json') }}-${{ hashFiles('/.{js,jsx,ts,tsx}') }} | ||
# restore-keys: | | ||
# ${{ runner.os }}-vite-${{ hashFiles('**/package-lock.json') }}- | ||
|
||
# - name: 🧰 Instala bibliotecas e dependências | ||
# run: npm i | ||
|
||
# - name: 🔍 Verifica estilização do código | ||
# run: npm run check-format | ||
|
||
# lint: | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - name: Checkout code | ||
# uses: actions/checkout@v3 | ||
|
||
# - name: Use Node.js 20.x | ||
# uses: actions/setup-node@v3 | ||
# with: | ||
# node-version: 20.x | ||
|
||
# - name: 📬 Caching | ||
# uses: actions/cache@v3 | ||
# with: | ||
# path: | | ||
# ${{ github.workspace }}/node_modules | ||
# ${{ github.workspace }}/dist | ||
# key: ${{ runner.os }}-vite-${{ hashFiles('*/package-lock.json') }}-${{ hashFiles('/.{js,jsx,ts,tsx}') }} | ||
# restore-keys: | | ||
# ${{ runner.os }}-vite-${{ hashFiles('**/package-lock.json') }}- | ||
|
||
# - name: 🧰 Instala bibliotecas e dependências | ||
# run: npm i | ||
|
||
# - name: 🧹 Verifica eslint | ||
# run: npm run check-lint | ||
|
||
# ------------------------ TO DO: ADICIONAR BIBLIOTECAS DE ESTILIZACAO DE CODIGO (ES-LINT E PRETTIER) --------------------------------- | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
# TO DO: adicionar variaveis de ambiente conforme necessario | ||
# env: | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js 20.x | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20.x | ||
|
||
- name: 📬 Caching | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
${{ github.workspace }}/node_modules | ||
${{ github.workspace }}/dist | ||
key: ${{ runner.os }}-vite-${{ hashFiles('*/package-lock.json') }}-${{ hashFiles('/.{js,jsx,ts,tsx}') }} | ||
restore-keys: | | ||
${{ runner.os }}-vite-${{ hashFiles('**/package-lock.json') }}- | ||
- name: 🧰 Instala bibliotecas e dependências | ||
run: npm i | ||
|
||
- name: 🧪 Roda suíte de testes | ||
run: npm test | ||
|
||
build: | ||
# TO DO: adicionar format e lint apos configurar prettier e es-lint | ||
# needs: [format, lint] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js 20.x | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20.x | ||
|
||
- name: 📬 Caching | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
${{ github.workspace }}/node_modules | ||
${{ github.workspace }}/dist | ||
key: ${{ runner.os }}-vite-${{ hashFiles('*/package-lock.json') }}-${{ hashFiles('/.{js,jsx,ts,tsx}') }} | ||
restore-keys: | | ||
${{ runner.os }}-vite-${{ hashFiles('**/package-lock.json') }}- | ||
- name: 🧰 Instala bibliotecas e dependências | ||
run: npm i | ||
|
||
- name: 📦 Builda o projeto | ||
run: npm run build | ||
|
||
sonarcloud: | ||
# TO DO: adicionar variaveis de ambiente conforme necessario | ||
# env: | ||
name: sonarcloud | ||
runs-on: ubuntu-latest | ||
continue-on-error: true | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: 📬 Caching | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
${{ github.workspace }}/node_modules | ||
${{ github.workspace }}/dist | ||
key: ${{ runner.os }}-vite-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.{js,jsx,ts,tsx}') }} | ||
restore-keys: | | ||
${{ runner.os }}-vite-${{ hashFiles('**/package-lock.json') }}- | ||
- name: 🧰 Instala bibliotecas e dependências | ||
run: npm i | ||
|
||
# TODO: Setup eslint | ||
# - name: 📜 Relatório do eslint | ||
# run: npx eslint -f json -o reports/eslint-report.json src || true | ||
|
||
- name: 🧪 Testes e cobertura | ||
run: VITEST_REPORTER=vitest-sonar-reporter CI=true npm test -- --coverage | ||
|
||
- name: SonarCloud Scan | ||
uses: SonarSource/sonarcloud-github-action@master | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.PERSONAL_TOKEN }} | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: front-release | ||
|
||
on: | ||
push: | ||
branches: [main, devel] | ||
tags: | ||
- "v*" | ||
|
||
jobs: | ||
generate-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: 'Get Previous tag' | ||
id: previoustag | ||
uses: "WyriHaximus/github-action-get-previous-tag@v1" | ||
with: | ||
fallback: 1.0.0 | ||
|
||
- name: Use Node.js 16.x | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16.x | ||
|
||
- name: Cria métricas do SonarCloud | ||
run: python metrics/sonar-metrics.py ${{ github.event.repository.name }} ${{ github.ref_name }} | ||
|
||
- name: Commita arquivos de métricas do SonarCloud | ||
run: | | ||
git config --global user.email "${{ secrets.GIT_EMAIL }}" | ||
git config --global user.name "${{ secrets.GIT_USER }}" | ||
git clone --single-branch --branch main "https://x-access-token:${{ secrets.PERSONAL_TOKEN }}@github.com/fga-eps-mds/2024.1-SENTINELA-DOC" doc | ||
mkdir -p doc/analytics-raw-data | ||
cp -R fga-eps-mds*.json doc/analytics-raw-data | ||
cd doc | ||
git add . | ||
git commit -m "Métricas SonarCloud - ${{ github.event.repository.name }} ${{ github.ref_name }}" | ||
git push | ||
echo "Arquivos de métricas gerado com sucesso." |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,6 @@ dist-ssr | |
*.njsproj | ||
*.sln | ||
*.sw? | ||
|
||
# Tests coverage report | ||
coverage/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import json | ||
import sys | ||
import urllib.request | ||
from datetime import datetime | ||
|
||
def generate_metrics(): | ||
base_url = "https://sonarcloud.io/api/measures/component_tree?component=" | ||
prefix = "fga-eps-mds" | ||
metrics = [ | ||
"files", | ||
"functions", | ||
"complexity", | ||
"comment_lines_density", | ||
"duplicated_lines_density", | ||
"coverage", | ||
"ncloc", | ||
"tests", | ||
"test_errors", | ||
"test_failures", | ||
"test_execution_time", | ||
"security_rating" | ||
] | ||
|
||
repository_name = sys.argv[1] | ||
repository_version = sys.argv[2] | ||
underlined_repo_name = repository_name[:16] + \ | ||
repository_name[16:].replace('-', "_") | ||
url = f'{base_url}{repository_name}&metricKeys={",".join(metrics)}' | ||
with urllib.request.urlopen(url) as res: | ||
data = json.load(res) | ||
date = datetime.now() | ||
date_padrao_hilmer = f"{date.month}-{date.day}-{date.year}-{date.hour}-{date.minute}-{date.second}" | ||
|
||
filename = f"{prefix}-{underlined_repo_name}-{date_padrao_hilmer}-{repository_version}.json" | ||
print(filename) | ||
with open(filename, "w") as file: | ||
json.dump(data, file) | ||
|
||
|
||
if __name__ == "__main__": | ||
generate_metrics() |
Oops, something went wrong.