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

Feature - Automated pull request checks #1159

Open
wants to merge 55 commits into
base: main
Choose a base branch
from

Conversation

hozlucas28
Copy link
Contributor

@hozlucas28 hozlucas28 commented Jan 24, 2024

Descripción de la Pull Request

GitHub Action que comprueba las Pull Requests, en base a los lineamientos establecidos. Si se desea, se podría configurar el repositorio para que el merge se realize automáticamente al finalizar exitosamente la GitHub Action de la Pull Request.

¿Cómo funciona?

Una vez abierta, editada, reabierta o sincronizada una Pull Request donde se vea afectada la carpeta Roadmap se inicia el flujo de trabajo Check pull request. Ejecutando los siguientes trabajos:

  1. Check title: corrobora que el número de desafío y el nombre del lenguaje de programación existan. Para luego comprobar que el formato sea #<NÚMERO DE DESAFÍO> - <NOMBRE DEL LENGUAJE DE PROGRAMACIÓN>.
  2. Get committed files: obtiene los archivos añadidos, modificados o eliminados de la Pull Request.
  3. Check committed files: verifica que los archivos obtenidos sean uno solo.
  4. Check committed file: verifica la extensión, el nombre y la ruta del archivo en base al número de desafío y el lenguaje de programación del título de la Pull Request.

Note

La GitHub Action no se ejecutara si la Pull Request no afecta a la carpeta Roadmap ó si los archivos afectados son Markdowns.

Important

Si un trabajo falla, se detiene la ejecución de los siguientes y se notifica el error en las verificaciones de la Pull Request.

Archivos relevantes

FAQ

¿Por qué se modifico la plantilla de las Pull Requests?

Se modifico con el fin de evitar el inicio indeseado de la GitHub Action al actualizar las casillas de verificación. Además, se corrigió un error ortográfico.

¿Desde donde se obtienen los datos para corroborar la Pull Request?

La información necesaria para corroborar la Pull Request se extrae del contenido de la carpeta Roadmap del repositorio remoto. Gracias a una serie de funciones presentes en utils.mjs.

Imágenes

Fallo del flujo de trabajo "Check pull request" debido a una serie de errores en el trabajo "Check title"

El trabajo Check title falla porque el título de la Pull Request es incorrecto. Reportando los errores encontrados.

Fallo del flujo de trabajo "Check pull request" debido a un error en el trabajo "Check committed files"

El trabajo Check committed files falla porque los archivos obtenidos de la Pull Request no son uno solo. Reportando los errores encontrados.

Fallo del flujo de trabajo "Check pull request" debido a una serie de errores en el trabajo "Check committed file"

El trabajo Check committed file falla porque la extensión, el nombre y la ruta del archivo no corresponden con el título y el autor de la Pull Request. Reportando los errores encontrados.

Flujo de trabajo "Check pull request" finalizado con éxito

Se ejecutaron todos los trabajos sin errores. Por lo que la Pull Request cumple con los lineamientos establecidos para que se realize el merge automáticamente.

* Create check-pull-request-title action

* Create check-pull-request-changed-files action

* Add utils.js file with language and challenge functions

* Add language data to data.json

* Add GitHub Actions workflow to check pull requests

* Add pull request title and changed file checks

This commit adds two new jobs to the GitHub Actions workflow. The first job checks the title of the pull request, while the second job retrieves the changed and modified files. These changes will help ensure that the pull request meets the required criteria.

* Update language names in data.json

* Update pull request title validation
Refactor the pull request title validation logic to use the correct input name and programming language names. This ensures that the title follows the format "#<CHALLENGE NUMBER> - <LANGUAGE NAME>".

* Refactor utils.js to use object literals for challenges and programming languages

* Update comments

* Rename input name in check-pull-request.yml workflow

* Update strings of check-pull-request-title action

* Update action.yml and main.js for checking changed and modified files of a pull request

* Move and rename action folders

* Update file extension name in data.json

* Add outputs for challenge number and programming language name based on pull request title

* Add new outputs

* Add Roadmap folder to pull request check

This commit adds the 'Roadmap' folder to the pull request check, excluding any markdown files within it.

* Refactor pull request title validation logic

* Add debug statement to check changed and modified files

* Create action to check changed or modified file

* Refactor utils.js to add new functions and improve existing ones

