Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GH Action] Code quality checks #91

Merged
merged 11 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
GITHUB_TOKEN=
NEXT_PUBLIC_SUPABASE_URL=
NEXT_PUBLIC_SUPABASE_ANON_KEY=
8 changes: 4 additions & 4 deletions .github/dana-crawler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: Docker

on:
push:
branches: ["main"]
branches: ['main']
# Publish semver tags as releases.
tags: ["v*.*.*"]
tags: ['v*.*.*']
paths:
- "tools/DanaCrawler/**"
- 'tools/DanaCrawler/**'

env:
REGISTRY: ghcr.io
Expand All @@ -27,7 +27,7 @@ jobs:
- name: Install cosign
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0
with:
cosign-release: "v2.2.4"
cosign-release: 'v2.2.4'

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/code-quality-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Code quality checks

on:
push:
branches:
- '**'
pull_request:
branches:
- '**'

jobs:
quality:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install dependencies
run: npm install

- name: Run ESLint
run: npm run lint

- name: Check formatting
run: npm run prettier:check

- name: Build app
env:
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
run: npm run build
8 changes: 4 additions & 4 deletions .github/workflows/dana-crawler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: Docker

on:
push:
branches: ["main"]
branches: ['main']
# Publish semver tags as releases.
tags: ["v*.*.*"]
tags: ['v*.*.*']
paths:
- "tools/DanaCrawler/**"
- 'tools/DanaCrawler/**'

env:
REGISTRY: ghcr.io
Expand All @@ -27,7 +27,7 @@ jobs:
- name: Install cosign
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0
with:
cosign-release: "v2.2.4"
cosign-release: 'v2.2.4'

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ Encontraras un archivo .env.example para usar de referencia

Las contribuciones son siempre bienvenidas.

Consulta `contributing.md` para saber cómo empezar.
Consulta `contributing.md` para saber cómo empezar.
56 changes: 28 additions & 28 deletions kubernetes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
serviceAccountName: datadog-agent
containers:
- name: emergency-cv--webapp
image: "localhost:30500/emergency-cv/webapp:VAR_GITHUB_COMMIT_HASH"
image: 'localhost:30500/emergency-cv/webapp:VAR_GITHUB_COMMIT_HASH'
ports:
- containerPort: 3000
env:
Expand All @@ -42,37 +42,37 @@ spec:
image: gcr.io/datadoghq/agent:latest
env:
- name: DD_API_KEY
value: "VAR_DATADOG_API_KEY"
value: 'VAR_DATADOG_API_KEY'
- name: DD_SITE
value: "datadoghq.eu"
value: 'datadoghq.eu'
- name: DD_LOGS_ENABLED
value: "true"
value: 'true'
- name: DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL
value: "true"
value: 'true'
- name: DD_APM_ENABLED
value: "true"
value: 'true'
- name: DD_APM_NON_LOCAL_TRAFFIC
value: "true"
value: 'true'
- name: DD_KUBELET_TLS_VERIFY
value: "false"
value: 'false'
- name: DD_PROCESS_AGENT_ENABLED
value: "true"
value: 'true'
- name: DD_CONTAINER_EXCLUDE
value: "image:gcr.io/datadoghq/agent"
value: 'image:gcr.io/datadoghq/agent'
- name: DD_CONTAINER_INCLUDE_METRICS
value: "name:emergency-cv--webapp"
value: 'name:emergency-cv--webapp'
- name: DD_CONTAINER_INCLUDE_LOGS
value: "name:emergency-cv--webapp"
value: 'name:emergency-cv--webapp'
- name: DD_SYSTEM_PROBE_ENABLED
value: "false"
value: 'false'
- name: DD_KUBERNETES_KUBELET_HOST
valueFrom:
fieldRef:
fieldPath: status.hostIP
securityContext:
privileged: false
capabilities:
add: [ "SYS_ADMIN" ]
add: ['SYS_ADMIN']
ports:
- containerPort: 8126
name: traceport
Expand Down Expand Up @@ -117,13 +117,13 @@ spec:
- name: kaniko
image: gcr.io/kaniko-project/executor:latest
args:
- "--context=git://[email protected]/pedrolivaresanchez/emergency-cv.git"
- "--dockerfile=Dockerfile"
- "--destination=idl-apps--container-registry-service:5000/emergency-cv/webapp:VAR_GITHUB_COMMIT_HASH"
- "--insecure"
- "--skip-tls-verify"
- "--build-arg=NEXT_PUBLIC_SUPABASE_URL=VAR_SUPABASE_URL"
- "--build-arg=NEXT_PUBLIC_SUPABASE_ANON_KEY=VAR_SUPABASE_ANON_KEY"
- '--context=git://[email protected]/pedrolivaresanchez/emergency-cv.git'
- '--dockerfile=Dockerfile'
- '--destination=idl-apps--container-registry-service:5000/emergency-cv/webapp:VAR_GITHUB_COMMIT_HASH'
- '--insecure'
- '--skip-tls-verify'
- '--build-arg=NEXT_PUBLIC_SUPABASE_URL=VAR_SUPABASE_URL'
- '--build-arg=NEXT_PUBLIC_SUPABASE_ANON_KEY=VAR_SUPABASE_ANON_KEY'
restartPolicy: Never
backoffLimit: 2
---
Expand All @@ -138,7 +138,7 @@ kind: ClusterRole
metadata:
name: datadog-agent
rules:
- apiGroups: [ "" ]
- apiGroups: ['']
resources:
- nodes
- nodes/metrics
Expand All @@ -149,16 +149,16 @@ rules:
- services
- endpoints
- events
verbs: [ "get", "list", "watch" ]
- apiGroups: [ "" ]
verbs: ['get', 'list', 'watch']
- apiGroups: ['']
resources:
- configmaps
resourceNames: [ "datadog-leader-election" ]
verbs: [ "get", "update" ]
- apiGroups: [ "" ]
resourceNames: ['datadog-leader-election']
verbs: ['get', 'update']
- apiGroups: ['']
resources:
- configmaps
verbs: [ "create" ]
verbs: ['create']
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
Expand Down
8 changes: 4 additions & 4 deletions middleware.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { type NextRequest } from 'next/server'
import { updateSession } from 'src/lib/supabase/middleware'
import { type NextRequest } from 'next/server';
import { updateSession } from 'src/lib/supabase/middleware';

