ci: rewrite deploy scripts with python3#7046
Conversation
hjpalpha
left a comment
There was a problem hiding this comment.
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 |
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.
| 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.
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.
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.
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?