In this PR, we added a CI check process.
When there is a push or pull request, it will verify whether the events are valid, such as checking for syntax errors, incorrect trigger dates, and more.
In this PR, we added a CI check process.
When there is a push or pull request, it will verify whether the events are valid, such as checking for syntax errors, incorrect trigger dates, and more.
{"event":"this should be place in static","triggerDate":{"month":"6","date":"21"},"status_index":"0","goodFortunes":{"l_1_event":"123","l_1_desc":"123","l_2_event":"","l_2_desc":""},"badFortunes":{"r_1_event":"","r_1_desc":"","r_2_event":"","r_2_desc":""}}`triggerDate`missing`year`.thisevent`thisshouldbeplaceinstatic`shouldbeplacedin`static_special.json`.{"event":"this should be place in cyclical","triggerDate":{"month":"5","week":"2","weekday":"1"},"status_index":"0","goodFortunes":{"l_1_event":"123","l_1_desc":"123","l_2_event":"","l_2_desc":""},"badFortunes":{"r_1_event":"","r_1_desc":"","r_2_event":"","r_2_desc":""}}`triggerDate`missing`year`.`triggerDate`missing`date`.thisevent`thisshouldbeplaceincyclical`shouldbeplacedin`cyclical_special.json`.{"event":"incorrect year, month","triggerDate":{"year":"-1","month":"123","date":"2"},"status_index":"0","goodFortunes":{"l_1_event":"123","l_1_desc":"123","l_2_event":"","l_2_desc":""},"badFortunes":{"r_1_event":"","r_1_desc":"","r_2_event":"","r_2_desc":""}}`triggerDate.year`shouldbebetween1and9999`triggerDate.month`shouldbebetween1and12{"event":"incorrect date","triggerDate":{"year":"2021","month":"2","date":"29"},"status_index":"0","goodFortunes":{"l_1_event":"123","l_1_desc":"123","l_2_event":"","l_2_desc":""},"badFortunes":{"r_1_event":"","r_1_desc":"","r_2_event":"","r_2_desc":""}}`triggerDate.date`shouldbebetween1and28{"event":"Mukden incident","triggerDate":{"year":"1931","month":"9","date":"18"},"status_index":"0","goodFortunes":{"l_1_event":"123","l_1_desc":"123","l_2_event":"","l_2_desc":""},"badFortunes":{"r_1_event":"","r_1_desc":"","r_2_event":"","r_2_desc":""}}Thedate`1931/9/18`of`Mukdenincident`isrepeated.
This is the current error message.
The checker will list all errors as much as possible.
```json
{
"event": "this should be place in static",
"triggerDate": {
"month": "6",
"date": "21"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "123",
"l_1_desc": "123",
"l_2_event": "",
"l_2_desc": ""
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
}
`triggerDate` missing `year`.
this event `this should be place in static` should be placed in `static_special.json`.
{
"event": "this should be place in cyclical",
"triggerDate": {
"month": "5",
"week": "2",
"weekday": "1"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "123",
"l_1_desc": "123",
"l_2_event": "",
"l_2_desc": ""
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
}
`triggerDate` missing `year`.
`triggerDate` missing `date`.
this event `this should be place in cyclical` should be placed in `cyclical_special.json`.
{
"event": "incorrect year, month",
"triggerDate": {
"year": "-1",
"month": "123",
"date": "2"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "123",
"l_1_desc": "123",
"l_2_event": "",
"l_2_desc": ""
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
}
`triggerDate.year` should be between 1 and 9999
`triggerDate.month` should be between 1 and 12
{
"event": "incorrect date",
"triggerDate": {
"year": "2021",
"month": "2",
"date": "29"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "123",
"l_1_desc": "123",
"l_2_event": "",
"l_2_desc": ""
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
}
`triggerDate.date` should be between 1 and 28
{
"event": "Mukden incident",
"triggerDate": {
"year": "1931",
"month": "9",
"date": "18"
},
"status_index": "0",
"goodFortunes": {
"l_1_event": "123",
"l_1_desc": "123",
"l_2_event": "",
"l_2_desc": ""
},
"badFortunes": {
"r_1_event": "",
"r_1_desc": "",
"r_2_event": "",
"r_2_desc": ""
}
}
The date `1931/9/18` of `Mukden incident` is repeated.
```
This is the current error message.
The checker will list all errors as much as possible.
OK.
[test_custom.json](https://github.com/user-attachments/files/18632730/test_custom.json)
[test_cyclical.json](https://github.com/user-attachments/files/18632732/test_cyclical.json)
[test_static.json](https://github.com/user-attachments/files/18632733/test_static.json)
[test_structure.json](https://github.com/user-attachments/files/18632734/test_structure.json)
There are some test files.
I once left a message here asking you to put all scripts in the scripts/ folder but it seems to be gone. Anyway, I would like to ask you to make this change.
I once left a message here asking you to put all scripts in the `scripts/` folder but it seems to be gone. Anyway, I would like to ask you to make this change.
I originally just wanted to ask you to move the CI script there. And after all, the two files originally in dev/ are outdated. But you have already moved them there. So now we have to consider whether to deal with the two files originally in dev/ in the next PR (then you need to reverse) or just put them in scripts or even delete them directly.
I originally just wanted to ask you to move the CI script there. And after all, the two files originally in `dev/` are outdated. But you have already moved them there. So now we have to consider whether to deal with the two files originally in dev/ in the next PR (then you need to reverse) or just put them in scripts or even delete them directly.
Overall, this is a well-structured addition that will help maintain data consistency. Here's my review:
Strong Points:
Well-organized code with proper typing, enums, and argument parsing
Comprehensive validation for different date types (Custom, Static, Cyclical)
Good error handling for file operations and JSON parsing
Thorough field checking with type validation
Clear error messaging system
Proper handling of leap years and date validation
Duplicate checking for event names and dates
Suggested Improvements:
Code Structure:
Add docstrings to main functions for better documentation
Add type hints for function return values
Error Handling:
Replace print statements with proper logging
Consider creating a custom Exception class for validation errors
Add input validation for the JSON file path
Testing & Maintainability:
Would be great to add unit tests for the validation logic
Consider making the constants configurable via command line arguments
The code is good to merge after addressing the docstring and logging improvements. The other suggestions can be handled in future PRs.
Let me know if you'd like me to elaborate on any of these points.
Overall, this is a well-structured addition that will help maintain data consistency. Here's my review:
Strong Points:
- Well-organized code with proper typing, enums, and argument parsing
- Comprehensive validation for different date types (Custom, Static, Cyclical)
- Good error handling for file operations and JSON parsing
- Thorough field checking with type validation
- Clear error messaging system
- Proper handling of leap years and date validation
- Duplicate checking for event names and dates
Suggested Improvements:
1. Code Structure:
- Add docstrings to main functions for better documentation
- Add type hints for function return values
2. Error Handling:
- Replace print statements with proper logging
- Consider creating a custom Exception class for validation errors
- Add input validation for the JSON file path
3. Testing & Maintainability:
- Would be great to add unit tests for the validation logic
- Consider making the constants configurable via command line arguments
The code is good to merge after addressing the docstring and logging improvements. The other suggestions can be handled in future PRs.
Let me know if you'd like me to elaborate on any of these points.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
In this PR, we added a CI check process.
When there is a push or pull request, it will verify whether the events are valid, such as checking for syntax errors, incorrect trigger dates, and more.
Have you tested the workflow?
The workflow ran successfully
https://github.com/LifeAdventurer/generators/actions/runs/12975393011/job/36186418331?pr=50
I mean have you tested various wrong formats and will he be able to debug it?
Ohhhh
This is the current error message.
The checker will list all errors as much as possible.
@LifeAdventurer
Should I write a new CI for testing the event checker?
You only need to ensure that the event checker works. There's no need for a CI to repeatedly verify a static event checker.
OK.
test_custom.json
test_cyclical.json
test_static.json
test_structure.json
There are some test files.
Do you want to merge this pr?
I once left a message here asking you to put all scripts in the
scripts/folder but it seems to be gone. Anyway, I would like to ask you to make this change.OK.
No problem.
I'll do it right now.
Is this okay now?
I originally just wanted to ask you to move the CI script there. And after all, the two files originally in
dev/are outdated. But you have already moved them there. So now we have to consider whether to deal with the two files originally in dev/ in the next PR (then you need to reverse) or just put them in scripts or even delete them directly.I think we can delete it in this PR first and open another PR related to probability analysis to handle this.
Please commit these resolve request changes (including deleting the files) after I review your pull request.
@@ -0,0 +1,35 @@name: Check special eventsUse checkout@v4
@@ -0,0 +1,35 @@name: Check special eventson:Try to use
paths, so we only need to run this workflow when files underfortune_generator/json/are changed.Overall, this is a well-structured addition that will help maintain data consistency. Here's my review:
Strong Points:
Suggested Improvements:
Code Structure:
Error Handling:
Testing & Maintainability:
The code is good to merge after addressing the docstring and logging improvements. The other suggestions can be handled in future PRs.
Let me know if you'd like me to elaborate on any of these points.
Remove this file.
Remove this file.
Squash your commits before I merge.
OK