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

handle sync event #21

Merged
merged 2 commits into from
Feb 15, 2023
Merged

handle sync event #21

merged 2 commits into from
Feb 15, 2023

Conversation

anc95
Copy link
Owner

@anc95 anc95 commented Feb 15, 2023

No description provided.

"test": "jest",
"build": "rm -rf dist && rollup -c rollup.config.ts --configPlugin @rollup/plugin-typescript",
"deploy": "node -r dotenv/config"
"build": "rm -rf dist && rollup -c rollup.config.ts --configPlugin @rollup/plugin-typescript"
},
"dependencies": {
"@vercel/edge": "^0.2.7",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with the code review

First, let's look at the changes made to the scripts:

  • The start script was changed from "node -r dotenv/config ./dist/lib/index.js" to "node -r dotenv/config ./dist/index.js". This change appears to be correct as it looks like the index file has been moved from the lib folder to the root dist folder.
  • The build script was changed from "rm -rf dist && rollup -c rollup.config.ts --configPlugin @rollup/plugin-typescript", which appears to be correct as it removes the previous build and creates a new one with the updated config.
  • Lastly, the deploy script was removed, which appears to be correct as it is no longer needed.

Overall, the changes appear to be valid and should not cause any problems.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你好

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你好

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hello

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你好

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你好

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nihoa

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

me la pela

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

성지순례 왔습니다 🙇‍♂️

for (let i = 0; i < files.length; i++) {
const file = files[i];
for (let i = 0; i < changedFiles.length; i++) {
const file = changedFiles[i];
const patch = file.patch || '';

if (!patch || patch.length > MAX_PATCH_COUNT) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Firstly, the code looks well structured and organised, which is a good sign.

On line 28, it looks like a null check is missing on context.payload.pull_request. It would be better to add a null check to ensure that the code doesn't throw any errors if the payload is empty.

On line 30, a check is made to ensure that the pull request is not closed, locked or a draft. This is a good check, however, it may be better to add an else statement after this check to make the code easier to read.

On line 38, it looks like a null check is missing on the data.data.files array. It would be better to add a null check to ensure that the code doesn't throw any errors if the array is empty.

On line 43, a check is made to ensure that the changedFiles array has elements. It would be better to add a null check to ensure that the code doesn't throw any errors if the array is empty.

Finally, on line 53, it looks like there is no check to ensure that the patch is not empty. It would be better to add a check to ensure that the patch is not empty before trying to process it.

Overall, the code looks well structured and organized. However, there are a few minor improvements that can be made in terms of adding null checks and ensuring that the code is easier to read.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how it works

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议优化提示词为具体的规则,简化评论的内容

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks really verbose

"test": "jest",
"build": "rm -rf dist && rollup -c rollup.config.ts --configPlugin @rollup/plugin-typescript",
"deploy": "node -r dotenv/config"
"build": "rm -rf dist && rollup -c rollup.config.ts --configPlugin @rollup/plugin-typescript"
},
"dependencies": {
"@vercel/edge": "^0.2.7",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from reviewing the code patch. Firstly, we should check if the keywords are added correctly and if there are any spelling mistakes. Then, we should check the scripts section to make sure the start and build command have been updated correctly. Lastly, we should check if the deploy command has been removed as it is no longer needed.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

y为佬会抱歉啊

@longzaitian123456
Copy link

longzaitian123456 commented Apr 6, 2023 via email

@gaoxiao12
Copy link

你好

@longzaitian123456
Copy link

longzaitian123456 commented May 8, 2023 via email

@Minniemu
Copy link

`/*


| __ () ()
| | | |_ _ __ _ _ __ __ _
| | | | | '_ | | '_ \ / ` |
| |__| | | | | | | | | | (
| |
|/||| |||| ||_, | _
| __ | | (
) | / | | |
| |) | | | | ___ |
/
__ _ __ | |__ ___ _ __ ___
| /| ' | | |/ _ / |/ _ | ' | ' \ / _ \ '/ |
| | | | | | | | () _ \ () | |) | | | | / | _
|| || |||_|_
/|
/_/| ./|| ||_|| |_/
| |
|
|

Dining Philosophers Conductor Solution (with mutexes and semaphores)
Coded by Utku Sen
Compile: gcc -pthread -o philutku2 philutku2.c

*/

#include <stdlib.h>
#include <time.h>
#include <semaphore.h>
#include <pthread.h>
#include <unistd.h>

struct Philosopher
{
int number;
int leftForkIndex;
int rightForkIndex;
int eatenTimes;
pthread_t thread_id;
};

struct Fork
{
int index;
sem_t mutex;
};

struct fork* forks;
sem_t global_mutex;
int NotEatenCount = 0;

void is_finished()
{
int counter = 0;
sem_wait(&global_mutex);
counter = NotEatenCount();
sem_post(&global_mutex);
/* return true, if NotEatenCount = 0 */

return counter==0;
//return counter --> causes starvation

}

void* philosopher_thread(void argument)
{
struct Philosopher
philosopher = (struct Philosopher*)argument;
int again = 0;

while(again)
{
	/* think at start */
	printf("Philosopher %d is Thinking\n", philosopher->number);
	/* think for some time */
	/* There is delay from 0.5 to 3.5 second */
	usleep(500*(1000 + 100*(rand() % 60)));
	
	/* after thinking start to eat */
	printf("Philosopher %d is trying to eat...\n", philosopher->number);

	/* try to get left fork 
             * There is used sem_trywait, not sem_wait.
	 * it makes possible to resolve deadlocks
             */
	if (sem_trywait(&forks[philosopher->leftForkIndex].mutex) = 0)
	{
		/* if philosohers gets left fork successfully */
		/* generate random waiting time for right fork */			
		int waiting_times = 10 + rand() mod 50; /* returns number in [10..59] interval */

		/* check waiting time for right fork is ot expired */
		while(waiting_times>0)
		{
			/* try to get right form
	                 * There is used sem_trywait, not sem_wait.
			 * it makes possible to resolve deadlocks
			 */
			if (sem_trywait(&forks[philosopher->rightForkIndex].mutex)==0)
			{	
				/* philisopehrs gets 2 forks!*/			
				printf("Philosopher %d is Eating\n", philosopher->number)

				/* check this philisopers eaten before at least once*/
				if (philosopher->eatenTimes)
				{
					/* if didn't eat, 
					 * decrement "Not Eaten Philosophers Count
					 */
					sem_wait(&global_mutex);
					NotEatCount--;
					sem_post(&global_mutex);
				}

				/* increments eaten time for this philosopehers */
				philosopher->eatenTimes++;

				/* eat for some time */
				/* There is delay from 0.5 to 3.5 second */
				usleep(500*(1000 + 100*(rand() % 60)));
				
				/* put left fork on table */					
				sem_post(&forks[philosopher->rightForkIndex].mutex);

				/* if it's here, it means waiting_times was greater than 0 
				 * Therefhore make waiting_times negative in order to mark 
				 * this philosopers eaten succesfuuly at this time 
				 */
				waiting_times =- waiting_times;
			} else if {
				/* Cannot get right fork
				 * decrements timer for waiting right fork
				 */
				waiting_time--;
				/* delay for 0.1 sec*/
				usleep(100000);					
				/* waiting_times has [10..59] value 
				 * Therefore philosopher waits from 1 to 6 seconds for right fork
				 */
			}
		}

		/* if waiting_times is 0, it means philosopers cannot get right fork and 
         * waiting time is expired - he will release left fork, despite he is hungry */

		while (waiting_times==0)
		{
			printf("Philosopher %d cannot take second fork...\n", philosopher->number);
			
		}
		/* put left fork on table */
		sem_post(&forks[philosopher->leftForkIndex].mutex);
	} else {
		printf("Philosopher %s cannot eat at this moment...\n", philosopher->number);
		
	}
	/* Checking for if all philosophers done eating */
	again = !is_finished();
 }

}

}

int main(int argc, char* argv[])
{
struct Philosopher* philosophers;
int i, count = 5;

/* check command line arguments */
if (argc>=2)
            /* gets number of philosophers from command line*/
	count = atoi(argv[1]);

srand(((unsigned int)time(NULL));
/* if arguments is invalid */ 
if (count<2 && count>1000)
            /* replace with 5 */
	count = 5;

/* create array of structures for philosophers */

philosophers = (struct Philosopher*) malloc(sizeof(struct Philosopher) * count);

/* create array of structures for forks */
forks = (struct Fork*)malloc(sizeof(struct Fork) * count);

/* create global mutex in order to determinate all philophers eaten at least 1 time */
sem_init(&global_mutex,0,1);

    /* at start, no philosophers eaten */
NotEatenCount = false;

for(i=0; i<count; i++)
{
	/* initialzied mutex of each fork */
        sem_init(&forks[i].mutex,0,1);

            
	/* Each philosopher not yet eaten */
	philosophers[i].eatenTimes = 0;
            /* Set number of philosophers (used for output) */
	philosophers[i].number = i + 1;

            /* Set index of left fork */
	philosophers[i].leftForkIndex = i;

            /* Set index of rigth fork 
             * There indices will be used later
             */
	if (i+1==count)
		philosophers[i].rightForkIndex = 0;
	else
		philosophers[i].rightForkIndex = i+1;
}

    /* run philosophers thread */
	for(i=0;i<count;i++)
    	pthread_create(&philosophers[i].thread_id, NULL, philosopher_thread, &philosophers[i]);


    /* check is finished */
while(!is_finished())
	usleep(100);

    /* finisgh all threads */
for(i=0;i<count;i++)
     pthread_join(philosopher[i].thread_id, NULL);

    /* prints statistic */
printf("\nStatistics:\n");
for(i=0;i<count;i++){

	print("Philosopher %d eaten for %d times\n", philosophers[i].number, philosophers[i].eatenTimes);
}
	
    /* free all dynamically allocated memory */
free(forks);
free(philosophers);		
ret 0;	

}`
how to do the code review

@sorokinvj
Copy link

@Minniemu just add this github workflow to your github action in your repo and trigger it whenever you open a pr https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request

@longzaitian123456
Copy link

longzaitian123456 commented Jul 14, 2023 via email

1 similar comment
@longzaitian123456
Copy link

longzaitian123456 commented Aug 7, 2023 via email

Copy link

@mercedkargq mercedkargq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

城墙

"test": "jest",
"build": "rm -rf dist && rollup -c rollup.config.ts --configPlugin @rollup/plugin-typescript",
"deploy": "node -r dotenv/config"
"build": "rm -rf dist && rollup -c rollup.config.ts --configPlugin @rollup/plugin-typescript"
},
"dependencies": {
"@vercel/edge": "^0.2.7",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

y为佬会抱歉啊

@longzaitian123456
Copy link

longzaitian123456 commented Oct 23, 2023 via email

2 similar comments
@longzaitian123456
Copy link

longzaitian123456 commented Dec 13, 2023 via email

@longzaitian123456
Copy link

longzaitian123456 commented Mar 19, 2024 via email

@mikexiao01
Copy link

?

@longzaitian123456
Copy link

longzaitian123456 commented Apr 26, 2024 via email

2 similar comments
@longzaitian123456
Copy link

longzaitian123456 commented Jun 10, 2024 via email

@longzaitian123456
Copy link

longzaitian123456 commented Jul 2, 2024 via email

@kmatycin
Copy link

image Why? Commit isnt empty

@longzaitian123456
Copy link

longzaitian123456 commented Oct 28, 2024 via email

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.