From 007bdb6aa5a20f5461abf7d01c32f19e4acde300 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20B=C3=B6ker?= Date: Sat, 20 May 2023 18:59:46 +0000 Subject: [PATCH] More fixups for archive cleanup --- lib/DB.rakumod | 40 +++++++++++++++++--------------- lib/SourceArchiveCreator.rakumod | 5 +++- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/lib/DB.rakumod b/lib/DB.rakumod index d1052e7..6b6202b 100644 --- a/lib/DB.rakumod +++ b/lib/DB.rakumod @@ -1,7 +1,25 @@ use Red:api<2> ; 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 @@ -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 { ... } @@ -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; } + +} diff --git a/lib/SourceArchiveCreator.rakumod b/lib/SourceArchiveCreator.rakumod index 8597de4..ffde81b 100644 --- a/lib/SourceArchiveCreator.rakumod +++ b/lib/SourceArchiveCreator.rakumod @@ -1,3 +1,4 @@ +use Log::Async; use OO::Monitors; use Log::Async; use DB; @@ -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;