ci: format
This commit is contained in:
parent
9272a9660e
commit
574e6b3a79
7 changed files with 196 additions and 907 deletions
41
flake.nix
41
flake.nix
|
|
@ -26,6 +26,20 @@
|
|||
ps.requests
|
||||
]);
|
||||
|
||||
mkDevPythonEnv =
|
||||
pkgs:
|
||||
pkgs.python312.withPackages (ps: [
|
||||
ps.backoff
|
||||
ps.beautifulsoup4
|
||||
ps.curl-cffi
|
||||
ps.httpx
|
||||
ps.ndjson
|
||||
ps.pydantic
|
||||
ps.requests
|
||||
ps.pytest
|
||||
ps.pytest-mock
|
||||
]);
|
||||
|
||||
mkSubmitEnv =
|
||||
pkgs:
|
||||
pkgs.buildFHSEnv {
|
||||
|
|
@ -44,19 +58,24 @@
|
|||
glib
|
||||
gtk3
|
||||
libdrm
|
||||
libGL
|
||||
libxkbcommon
|
||||
mesa
|
||||
libGL
|
||||
nspr
|
||||
nss
|
||||
pango
|
||||
xorg.libX11
|
||||
xorg.libXcomposite
|
||||
xorg.libXdamage
|
||||
xorg.libXext
|
||||
xorg.libXfixes
|
||||
xorg.libXrandr
|
||||
xorg.libxcb
|
||||
libx11
|
||||
libxcomposite
|
||||
libxdamage
|
||||
libxext
|
||||
libxfixes
|
||||
libxrandr
|
||||
libxcb
|
||||
at-spi2-core
|
||||
expat
|
||||
libgbm
|
||||
systemdLibs
|
||||
zlib
|
||||
];
|
||||
runScript = "${pkgs.uv}/bin/uv";
|
||||
};
|
||||
|
|
@ -100,15 +119,19 @@
|
|||
submitEnv = mkSubmitEnv (pkgsFor system);
|
||||
});
|
||||
|
||||
formatter = eachSystem (system: (pkgsFor system).nixfmt-tree);
|
||||
|
||||
devShells = eachSystem (system: {
|
||||
default = (pkgsFor system).mkShell {
|
||||
packages = with (pkgsFor system); [
|
||||
uv
|
||||
python312
|
||||
(mkDevPythonEnv (pkgsFor system))
|
||||
prettier
|
||||
ruff
|
||||
stylua
|
||||
selene
|
||||
lua-language-server
|
||||
ty
|
||||
];
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -278,7 +278,16 @@ function M.scrape_all_tests(platform, contest_id, callback)
|
|||
})
|
||||
end
|
||||
|
||||
function M.submit(platform, contest_id, problem_id, language, source_code, credentials, on_status, callback)
|
||||
function M.submit(
|
||||
platform,
|
||||
contest_id,
|
||||
problem_id,
|
||||
language,
|
||||
source_code,
|
||||
credentials,
|
||||
on_status,
|
||||
callback
|
||||
)
|
||||
local done = false
|
||||
run_scraper(platform, 'submit', { contest_id, problem_id, language }, {
|
||||
ndjson = true,
|
||||
|
|
@ -286,15 +295,22 @@ function M.submit(platform, contest_id, problem_id, language, source_code, crede
|
|||
env_extra = { CP_CREDENTIALS = vim.json.encode(credentials) },
|
||||
on_event = function(ev)
|
||||
if ev.status ~= nil then
|
||||
if type(on_status) == 'function' then on_status(ev.status) end
|
||||
if type(on_status) == 'function' then
|
||||
on_status(ev.status)
|
||||
end
|
||||
elseif ev.success ~= nil then
|
||||
done = true
|
||||
if type(callback) == 'function' then callback(ev) end
|
||||
if type(callback) == 'function' then
|
||||
callback(ev)
|
||||
end
|
||||
end
|
||||
end,
|
||||
on_exit = function(proc)
|
||||
if not done and type(callback) == 'function' then
|
||||
callback({ success = false, error = 'submit process exited (code=' .. tostring(proc.code) .. ')' })
|
||||
callback({
|
||||
success = false,
|
||||
error = 'submit process exited (code=' .. tostring(proc.code) .. ')',
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ requires-python = ">=3.11"
|
|||
dependencies = [
|
||||
"backoff>=2.2.1",
|
||||
"beautifulsoup4>=4.13.5",
|
||||
"camoufox[geoip]",
|
||||
"scrapling[fetchers]>=0.4",
|
||||
"curl-cffi>=0.13.0",
|
||||
"httpx>=0.28.1",
|
||||
"ndjson>=0.3.1",
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ def _extract_samples(html: str) -> list[TestCase]:
|
|||
return cases
|
||||
|
||||
|
||||
_TURNSTILE_JS = '() => { const el = document.querySelector(\'[name="cf-turnstile-response"]\'); return el && el.value.length > 0; }'
|
||||
_TURNSTILE_JS = "() => { const el = document.querySelector('[name=\"cf-turnstile-response\"]'); return el && el.value.length > 0; }"
|
||||
|
||||
|
||||
def _solve_turnstile(page) -> None:
|
||||
|
|
@ -358,9 +358,7 @@ def _submit_headless(
|
|||
finally:
|
||||
os.unlink(tmp_path)
|
||||
page.locator('button[type="submit"]').click()
|
||||
page.wait_for_url(
|
||||
lambda url: "/submissions/me" in url, timeout=60000
|
||||
)
|
||||
page.wait_for_url(lambda url: "/submissions/me" in url, timeout=60000)
|
||||
except Exception as e:
|
||||
submit_error = str(e)
|
||||
|
||||
|
|
@ -561,7 +559,12 @@ class AtcoderScraper(BaseScraper):
|
|||
credentials: dict[str, str],
|
||||
) -> SubmitResult:
|
||||
return await asyncio.to_thread(
|
||||
_submit_headless, contest_id, problem_id, source_code, language_id, credentials
|
||||
_submit_headless,
|
||||
contest_id,
|
||||
problem_id,
|
||||
source_code,
|
||||
language_id,
|
||||
credentials,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
LANGUAGE_IDS = {
|
||||
"atcoder": {
|
||||
"cpp": "5028",
|
||||
"python": "5078",
|
||||
"cpp": "6017",
|
||||
"python": "6082",
|
||||
},
|
||||
"codeforces": {
|
||||
"cpp": "89",
|
||||
|
|
|
|||
|
|
@ -4,8 +4,10 @@ set -eu
|
|||
nix develop --command stylua --check .
|
||||
git ls-files '*.lua' | xargs nix develop --command selene --display-style quiet
|
||||
nix develop --command prettier --check .
|
||||
nix fmt
|
||||
git diff --exit-code -- '*.nix'
|
||||
nix develop --command lua-language-server --check . --checklevel=Warning
|
||||
nix develop --command uvx ruff format --check .
|
||||
nix develop --command uvx ruff check .
|
||||
nix develop --command uvx ty check .
|
||||
nix develop --command uv run pytest tests/ -v
|
||||
nix develop --command ruff format --check .
|
||||
nix develop --command ruff check .
|
||||
nix develop --command ty check .
|
||||
nix develop --command python -m pytest tests/ -v
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue