Skip to content

Feature/hozlucas28 automated checks #3

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

Merged
merged 50 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
dd9b6d2
Create check-pull-request-title action
hozlucas28 Jan 22, 2024
8c220f9
Create check-pull-request-changed-files action
hozlucas28 Jan 22, 2024
f68dd32
Add utils.js file with language and challenge functions
hozlucas28 Jan 22, 2024
e30e9fe
Add language data to data.json
hozlucas28 Jan 22, 2024
b75bccd
Add GitHub Actions workflow to check pull requests
hozlucas28 Jan 22, 2024
e3abfd0
Add pull request title and changed file checks
hozlucas28 Jan 22, 2024
53e8d6c
Update language names in data.json
hozlucas28 Jan 22, 2024
ec67198
Update pull request title validation
hozlucas28 Jan 22, 2024
ce7e5e8
Refactor utils.js to use object literals for challenges and programmi…
hozlucas28 Jan 22, 2024
a6cea98
Update comments
hozlucas28 Jan 22, 2024
f656d03
Rename input name in check-pull-request.yml workflow
hozlucas28 Jan 22, 2024
9c2db6f
Update strings of check-pull-request-title action
hozlucas28 Jan 22, 2024
64015a8
Update action.yml and main.js for checking changed and modified files…
hozlucas28 Jan 22, 2024
66c4c88
Move and rename action folders
hozlucas28 Jan 22, 2024
2acba31
Update file extension name in data.json
hozlucas28 Jan 22, 2024
d70552a
Add outputs for challenge number and programming language name based …
hozlucas28 Jan 22, 2024
dfaee92
Add new outputs
hozlucas28 Jan 22, 2024
5ceced5
Add Roadmap folder to pull request check
hozlucas28 Jan 22, 2024
7167b85
Refactor pull request title validation logic
hozlucas28 Jan 22, 2024
663950b
Add debug statement to check changed and modified files
hozlucas28 Jan 22, 2024
ef00b88
Create action to check changed or modified file
hozlucas28 Jan 22, 2024
f7881df
Refactor utils.js to add new functions and improve existing ones
hozlucas28 Jan 22, 2024
0ed0673
Update language data in data.json
hozlucas28 Jan 22, 2024
bf6aa18
Update workflow inputs and outputs
hozlucas28 Jan 22, 2024
a1d92f9
Update inputs and outputs
hozlucas28 Jan 22, 2024
f5bb702
Update output variable name
hozlucas28 Jan 22, 2024
0c03453
Update output variable names
hozlucas28 Jan 22, 2024
3f8e014
Update programming-language description in action.yml
hozlucas28 Jan 22, 2024
f2c5a22
Refactor check-changed-or-modified-file script
hozlucas28 Jan 22, 2024
01da703
Refactor utils.js to improve readability and add new functionality
hozlucas28 Jan 22, 2024
1304e9c
Improve error messages
hozlucas28 Jan 22, 2024
9108c8f
Refactor code to use utility function for formatting array to string
hozlucas28 Jan 22, 2024
ceb4c71
Improve names
hozlucas28 Jan 22, 2024
8476e5a
Improve descriptions and names
hozlucas28 Jan 22, 2024
39fa19b
Refactor input and output names in check-changed-and-modified-files a…
hozlucas28 Jan 22, 2024
09a891f
Refactor pull request title validation logic
hozlucas28 Jan 22, 2024
2243535
Update debug message in main.js
hozlucas28 Jan 22, 2024
13c6263
Refactor utils.js file
hozlucas28 Jan 22, 2024
aa1f201
Add type module to package.json
hozlucas28 Jan 22, 2024
5d04860
Refactor check-title/main.js for improved readability and maintainabi…
hozlucas28 Jan 22, 2024
84c57ae
Add type module to package.json
hozlucas28 Jan 22, 2024
387ba5b
Remove unused language data
hozlucas28 Jan 22, 2024
38e4a28
Update inputs in action.yml file
hozlucas28 Jan 22, 2024
264031b
Refactor file paths and inputs in check-changed-or-modified-file action
hozlucas28 Jan 22, 2024
c4e124f
Fix pull request title format
hozlucas28 Jan 22, 2024
e068c8a
Refactor code to improve readability and maintainability
hozlucas28 Jan 22, 2024
dd0b2f4
Refactor GitHub Actions workflow
hozlucas28 Jan 22, 2024
c769d7d
Add read permission to pull requests
hozlucas28 Jan 22, 2024
f7d63af
Rename action folders
hozlucas28 Jan 22, 2024
b4f7ea0
Merge branch 'main' into feature/hozlucas28-automated-checks
hozlucas28 Jan 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
19 changes: 19 additions & 0 deletions .github/actions/pull-requests/check-committed-file/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
author: 'hozlucas28'

name: 'Check committed file'
description: 'Check if the committed file of a pull request is valid'

runs:
using: 'node20'
main: 'main.js'

inputs:
author:
description: 'Name of the user who created the pull request'
required: true
committed-file:
description: 'Committed file of the pull request'
required: true
title:
description: 'Title of the pull request'
required: true
55 changes: 55 additions & 0 deletions .github/actions/pull-requests/check-committed-file/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { debug, getInput, setFailed } from '@actions/core'
import * as path from 'node:path'
import { getChallengeFolder, getProgrammingLanguageExtension, wrapperChallengesFolder } from '../../utils.js'

// Inputs
const author = getInput('author')
const committedFile = getInput('committed-file')
const title = getInput('title')
debug(`'author' (input): ${author}`)
debug(`'committed-file' (input): ${committedFile}`)
debug(`'title' (input): ${title}`)

// Required data
const titleProps = {
challenge: title.slice(1, 3),
language: title.slice(6).toLowerCase(),
}

const challengeFolder = getChallengeFolder(titleProps.challenge)
const committedFileProps = path.parse(committedFile)

// Check if directory is valid
const expectedDirectory = path.join(wrapperChallengesFolder, challengeFolder, titleProps.language)
const isValidDirectory = path.normalize(committedFileProps.dir) === expectedDirectory
if (!isValidDirectory) {
setFailed(
"Directory of committed file doesn't match with the challenge and programming language of the pull request title. " +
'Please check the directory of committed file of the pull request. ' +
`It should be: '${expectedDirectory}'. ` +
'If you think this is an error, please contact an administrator.'
)
}

// Check if file name is valid
const isValidFileName = committedFileProps.name === author
if (!isValidFileName) {
setFailed(
"File name of committed file doesn't match with the author name. " +
'Please check the file name of committed file of the pull request. ' +
`It should be: '${author}'. ` +
'If you think this is an error, please contact an administrator.'
)
}

// Check if file extension is valid
const expectedFileExtension = getProgrammingLanguageExtension(titleProps.language)
const isValidFileExtension = committedFileProps.ext === expectedFileExtension
if (!isValidFileExtension) {
setFailed(
"File extension of committed file doesn't match with the programming language name of the pull request title. " +
'Please check the file extension name of committed file of the pull request. ' +
`It should be: '${expectedFileExtension}'. ` +
'If you think this is an error, please contact an administrator.'
)
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading