Chore(Fortune): add pre-commit to check special events #55

Merged
tobiichi3227 merged 3 commits from ci/event-check-pre-commit into main 2025-02-20 17:00:49 +00:00

36
.pre-commit-config.yaml Normal file
View File

@@ -0,0 +1,36 @@
# See https://pre-commit.com for more information
lifeadventurer commented 2025-02-17 12:52:12 +00:00 (Migrated from github.com)
Review

Use the latest version v5.0.0

Use the latest version v5.0.0
lifeadventurer commented 2025-02-17 15:20:05 +00:00 (Migrated from github.com)
Review

I noticed you're using a shell script wrapper to run the Python scripts. Since check-events.py is a Python program, I'd recommend calling it directly rather than through a shell script wrapper.
This approach would be more Windows-friendly, as shell scripts can be problematic on Windows environments. Making this change will ensure developers across all platforms can use the pre-commit hooks without issue.

I noticed you're using a shell script wrapper to run the Python scripts. Since `check-events.py` is a Python program, I'd recommend calling it directly rather than through a shell script wrapper. This approach would be more Windows-friendly, as shell scripts can be problematic on Windows environments. Making this change will ensure developers across all platforms can use the pre-commit hooks without issue.
tobiichi3227 commented 2025-02-18 02:45:36 +00:00 (Migrated from github.com)
Review

I switched to using a Python script because passing parameters directly is difficult.

I switched to using a Python script because passing parameters directly is difficult.
lifeadventurer commented 2025-02-18 06:36:11 +00:00 (Migrated from github.com)
Review

Isn't this working?
entry: python3 scripts/check-events.py fortune_generator/json/custom_special.json custom

Isn't this working? `entry: python3 scripts/check-events.py fortune_generator/json/custom_special.json custom`
tobiichi3227 commented 2025-02-18 06:49:14 +00:00 (Migrated from github.com)
Review

Oh.
It works.
But I think this way can check three files and list all errors.
Instead of checking after each modification.

Oh. It works. But I think this way can check three files and list all errors. Instead of checking after each modification.
lifeadventurer commented 2025-02-18 06:53:37 +00:00 (Migrated from github.com)
Review

What do you mean by "checking after each modification"?

What do you mean by "checking after each modification"?
tobiichi3227 commented 2025-02-18 06:57:02 +00:00 (Migrated from github.com)
Review

Modify, commit, and then pre-commit check.

Modify, commit, and then pre-commit check.
lifeadventurer commented 2025-02-18 07:01:12 +00:00 (Migrated from github.com)
Review

Why do you need to check after each modification?

Why do you need to check after each modification?
lifeadventurer commented 2025-02-18 07:04:59 +00:00 (Migrated from github.com)
Review
entry: |
      python3 scripts/check-events.py fortune_generator/json/custom_special.json custom &&
      python3 scripts/check-events.py fortune_generator/json/cyclical_special.json cyclical &&
      python3 scripts/check-events.py fortune_generator/json/static_special.json static
``` entry: | python3 scripts/check-events.py fortune_generator/json/custom_special.json custom && python3 scripts/check-events.py fortune_generator/json/cyclical_special.json cyclical && python3 scripts/check-events.py fortune_generator/json/static_special.json static ```
tobiichi3227 commented 2025-02-18 07:13:15 +00:00 (Migrated from github.com)
Review

It doesn't work.

It doesn't work.
tobiichi3227 commented 2025-02-18 07:14:07 +00:00 (Migrated from github.com)
Review
bash -c '
  python3 scripts/check-events.py fortune_generator/json/custom_special.json custom &&
  python3 scripts/check-events.py fortune_generator/json/cyclical_special.json cyclical &&
  python3 scripts/check-events.py fortune_generator/json/static_special.json static
'

This can work.
However, it's not possible to check all three files at the same time.

