Skip to content

Commit

Permalink
More fixups for archive cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickbkr committed May 20, 2023
1 parent 8f0f189 commit 007bdb6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
40 changes: 21 additions & 19 deletions lib/DB.rakumod
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
use Red:api<2> <refreshable>;
use Config;

unit module DB;
class SourceSpec {
# A Git SHA-1 is a length 40 hex number
subset SHA1 of Str where m:i/ [ <[0..9a..f]> ** 40 ] | latest | "" /;

has Str $.rakudo-git-url = config.projects.rakudo.repo-url;
has SHA1 $.rakudo-commit-sha = 'LATEST';
has Str $.nqp-git-url = config.projects.nqp.repo-url;
has SHA1 $.nqp-commit-sha = 'LATEST';
has Str $.moar-git-url = config.projects.moar.repo-url;
has SHA1 $.moar-commit-sha = 'LATEST';

submethod TWEAK() {
$!rakudo-commit-sha .= uc;
$!nqp-commit-sha .= uc;
$!moar-commit-sha .= uc;
}
}

module DB {

enum CIPlatformIdentifier <
AZURE
Expand Down Expand Up @@ -64,24 +82,6 @@ enum CommandStatus <
COMMAND_DONE
>;

class SourceSpec {
# A Git SHA-1 is a length 40 hex number
subset SHA1 of Str where m:i/ [ <[0..9a..f]> ** 40 ] | latest | "" /;

has Str $.rakudo-git-url = config.projects.rakudo.repo-url;
has SHA1 $.rakudo-commit-sha = 'LATEST';
has Str $.nqp-git-url = config.projects.nqp.repo-url;
has SHA1 $.nqp-commit-sha = 'LATEST';
has Str $.moar-git-url = config.projects.moar.repo-url;
has SHA1 $.moar-commit-sha = 'LATEST';

submethod TWEAK() {
$!rakudo-commit-sha .= uc;
$!nqp-commit-sha .= uc;
$!moar-commit-sha .= uc;
}
}


model CITest { ... }
model CIPlatformTestSet { ... }
Expand Down Expand Up @@ -242,3 +242,5 @@ our sub drop-schema() {
our sub create-schema() {
schema(DB::CITest, CIPlatformTestSet, DB::CITestSet, DB::GitHubPullState, DB::GitHubPR, DB::Command).create;
}

}
5 changes: 4 additions & 1 deletion lib/SourceArchiveCreator.rakumod
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use Log::Async;
use OO::Monitors;
use Log::Async;
use DB;
Expand Down Expand Up @@ -230,9 +231,11 @@ method create-archive(DB::CITestSet $test-set) {
method clean-old-archives() {
for DB::CITestSet.^all.grep({
$_.source-archive-exists == True &&
$_.finished-at.defined &&
$_.finished-at < DateTime.now - config.source-archive-retain-days * 24 * 60 * 60
}) -> $test-set {
my $filepath-base = self!get-path-for-name($id, :create-dirs).relative($!work-dir);
trace "Removing archives for " ~ $test-set.id ~ " finished at " ~ $test-set.finished-at;
my $filepath-base = self!get-path-for-name($test-set.source-archive-id, :create-dirs).relative($!work-dir);

run("rm", $filepath-base ~ ".tar.xz", :cwd($!work-dir), :merge).so;
run("rm", $filepath-base ~ "-moar.tar.xz", :cwd($!work-dir), :merge).so;
Expand Down

0 comments on commit 007bdb6

Please sign in to comment.