* Update language data in data.json

* Update workflow inputs and outputs

* Update inputs and outputs

* Update output variable name

* Update output variable names

* Update programming-language description in action.yml

* Refactor check-changed-or-modified-file script

This commit refactors the check-changed-or-modified-file script by updating variable names and improving code readability.

* Refactor utils.js to improve readability and add new functionality
* Create check-pull-request-title action

* Create check-pull-request-changed-files action

* Add utils.js file with language and challenge functions

* Add language data to data.json

* Add GitHub Actions workflow to check pull requests

* Add pull request title and changed file checks

This commit adds two new jobs to the GitHub Actions workflow. The first job checks the title of the pull request, while the second job retrieves the changed and modified files. These changes will help ensure that the pull request meets the required criteria.

* Update language names in data.json

* Update pull request title validation
Refactor the pull request title validation logic to use the correct input name and programming language names. This ensures that the title follows the format "#<CHALLENGE NUMBER> - <LANGUAGE NAME>".

* Refactor utils.js to use object literals for challenges and programming languages

* Update comments

* Rename input name in check-pull-request.yml workflow

* Update strings of check-pull-request-title action

* Update action.yml and main.js for checking changed and modified files of a pull request

* Move and rename action folders

* Update file extension name in data.json

* Add outputs for challenge number and programming language name based on pull request title

* Add new outputs

* Add Roadmap folder to pull request check

This commit adds the 'Roadmap' folder to the pull request check, excluding any markdown files within it.

* Refactor pull request title validation logic

* Add debug statement to check changed and modified files

* Create action to check changed or modified file

* Refactor utils.js to add new functions and improve existing ones

* Update language data in data.json

* Update workflow inputs and outputs

* Update inputs and outputs

* Update output variable name

* Update output variable names

* Update programming-language description in action.yml

* Refactor check-changed-or-modified-file script

This commit refactors the check-changed-or-modified-file script by updating variable names and improving code readability.

* Refactor utils.js to improve readability and add new functionality

* Improve error messages

* Refactor code to use utility function for formatting array to string

* Improve names

* Improve descriptions and names

* Refactor input and output names in check-changed-and-modified-files action

* Refactor pull request title validation logic

* Update debug message in main.js

* Refactor utils.js file

* Add type module to package.json

* Refactor check-title/main.js for improved readability and maintainability

* Add type module to package.json

* Remove unused language data

* Update inputs in action.yml file

* Refactor file paths and inputs in check-changed-or-modified-file action

* Fix pull request title format

* Refactor code to improve readability and maintainability

* Refactor GitHub Actions workflow

This commit refactors the GitHub Actions workflow for checking pull requests. It removes unused outputs and simplifies the steps.

* Add read permission to pull requests

* Rename action folders
* Create check-pull-request-title action

* Create check-pull-request-changed-files action

* Add utils.js file with language and challenge functions

* Add language data to data.json

* Add GitHub Actions workflow to check pull requests

* Add pull request title and changed file checks

This commit adds two new jobs to the GitHub Actions workflow. The first job checks the title of the pull request, while the second job retrieves the changed and modified files. These changes will help ensure that the pull request meets the required criteria.

* Update language names in data.json

* Update pull request title validation
Refactor the pull request title validation logic to use the correct input name and programming language names. This ensures that the title follows the format "#<CHALLENGE NUMBER> - <LANGUAGE NAME>".

* Refactor utils.js to use object literals for challenges and programming languages

* Update comments

* Rename input name in check-pull-request.yml workflow

* Update strings of check-pull-request-title action

* Update action.yml and main.js for checking changed and modified files of a pull request

* Move and rename action folders

* Update file extension name in data.json

* Add outputs for challenge number and programming language name based on pull request title

* Add new outputs

* Add Roadmap folder to pull request check

This commit adds the 'Roadmap' folder to the pull request check, excluding any markdown files within it.

* Refactor pull request title validation logic

* Add debug statement to check changed and modified files

* Create action to check changed or modified file

* Refactor utils.js to add new functions and improve existing ones

* Update language data in data.json

* Update workflow inputs and outputs

* Update inputs and outputs

* Update output variable name

* Update output variable names

* Update programming-language description in action.yml

* Refactor check-changed-or-modified-file script

