-
Notifications
You must be signed in to change notification settings - Fork 101
ci: rewrite deploy scripts with python3 #7046
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
base: main
Are you sure you want to change the base?
Conversation
hjpalpha
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we should test this on a fork first ;)
on first glance seems reasonable
update: https://github.com/ElectricalBoy/Lua-Modules/actions/runs/21696696866 |
36024bb to
882b225
Compare
|
Would it be worth using pywikibot directly? |
imo too much overhead and would likely increase runtime even more |
FO-nTTaX
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we feel the need to have a linter and style checker for the deploy scripts? I'm not aware of such things for bash, but in the python world tools like Flake8 exist
nowadays people use https://astral.sh/ruff instead |
I didn't pass the scripts through a linter but everything is style checked with psf/black already |
882b225 to
1f15076
Compare
8844902 to
845b2b3
Compare
5a0e092 to
6e7bc44
Compare
.github/workflows/pythoncheck.yml
Outdated
| @@ -0,0 +1,19 @@ | |||
| name: Python Code Style | |||
|
|
|||
| on: [pull_request, workflow_dispatch] | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| on: [pull_request, workflow_dispatch] | |
| on: | |
| pull_request: | |
| paths: | |
| - '**.py' | |
| workflow_dispatch: |
Not sure if we even need the dispatch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we even need the dispatch?
it's there only because luacheck workflow has it
and I'm not opposed to removing dispatch trigger from both
| token = get_token(wiki) | ||
| with requests.Session() as session: | ||
| session.cookies = read_cookie_jar(wiki) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also move this into a dedicated context manager to avoid repetition of cookie reading, but is also a bit overkill
@contextmanager
def authenticated_session(wiki: str):
token = get_token(wiki)
with requests.Session() as session:
session.headers.update(HEADERS)
session.cookies = read_cookie_jar(wiki)
yield session, token| token = get_token(wiki) | |
| with requests.Session() as session: | |
| session.cookies = read_cookie_jar(wiki) | |
| with authenticated_session(wiki) as session, token: |
In case we'd then also move the opening of this context manager to be in each main function, and then passed everywhere, we could also get rid of the cookie jar as the session will persist the cookies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I think it's a bit overkill
Co-authored-by: SyntacticSalt <mail@mbergen.de>
Fair enough, I'm not super up top date with the wider python ecosystem, flake8 is what I use for the LP Discord Bot, hence that suggestion. I'm not married to either tool, or to how far we'd want to go with implementing style checking and/or linting for this, I just wanted to start the discussion if this was relevant. |
Summary
Previous discussion: https://discord.com/channels/321003439431745537/321641940879802368/1468407645391163432
This PR rewrites shellscript versions of current deploy scripts with Python.
How did you test this change?