```bash bash -c ' python3 scripts/check-events.py fortune_generator/json/custom_special.json custom && python3 scripts/check-events.py fortune_generator/json/cyclical_special.json cyclical && python3 scripts/check-events.py fortune_generator/json/static_special.json static ' ``` This can work. However, it's not possible to check all three files at the same time.
lifeadventurer commented 2025-02-18 07:16:37 +00:00 (Migrated from github.com)
Review

Set language: system instead of language: python because we're utilizing shell functionality rather than running a standalone Python script.

Set `language: system` instead of `language: python` because we're utilizing shell functionality rather than running a standalone Python script.
lifeadventurer commented 2025-02-18 07:17:10 +00:00 (Migrated from github.com)
Review
bash -c '
  python3 scripts/check-events.py fortune_generator/json/custom_special.json custom &&
  python3 scripts/check-events.py fortune_generator/json/cyclical_special.json cyclical &&
  python3 scripts/check-events.py fortune_generator/json/static_special.json static
'

This can work. However, it's not possible to check all three files at the same time.

We have concluded that we should not use bash.

> ```shell > bash -c ' > python3 scripts/check-events.py fortune_generator/json/custom_special.json custom && > python3 scripts/check-events.py fortune_generator/json/cyclical_special.json cyclical && > python3 scripts/check-events.py fortune_generator/json/static_special.json static > ' > ``` > > This can work. However, it's not possible to check all three files at the same time. We have concluded that we should not use bash.
tobiichi3227 commented 2025-02-18 07:18:41 +00:00 (Migrated from github.com)
Review

Set language: system instead of language: python because we're utilizing shell functionality rather than running a standalone Python script.

Yes.
I already setted

> Set `language: system` instead of `language: python` because we're utilizing shell functionality rather than running a standalone Python script. Yes. I already setted
tobiichi3227 commented 2025-02-18 07:19:19 +00:00 (Migrated from github.com)
Review
bash -c '
  python3 scripts/check-events.py fortune_generator/json/custom_special.json custom &&
  python3 scripts/check-events.py fortune_generator/json/cyclical_special.json cyclical &&
  python3 scripts/check-events.py fortune_generator/json/static_special.json static
'

This can work. However, it's not possible to check all three files at the same time.

We have concluded that we should not use bash.

Yes

> > ```shell > > bash -c ' > > python3 scripts/check-events.py fortune_generator/json/custom_special.json custom && > > python3 scripts/check-events.py fortune_generator/json/cyclical_special.json cyclical && > > python3 scripts/check-events.py fortune_generator/json/static_special.json static > > ' > > ``` > > > > > > > > > > > > > > > > > > > > > > > > This can work. However, it's not possible to check all three files at the same time. > > We have concluded that we should not use bash. Yes
lifeadventurer commented 2025-02-18 07:23:08 +00:00 (Migrated from github.com)
Review

Set language: system instead of language: python because we're utilizing shell functionality rather than running a standalone Python script.

Yes. I already setted

What is the problem of it not working?

> > Set `language: system` instead of `language: python` because we're utilizing shell functionality rather than running a standalone Python script. > > Yes. I already setted What is the problem of it not working?
tobiichi3227 commented 2025-02-18 07:56:21 +00:00 (Migrated from github.com)
Review

Changing to language: system allows it to work properly.

Changing to language: system allows it to work properly.
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: local
hooks:
- id: check-cyclical-event
name: check-cyclical-event
entry: python3 scripts/check-events.py fortune_generator/json/cyclical_special.json cyclical
language: python
files: fortune_generator/json/cyclical_special.json
types: [json]
pass_filenames: false
- id: check-custom-event
name: check-custom-event
entry: python3 scripts/check-events.py fortune_generator/json/custom_special.json custom
language: python
files: fortune_generator/json/custom_special.json
types: [json]
pass_filenames: false
- id: check-static-event
name: check-static-event
entry: python3 scripts/check-events.py fortune_generator/json/static_special.json static
language: python
files: fortune_generator/json/static_special.json
types: [json]
pass_filenames: false