export async function middleware(request: NextRequest) {
return await updateSession(request)
return await updateSession(request);
}

export const config = {
Expand All @@ -16,4 +16,4 @@ export const config = {
*/
'/((?!_next/static|_next/image|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)',
],
}
};
6 changes: 3 additions & 3 deletions src/app/solicitar-ayuda/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ export default function SolicitarAyuda() {
contacto: '',
pueblo: '',
consentimiento: false,
email: ''
email: '',
});

setStatus({ isSubmitting: false, error: null, success: true });
setStatus((prev) => ({ ...prev, success: false }));
router.push('/casos-activos/solicitudes');
setStatus((prev) => ({ ...prev, success: false }));
router.push('/casos-activos/solicitudes');
} catch (error) {
console.log('Error al enviar solicitud:', error.message);
setStatus({
Expand Down
73 changes: 34 additions & 39 deletions src/components/Pagination.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
import React from 'react';

const Pagination = ({ currentPage, totalPages, onPageChange }) => {
const getPageNumbers = () => {
const pageNumbers = [];
const rangeSize = 1; // Número de páginas a mostrar alrededor de la actual
const getPageNumbers = () => {
const pageNumbers = [];
const rangeSize = 1; // Número de páginas a mostrar alrededor de la actual

// Mostrar las primeras páginas con '...' si estamos lejos
if (currentPage > rangeSize + 2) {
pageNumbers.push(1, 2, '...');
} else {
for (let i = 1; i < Math.min(totalPages + 1, currentPage + rangeSize + 1); i++) {
pageNumbers.push(i);
}
}
// Mostrar las primeras páginas con '...' si estamos lejos
if (currentPage > rangeSize + 2) {
pageNumbers.push(1, 2, '...');
} else {
for (let i = 1; i < Math.min(totalPages + 1, currentPage + rangeSize + 1); i++) {
pageNumbers.push(i);
}
}

// Mostrar el rango de páginas alrededor de la página actual sin duplicar
const start = Math.max(3, currentPage - rangeSize);
const end = Math.min(totalPages - 2, currentPage + rangeSize);
for (let i = start; i <= end; i++) {
if (!pageNumbers.includes(i)) {
pageNumbers.push(i);
}
}
// Mostrar el rango de páginas alrededor de la página actual sin duplicar
const start = Math.max(3, currentPage - rangeSize);
const end = Math.min(totalPages - 2, currentPage + rangeSize);
for (let i = start; i <= end; i++) {
if (!pageNumbers.includes(i)) {
pageNumbers.push(i);
}
}

// Mostrar las últimas páginas con '...' si estamos lejos
if (currentPage < totalPages - rangeSize - 1) {
pageNumbers.push('...', totalPages - 1, totalPages);
} else {
for (let i = Math.max(start, totalPages - rangeSize); i <= totalPages; i++) {
if (!pageNumbers.includes(i)) {
pageNumbers.push(i);
}
}
// Mostrar las últimas páginas con '...' si estamos lejos
if (currentPage < totalPages - rangeSize - 1) {
pageNumbers.push('...', totalPages - 1, totalPages);
} else {
for (let i = Math.max(start, totalPages - rangeSize); i <= totalPages; i++) {
if (!pageNumbers.includes(i)) {
pageNumbers.push(i);
}
}
}

return pageNumbers;
};
return pageNumbers;
};

if (totalPages < 2) {
return;
Expand All @@ -45,9 +45,7 @@ const Pagination = ({ currentPage, totalPages, onPageChange }) => {
<div className="flex items-center space-x-2 mt-4">
{/* Botón de retroceso */}
<button
className={`px-3 py-1 border rounded-md text-gray-600 hover:bg-gray-100 ${
currentPage === 1 ? "hidden" : ""
}`}
className={`px-3 py-1 border rounded-md text-gray-600 hover:bg-gray-100 ${currentPage === 1 ? 'hidden' : ''}`}
onClick={() => onPageChange(currentPage - 1)}
>
Anterior
Expand All @@ -59,9 +57,7 @@ const Pagination = ({ currentPage, totalPages, onPageChange }) => {
key={index}
onClick={() => typeof page === 'number' && onPageChange(page)}
className={`px-3 py-1 border rounded-md ${
page === currentPage
? 'bg-blue-500 text-white'
: 'text-gray-600 hover:bg-gray-100'
page === currentPage ? 'bg-blue-500 text-white' : 'text-gray-600 hover:bg-gray-100'
}`}
disabled={page === '...'}
>
Expand All @@ -72,15 +68,14 @@ const Pagination = ({ currentPage, totalPages, onPageChange }) => {
{/* Botón de avance */}
<button
className={`px-3 py-1 border rounded-md text-gray-600 hover:bg-gray-100 ${
currentPage === totalPages ? "hidden" : ""
currentPage === totalPages ? 'hidden' : ''
}`}
onClick={() => onPageChange(currentPage + 1)}

>
Siguiente
</button>
</div>
);
};

export default Pagination;
export default Pagination;
30 changes: 15 additions & 15 deletions src/components/Tab.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
'use client';

import Link from "next/link";
import Link from 'next/link';

export default function Tab({ children, ...props}) {
return (
<Link
href={props.href}
className={`flex flex-col items-center justify-center py-3 px-2 rounded-lg transition-colors ${
props.isPath
? `bg-${props.color}-500 text-white`
: 'bg-gray-50 hover:bg-gray-100 text-gray-600 hover:text-gray-900'
}`}
>
{ children }
</Link>
)
}
export default function Tab({ children, ...props }) {
return (
<Link
href={props.href}
className={`flex flex-col items-center justify-center py-3 px-2 rounded-lg transition-colors ${
props.isPath
? `bg-${props.color}-500 text-white`
: 'bg-gray-50 hover:bg-gray-100 text-gray-600 hover:text-gray-900'
}`}
>
{children}
</Link>
);
}
Loading