This commit refactors the check-changed-or-modified-file script by updating variable names and improving code readability.

* Refactor utils.js to improve readability and add new functionality

* Improve error messages

* Refactor code to use utility function for formatting array to string

* Improve names

* Improve descriptions and names

* Refactor input and output names in check-changed-and-modified-files action

* Refactor pull request title validation logic

* Update debug message in main.js

* Refactor utils.js file

* Add type module to package.json

* Refactor check-title/main.js for improved readability and maintainability

* Add type module to package.json

* Remove unused language data

* Update inputs in action.yml file

* Refactor file paths and inputs in check-changed-or-modified-file action

* Fix pull request title format

* Refactor code to improve readability and maintainability

* Refactor GitHub Actions workflow

This commit refactors the GitHub Actions workflow for checking pull requests. It removes unused outputs and simplifies the steps.

* Add read permission to pull requests

* Rename action folders

* Change jobs order

* Fix roadmapPath

* Add separator option to get committed files

* Update splitting of committed files

* Add ref on checkouts
* Create check-pull-request-title action

* Create check-pull-request-changed-files action

* Add utils.js file with language and challenge functions

* Add language data to data.json

* Add GitHub Actions workflow to check pull requests

* Add pull request title and changed file checks

This commit adds two new jobs to the GitHub Actions workflow. The first job checks the title of the pull request, while the second job retrieves the changed and modified files. These changes will help ensure that the pull request meets the required criteria.

* Update language names in data.json

* Update pull request title validation
Refactor the pull request title validation logic to use the correct input name and programming language names. This ensures that the title follows the format "#<CHALLENGE NUMBER> - <LANGUAGE NAME>".

* Refactor utils.js to use object literals for challenges and programming languages

* Update comments

* Rename input name in check-pull-request.yml workflow

* Update strings of check-pull-request-title action

* Update action.yml and main.js for checking changed and modified files of a pull request

* Move and rename action folders

* Update file extension name in data.json

* Add outputs for challenge number and programming language name based on pull request title

* Add new outputs

* Add Roadmap folder to pull request check

This commit adds the 'Roadmap' folder to the pull request check, excluding any markdown files within it.

* Refactor pull request title validation logic

* Add debug statement to check changed and modified files

* Create action to check changed or modified file

* Refactor utils.js to add new functions and improve existing ones

* Update language data in data.json

* Update workflow inputs and outputs

* Update inputs and outputs

* Update output variable name

* Update output variable names

* Update programming-language description in action.yml

* Refactor check-changed-or-modified-file script

This commit refactors the check-changed-or-modified-file script by updating variable names and improving code readability.

* Refactor utils.js to improve readability and add new functionality

* Improve error messages

* Refactor code to use utility function for formatting array to string

* Improve names

* Improve descriptions and names

* Refactor input and output names in check-changed-and-modified-files action

* Refactor pull request title validation logic

* Update debug message in main.js

* Refactor utils.js file

* Add type module to package.json

* Refactor check-title/main.js for improved readability and maintainability

* Add type module to package.json

* Remove unused language data

* Update inputs in action.yml file

* Refactor file paths and inputs in check-changed-or-modified-file action

* Fix pull request title format

* Refactor code to improve readability and maintainability

* Refactor GitHub Actions workflow

This commit refactors the GitHub Actions workflow for checking pull requests. It removes unused outputs and simplifies the steps.

* Add read permission to pull requests

* Rename action folders

* Change jobs order

* Fix roadmapPath

* Add separator option to get committed files

* Update splitting of committed files

* Add ref on checkouts

* Fix regex
@hozlucas28 hozlucas28 marked this pull request as ready for review January 24, 2024 05:54
@hozlucas28 hozlucas28 changed the title Feature/hozlucas28 automated pull request checks Feature - Automated Pull Request Checks Jan 24, 2024
@hozlucas28 hozlucas28 changed the title Feature - Automated Pull Request Checks Feature - Automated pull request checks Jan 24, 2024
@mouredev mouredev self-assigned this Jan 25, 2024
@mouredev
Copy link
Owner

Hola!

Muchísimas gracias por el trabajo 🙌

A día de hoy tenemos un problema, delegar toda la revisión en el sistema exige que el usuario realice PR perfectas, y creo que estamos lejos de eso. Prefiero primar que la gente colabore a exigirles muchos cambios.

