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

PHP to Python plus tests and stuff #51

Merged
merged 5 commits into from
Oct 23, 2024

Conversation

fabianegli
Copy link
Contributor

This PR changes the behaviour:

  • ports php code to python -> no more PHP code, one language left
  • adds test for the json to txt and md conversion
  • removes the action for the php script - everything is now updated at once with the Python script
  • adds the action trigger push to the remaining action
  • adds some Python specific files and folders to .gitignore

and some file contents slightly:

  • removes the space at end of some lines in md table
  • adds a newline at end of robots.txt file

The python files have been formatted with black.

Copy link
Contributor

@glyn glyn left a comment

Choose a reason for hiding this comment

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

Thanks for this. I like the idea of centralising on a single coding language. We don't know if anyone will maintain the code, but at least we'll only need Python skills, which are more common than PHP skills. Also the addition of tests is really appreciated.

I've suggested various improvements. You may regard some of the larger ones as out of scope for this PR, in which case, please log an issue for each of the ones you choose not to address so these can be worked on in future. Alternatively, if you don't mind large PRs, please address all the comments here - your choice.

.github/workflows/daily_update.yml Outdated Show resolved Hide resolved
code/tests.py Show resolved Hide resolved
code/dark_visitors.py Outdated Show resolved Hide resolved
.github/workflows/daily_update.yml Outdated Show resolved Hide resolved
code/test_files/robots.json Show resolved Hide resolved
@glyn
Copy link
Contributor

glyn commented Oct 19, 2024

@cdransf PTAL as this is a substantial PR.

@glyn glyn requested a review from cdransf October 19, 2024 14:46
@fabianegli
Copy link
Contributor Author

Thanks for the review @glyn

Comment on lines +19 to +20
git config --global user.name "dark-visitors"
git config --global user.email "[email protected]"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why are these configs made here? And should they be changed for the conversion step?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know (x2).

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, the purpose of these configs is to make the changes produced by the dark visitors website look as if they were produced by a dark-visitors user. I'm not sure this is entirely necessary. The commit message should be sufficient on its own.

@glyn
Copy link
Contributor

glyn commented Oct 20, 2024

@fabianegli Thanks for the rework. A couple of remaining items for this PR:

  1. rationalise the git config user name/email so that updates are not wrongly attributed to dark-visitors. (I haven't worked through to know whether this has already been done, but please take a look.)
  2. the tests need to be run each time an action is triggered. Have I missed where that happens?

@glyn
Copy link
Contributor

glyn commented Oct 21, 2024

@fabianegli To expand on remaining item 1: please make sure that updates due to dark visitors changes have an appropriate commit message (and user/email if you decide to keep that) and that updates due to merging a local change also have an appropriate commit message (and user/email). In other words, we need to make sure we differentiate between dark visitors and local changes, especially in the situation where a local change is merged and, coincidentally, dark visitors has changed. If we are not careful, the current code will pick up both changes and put them in a single commit and give that commit an incorrect commit message (and user/email).

It may be necessary to step back from the approach in the current PR and keep the processing of dark visitors separate from the merging of local changes. It should still be possible to (a) replace the PHP by Python and (b) introduce tests of the Python functions.

Hope that helps make the requirements clearer.

@fabianegli fabianegli marked this pull request as draft October 21, 2024 09:33
@newbold newbold marked this pull request as ready for review October 23, 2024 01:31
@newbold
Copy link
Contributor

newbold commented Oct 23, 2024

Just gonna “Leeroy Jenkins” this and we’ll see what happens!

@newbold newbold merged commit a66b168 into ai-robots-txt:main Oct 23, 2024
@newbold
Copy link
Contributor

newbold commented Oct 23, 2024

It looks like the action ran without any issue. Not sure who can see this, but here’s the run that was triggered via the merge: https://github.com/ai-robots-txt/ai.robots.txt/actions/runs/11471373718

No changes to robots.json or robots.txt, though, but I can’t tell if that’s because there truly aren’t any new user agents to add or if something else happened.

@glyn
Copy link
Contributor

glyn commented Oct 23, 2024

Just gonna “Leeroy Jenkins” this and we’ll see what happens!

Will all changes now be attributed to dark visitors?

@fabianegli
Copy link
Contributor Author

I think there was indeed a change in the attribution logic. PR #58 reverts that.

@fabianegli
Copy link
Contributor Author

fabianegli commented Nov 26, 2024

I am sorry it took me so long to come back to this and indeed this probably shouldn't have been merged in this way. FYI that's why I marked it to be a draft before I had to turn my attention to other things for a while.

@fabianegli fabianegli mentioned this pull request Nov 26, 2024
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.

4 participants