Repository navigation
indexing context: make it easier to log and report on indexing status #405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+1,235
−889
Merged
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
58bf722
package indexing: try to avoid partial updates
rjbs 28e994f
PAUSE::Indexer::Context: a (currently zero-value) object for context
rjbs ab04f14
Indexer context: move indexing warnings to context
rjbs ab8fc21
Indexer context: move alerts to context
rjbs 9748c83
indexer: make more dist indexing steps check for skip
rjbs 9919b1a
indexer: add Abort and Errors to control indexing
rjbs 0764741
indexer: a big refactor to change how we abort indexing
rjbs b560b92
indexer constants: remove a bunch of dead constants
rjbs c07e05b
indexer context: call a method instead of copypasting
rjbs ab073d7
indexer: improve the no_distname_permissions error
rjbs c5bc5cb
indexer: restructure the try/catch for dist indexing
rjbs ffad32d
indexer: drop old warning code, use the new code
rjbs 7d0a373
no_index rules: simplify code while refactoring
rjbs 2ce1194
indexer: turn Abort into Abort::Dist
rjbs 5582ebb
indexer: gather packages, then index them
rjbs 326321e
indexer: introduce an Abort::Package catch loop
rjbs 902a38a
indexer: factor our part of the package indexer
rjbs 885185e
indexer: try to use "return early" instead of $ok more
rjbs 4442ed2
indexer context: add package-level indexing status
rjbs e3df668
indexer: clean up a weirdly-formatted comment
rjbs 45acfaf
indexer: use ->abort_indexing_package
rjbs 95342eb
replace use of index_status with context in reporting
rjbs a5ab382
indexer: reintroduce parameters to package-level errors
rjbs 93f8503
indexer: improve what we provide as overall status
rjbs fd9ba66
indexer: word wrap the "nothing updated" text
rjbs 2201709
PAUSE::Indexer::Errors: make sure Carp is loaded, we use it!
rjbs 88b19f8
PAUSE::Package: pass older_isa_regular_perl along
rjbs a8aa32b
PAUSE::Indexer::Context: make alert and error methods look the same
rjbs b2ea13b
PAUSE::Indexer::Context: log package errors when setting them
rjbs f34d5f3
PAUSE::package: remove dead, commented-out code
rjbs 392927d
Mock::Dist: remove this unused code
rjbs c917a49
PAUSE::Indexer::Errors: fix keys from $old
rjbs 31078cc
PAUSE::Indexer::Context: make add_dist_error only accept refs
rjbs ac0c14d
PAUSE::Indexer::Context: pass hashrefs to abort_indexing_dist
rjbs 44ec3c2
PAUSE::dist: do not include private errors in report
rjbs 997d106
PAUSE::DBError: use block-style package
rjbs 68fdf4b
PAUSE.pm: move email sending into PAUSE.pm
rjbs 8da4d10
PAUSE.pm: add "write mail to mbox" facility
rjbs 552967f
indexer: add tests for "nothing to index" email
rjbs 6645fc5
indexer: be more precise in "nothing to index" email text
rjbs e5139a4
PAUSE::pmfile: keep packages that pass all no_index rules
rjbs b2387da
PAUSE::package: abort a bad package name with a real package error
rjbs 7f9fd25
indexer: only call ->isa on abort exceptions that are objects
rjbs 43d7f68
indexer: reject distribution_type "script" dists with a report
rjbs 35557ea
indexer: don't send failure reports for trial releases
rjbs fefdde2
PAUSE::package: drop dead args to __do_regular_perl_update
rjbs 0b32e36
PAUSE::Indexer::Errors: name the right error when arguments are missing
rjbs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package PAUSE::Indexer::Abort::Dist; | ||
| use v5.12.0; | ||
| use Moo; | ||
|
|
||
| has public => ( | ||
| is => 'ro', | ||
| default => 0, | ||
| ); | ||
|
|
||
| has message => ( | ||
| is => 'ro', | ||
| required => 1, | ||
| ); | ||
|
|
||
| no Moo; | ||
| 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package PAUSE::Indexer::Abort::Package; | ||
| use v5.12.0; | ||
| use Moo; | ||
|
|
||
| has public => ( | ||
| is => 'ro', | ||
| default => 0, | ||
| ); | ||
|
|
||
| has message => ( | ||
| is => 'ro', | ||
| required => 1, | ||
| ); | ||
|
|
||
| no Moo; | ||
| 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,174 @@ | ||
| package PAUSE::Indexer::Context; | ||
| use v5.12.0; | ||
| use Moo; | ||
|
|
||
| use PAUSE::Indexer::Abort::Dist; | ||
| use PAUSE::Indexer::Abort::Package; | ||
| use PAUSE::Indexer::Errors; | ||
| use PAUSE::Logger '$Logger'; | ||
|
|
||
| has package_warnings => ( | ||
| is => 'bare', | ||
| reader => '_package_warnings', | ||
| default => sub { {} }, | ||
| ); | ||
|
|
||
| sub add_package_warning { | ||
| my ($self, $package_obj, $warning) = @_; | ||
|
|
||
| my $package = $package_obj->{PACKAGE}; | ||
| my $pmfile = $package_obj->pmfile->{PMFILE}; | ||
|
|
||
| my $key = "$package\0$pmfile"; | ||
|
|
||
| my $list = ($self->_package_warnings->{$key} //= []); | ||
| push @$list, { | ||
| package => $package, | ||
| pmfile => $pmfile, | ||
| text => $warning, | ||
| }; | ||
|
|
||
| $Logger->log([ | ||
| "adding package warning to %s: %s", | ||
| $package_obj->{PACKAGE}, | ||
| $list->[-1], | ||
| ]); | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| has package_status => ( | ||
| is => 'bare', | ||
| reader => '_package_status', | ||
| default => sub { {} }, | ||
| ); | ||
|
|
||
| sub _set_package_error { | ||
| my ($self, $package_obj, $status) = @_; | ||
|
|
||
| $self->_package_status->{ $package_obj->{PACKAGE} } = { | ||
| is_success => 0, | ||
| filename => $package_obj->{PP}{infile}, | ||
| version => $package_obj->{PP}{version}, | ||
| header => $status->{header}, | ||
| body => $status->{body}, | ||
| package => $package_obj->{PACKAGE}, | ||
| }; | ||
|
|
||
| $Logger->log([ | ||
| "set error status for %s to %s", | ||
| $package_obj->{PACKAGE}, | ||
| $status, | ||
| ]); | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| sub record_package_indexing { | ||
| my ($self, $package_obj) = @_; | ||
|
|
||
| $self->_package_status->{ $package_obj->{PACKAGE} } = { | ||
| is_success => 1, | ||
| filename => $package_obj->{PP}{infile}, | ||
| version => $package_obj->{PP}{version}, | ||
| header => "Indexed successfully", | ||
| body => "The package was indexed successfully.", | ||
| package => $package_obj->{PACKAGE}, | ||
| }; | ||
|
|
||
| $Logger->log([ | ||
| "set OK status for %s", | ||
| $package_obj->{PACKAGE}, | ||
| ]); | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| sub package_statuses { | ||
| my ($self) = @_; | ||
|
|
||
| my %stash = $self->_package_status->%*; | ||
| return @stash{ sort keys %stash }; | ||
| } | ||
|
|
||
| sub abort_indexing_package { | ||
| my ($self, $package_obj, $error) = @_; | ||
|
|
||
| $Logger->log("abort indexing $package_obj->{PACKAGE}"); | ||
|
|
||
| $self->_set_package_error($package_obj, $error); | ||
|
|
||
| die PAUSE::Indexer::Abort::Package->new({ | ||
| message => $error->{header}, | ||
| public => 1, | ||
| }); | ||
| } | ||
|
|
||
| sub warnings_for_all_packages { | ||
| my ($self) = @_; | ||
|
|
||
| return map {; @$_ } values $self->_package_warnings->%*; | ||
| } | ||
|
|
||
| sub warnings_for_package { | ||
| my ($self, $package_name) = @_; | ||
|
|
||
| return grep {; $_->{package} eq $package_name } | ||
| $self->warnings_for_all_packages; | ||
| } | ||
|
|
||
| has alerts => ( | ||
| is => 'bare', | ||
| reader => '_alerts', | ||
| default => sub { [] }, | ||
| ); | ||
|
|
||
| sub add_alert { | ||
| my ($self, $alert) = @_; | ||
| $alert =~ s/\v+\z//; | ||
|
|
||
| push $self->_alerts->@*, $alert; | ||
| return; | ||
| } | ||
|
|
||
| sub all_alerts { | ||
| my ($self) = @_; | ||
| return $self->_alerts->@*; | ||
| } | ||
|
|
||
| has dist_errors => ( | ||
| is => 'bare', | ||
| reader => '_dist_errors', | ||
| default => sub { [] }, | ||
| ); | ||
|
|
||
| sub add_dist_error { | ||
| my ($self, $error) = @_; | ||
|
|
||
| $Logger->log_fatal([ "add_dist_error got bogus input: %s", $error ]) | ||
| unless ref $error and $error->{header}; | ||
|
|
||
| $Logger->log([ "adding dist error: %s", $error->{header} ]); | ||
| push $self->_dist_errors->@*, $error; | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| sub all_dist_errors { | ||
| my ($self) = @_; | ||
| return $self->_dist_errors->@*; | ||
| } | ||
|
|
||
|
rjbs marked this conversation as resolved.
|
||
| sub abort_indexing_dist { | ||
| my ($self, $error) = @_; | ||
|
rjbs marked this conversation as resolved.
|
||
|
|
||
| $self->add_dist_error($error); | ||
|
|
||
| die PAUSE::Indexer::Abort::Dist->new({ | ||
| message => $error->{header}, | ||
| public => $error->{public}, | ||
| }); | ||
| } | ||
|
|
||
| no Moo; | ||
| 1; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.