Siendo realistas, aunque se recomiendan varias cosas, lo esencial, si no me equivoco, sería esto:

  • Nombre del fichero igual al del usuario (no tiene porqué coincidir en mayus/minus)
  • Extensión del fichero correcta para el directorio donde se encuentra. Aquí lo que se me ocurre es que se podría generar un diccionario de extensiones|lenguaje, para así no depender del título. Y en caso de que aparezca algún nuevo lenguaje, ir dándole soporte, o simplemente no aceptar la PR y revisarla a mano.
  • Un usuario puede enviar varias correcciones en la misma PR.

¿Cómo lo ves de factible?

@Roswell468 @kontroldev

@Roswell468
Copy link
Collaborator

Hola!

Muchísimas gracias por el trabajo 🙌

A día de hoy tenemos un problema, delegar toda la revisión en el sistema exige que el usuario realice PR perfectas, y creo que estamos lejos de eso. Prefiero primar que la gente colabore a exigirles muchos cambios.

Siendo realistas, aunque se recomiendan varias cosas, lo esencial, si no me equivoco, sería esto:

  • Nombre del fichero igual al del usuario (no tiene porqué coincidir en mayus/minus)
  • Extensión del fichero correcta para el directorio donde se encuentra. Aquí lo que se me ocurre es que se podría generar un diccionario de extensiones|lenguaje, para así no depender del título. Y en caso de que aparezca algún nuevo lenguaje, ir dándole soporte, o simplemente no aceptar la PR y revisarla a mano.
  • Un usuario puede enviar varias correcciones en la misma PR.

¿Cómo lo ves de factible?

@Roswell468 @kontroldev

Hola!
Yo agregaría a los puntos mencionados por Moure que la carpeta del lenguaje esté en minúsculas.

@hozlucas28
Copy link
Contributor Author

Buenas!

Modifique la GitHub action para que verifique solamente los aspectos esenciales de las Pull Requests, como dijo el patrón (@mouredev). Pudiendo enviar más de una corrección.

@Roswell468 también he agregado la condición que verifica que el nombre de la carpeta del lenguaje de programación sea en minúsculas. La compara con las existentes, ya que estas se encuentran en minúsculas. Además, arregle un pequeño bug en la función que obtenía las carpetas de los lenguajes de programación, ya que no captaba aquellas que en su nombre tenían un ., por ejemplo: vb.net.

En base al código todos los lenguajes existentes en el repositorio remoto deberían pasar la verificación de existencia de la GitHub Action. Si el lenguaje no existiera, un administrador debería mergear manualmente la Pull Request, solucionando el fallo para las siguientes ejecuciones de la GitHub Action.

Realizare los test para asegurarme que todo funcione correctamente. Les notificare.

@hozlucas28
Copy link
Contributor Author

hozlucas28 commented Jan 27, 2024

Test concluidos 🧪

Luego de realizar algunos ajustes todos los Test de la GitHub Action concluyeron exitosamente. A continuación una breve descripción de estos, junto con sus respectivos enlaces:

Test Descripción
01 Corroborar que el archivo se encuentre en la carpeta del lenguaje de programación correspondiente.
02 Corroborar que el nombre del archivo equivalga al nombre del autor, sin tener en cuenta mayúsculas o minúsculas.
03 Permitir multiples correcciones, siendo cada una evaluada independientemente para corroborar que cumplen con los aspectos esenciales.
04 Comportamiento de la GitHub Action si el archivo stats.json ha sido modificado.

Si revisan el estado de las acciones en cada Commit de los Test podrán observar las distintas respuestas de la GitHub Action.

Si se concreta el Merge recomiendo realizar un Squash de la Pull Request. Debido a que realize un Merge sin querer con una rama de mi Fork, y aunque logre revertirlo, se conservaron commits basura que ensuciarían el historial de Commits de la rama Main.

Warning

Si se quisiera que la GitHub Action realize el Push automáticamente de la Pull Request, solo si las condiciones esperadas se cumplieron, se debería agregar un nuevo Step al Job: check-committed-files. Debido a que se trata de una acción peligrosa, en caso de que se realize el Merge, recomiendo observar el comportamiento de la GitHub Action durante una semana para decidir si incorporar el Push automático o no.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants