Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
6201-gh-Prune-more-large-files-from-PR-result.p...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 6201-gh-Prune-more-large-files-from-PR-result.patch of Package erlang
From 721fb711076c73945726cba8eb812ba2d4aca016 Mon Sep 17 00:00:00 2001 From: Lukas Larsson <lukas@erlang.org> Date: Mon, 5 Jun 2023 14:20:56 +0200 Subject: [PATCH] gh: Prune more large files from PR result --- .github/scripts/sync-github-prs.es | 32 +++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/.github/scripts/sync-github-prs.es b/.github/scripts/sync-github-prs.es index 6560ae5e02..05c7cd4da4 100755 --- a/.github/scripts/sync-github-prs.es +++ b/.github/scripts/sync-github-prs.es @@ -26,7 +26,11 @@ main([Repo, Target]) -> false -> cmd("rm -rf " ++ filename:join(Target,PRNo)) end - end, AllPrs); + end, AllPrs), + + purge_prs(Target). + + main([Repo, Target, PRNo]) -> handle_prs(Repo, Target, [ghapi("gh api /repos/"++Repo++"/pulls/"++PRNo)]). @@ -154,6 +158,32 @@ purge_suite(SuiteFilePath) -> end, filelib:wildcard(filename:join(SuiteDir,"*.html"))) end. +%% If we have more the 10 GB of PR data we need to remove some otherwise +%% github actions will not work them. So we purge the largest files until we +%% reach the 10 GB limit. +purge_prs(Target) -> + Files = string:split(cmd("find prs -type f -exec du -a {} \+"),"\n",all), + SortedFiles = + lists:sort(fun([A|_]=As,[B|_]=Bs) -> + try + binary_to_integer(A) >= binary_to_integer(B) + catch E:R -> + io:format("~p ~p",[As, Bs]), + false + end + end, [string:split(F,"\t") || F <- Files, F =/= <<>>]), + purge_prs(SortedFiles, Target, get_directory_size(Target)). +purge_prs(Files, Target, Size) when Size > 10_000_000_000 -> + {H,T} = lists:split(10, Files), + [file:write_file(File, "Large file truncated by github") || [_Sz, File] <- H], + purge_prs(T, Target, get_directory_size(Target)); +purge_prs(_, _, _) -> + ok. + +get_directory_size(Dir) -> + binary_to_integer(hd(string:split(cmd("du -b --max-depth=0 " ++ Dir),"\t"))). + + ghapi(CMD) -> decode(cmd(CMD)). -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor