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

fix: add validation step to check if the event date is in the future. #751

Merged

Conversation

princerajpoot20
Copy link
Member

Description

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

Comment on lines 95 to 104
# New step to validate if the event is in the future
- name: Validate if the event is in the future
uses: actions/github-script@v6
with:
script: |
const eventDate = new Date('${{ inputs.date }}T${{ inputs.time }}:00Z');
const currentDate = new Date();
if (eventDate <= currentDate) {
core.setFailed('The event cannot be scheduled in the past.');
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# New step to validate if the event is in the future
- name: Validate if the event is in the future
uses: actions/github-script@v6
with:
script: |
const eventDate = new Date('${{ inputs.date }}T${{ inputs.time }}:00Z');
const currentDate = new Date();
if (eventDate <= currentDate) {
core.setFailed('The event cannot be scheduled in the past.');
}
// validate if the event is in the future
const eventDate = new Date('${{ inputs.date }}T${{ inputs.time }}:00Z');
const currentDate = new Date();
if (eventDate <= currentDate) {
core.setFailed('The event cannot be scheduled in the past.');
}

Copy link
Member

Choose a reason for hiding this comment

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

we can add this script to the previous step :)

@princerajpoot20
Copy link
Member Author

princerajpoot20 commented Jun 16, 2023

@KhudaDad414 Thank you for your review. I have made the changes. 🙂

Copy link
Member

@KhudaDad414 KhudaDad414 left a comment

Choose a reason for hiding this comment

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

LGTM! thanks @princerajpoot20 🙏

@AceTheCreator
Copy link
Member

@KhudaDad414 Thank you for your review. I have made the changes. 🙂

@princerajpoot20 did you test this locally? can you show proof that you did?

@princerajpoot20
Copy link
Member Author

@AceTheCreator I have tried testing it, but faced some difficulty in setting up locally. Sorry for making a PR without testing it locally.

@KhudaDad414
Copy link
Member

KhudaDad414 commented Jun 16, 2023

@princerajpoot20 it's hard to test actions locally. I would recommend testing workflows in your fork. it's much easier.
@AceTheCreator I have tested it and it works fine:
https://github.com/KhudaDad414/community/actions/runs/5288936387/jobs/9571256252
https://github.com/KhudaDad414/community/actions/runs/5288934316/jobs/9571251686

@AceTheCreator
Copy link
Member

@AceTheCreator I have tried testing it, but faced some difficulty in setting up locally. Sorry for making a PR without testing it locally.

Not a problem mate 🙂

@AceTheCreator
Copy link
Member

@princerajpoot20 it's hard to test actions locally. I would recommend testing workflows in your fork. it's much easier. @AceTheCreator I have tested it and it works fine: https://github.com/KhudaDad414/community/actions/runs/5288936387/jobs/9571256252 https://github.com/KhudaDad414/community/actions/runs/5288934316/jobs/9571251686

Thanks for validating it 🙂

@npiyush97
Copy link

@KhudaDad414 Thank you for your review. I have made the changes. slightly_smiling_face

@princerajpoot20 did you test this locally? can you show proof that you did?

its working this how you wanted to be ?

@KhudaDad414 Thank you for your review. I have made the changes. slightly_smiling_face

@princerajpoot20 did you test this locally? can you show proof that you did?

it is working this how you want it to be?
Screenshot from 2023-06-16 19-36-41

@princerajpoot20
Copy link
Member Author

princerajpoot20 commented Jun 16, 2023

@princerajpoot20 it's hard to test actions locally. I would recommend testing workflows in your fork. it's much easier. @AceTheCreator I have tested it and it works fine: https://github.com/KhudaDad414/community/actions/runs/5288936387/jobs/9571256252 https://github.com/KhudaDad414/community/actions/runs/5288934316/jobs/9571251686

@KhudaDad414 Ok, I will try testing in my fork and thanks for validating.🙂

@KhudaDad414
Copy link
Member

KhudaDad414 commented Jun 26, 2023

@fmvilas it would be a quick review. 🙇

Comment on lines 98 to 99
if (eventDate <= currentDate) {
core.setFailed('The event cannot be scheduled in the past.');
Copy link
Member

Choose a reason for hiding this comment

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

please make it more detailed, I mean the error message:

  • specify what was the event date specified by the user
  • specify what is the current time

when user makes a mistake, they make it unintentionally so definitely good to show them in logs what went wrong

@princerajpoot20
Copy link
Member Author

@derberg I agree with your point 🙂. I have made the changes.

Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

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

LGTM, well done 👏🏼 thanks!!!

@derberg
Copy link
Member

derberg commented Jun 27, 2023

@KhudaDad414 since you reviewed it before, please have another look and merge when ready

@KhudaDad414
Copy link
Member

/rtm

@KhudaDad414
Copy link
Member

thanks @princerajpoot20 🙇

@asyncapi-bot asyncapi-bot merged commit 7c9094a into asyncapi:master Jun 27, 2023
8 checks passed
@derberg
Copy link
Member

derberg commented Jun 27, 2023

@allcontributorsbot please add @princerajpoot20 for code

@derberg
Copy link
Member

derberg commented Jun 27, 2023

@allcontributors please add @princerajpoot20 for code

@allcontributors
Copy link
Contributor

@derberg

I've put up a pull request to add @princerajpoot20! 🎉

@princerajpoot20
Copy link
Member Author

@derberg @KhudaDad414 Thank you 🙇

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

Successfully merging this pull request may close these issues.

As A user, the CI should prevent me schedule an adhoc meeting in the past
6 participants