Skip to content

Commit

Permalink
git subrepo pull (merge) external/os-autoinst-common
Browse files Browse the repository at this point in the history
subrepo:
  subdir:   "external/os-autoinst-common"
  merged:   "db78c61"
upstream:
  origin:   "[email protected]:os-autoinst/os-autoinst-common.git"
  branch:   "master"
  commit:   "db78c61"
git-subrepo:
  version:  "0.4.6"
  origin:   "???"
  commit:   "???"
  • Loading branch information
baierjan committed Feb 12, 2024
1 parent 49990c3 commit 5d9a1e2
Show file tree
Hide file tree
Showing 14 changed files with 130 additions and 46 deletions.
2 changes: 2 additions & 0 deletions external/os-autoinst-common/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
indent_style = space
indent_size = 4
binary_next_line = true
switch_case_indent = true
space_redirects = true

[.bpan/**]
ignore = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Check subject beginning
uses: gsactions/commit-message-checker@v2
with:
pattern: '^([A-Z]|\S+:|git subrepo pull)'
pattern: '^([A-Z]|\S+:|git subrepo (clone|pull))'
flags: 'g'
error: 'The subject does not start with a capital or tag.'
excludeDescription: 'true'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: 'Perl author tests'

on: [push, pull_request]

jobs:
perl-author-tests:
runs-on: ubuntu-latest
name: Perl author tests
container:
image: registry.opensuse.org/devel/openqa/containers/os-autoinst_dev
steps:
- uses: actions/checkout@v4
- run: make test-author
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
---
name: 'Perl critic'

on:
pull_request:
push:
branches:
- 'master'
on: [push, pull_request]

jobs:
perl-critic-checks:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
---
name: 'Perl static checks'

on:
pull_request:
push:
branches:
- 'master'
on: [push, pull_request]

jobs:
perl-lint-checks:
runs-on: ubuntu-latest
name: "Perltidy"
container:
image: perldocker/perl-tester
image: registry.opensuse.org/devel/openqa/containers/os-autoinst_dev
steps:
- uses: actions/checkout@v4
- run: GITHUB_ACTIONS=1 ./tools/tidyall --check-only --all --quiet
6 changes: 1 addition & 5 deletions external/os-autoinst-common/.github/workflows/yamllint.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
---
name: 'YAML-lint'

on:
pull_request:
push:
branches:
- 'master'
on: [push, pull_request]

jobs:
yaml-lint:
Expand Down
4 changes: 2 additions & 2 deletions external/os-autoinst-common/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = [email protected]:os-autoinst/os-autoinst-common.git
branch = master
commit = ef465670789c9b49ce0e4e1f3da61c2cc313a0e0
parent = 73b88030ec6629098e96627cc393ec735ec6727e
commit = db78c615c257969eed5d71f3fcf5efe1a09d3b5c
parent = 1538ee5441108a71de78c82c33921a894a3f1f9c
method = merge
cmdver = 0.4.6
3 changes: 3 additions & 0 deletions external/os-autoinst-common/.mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ pull_request_rules:
- "#review-requested=0"
- -label~=^acceptance-tests-needed|not-ready
- base=master
- "#check-failure=0"
- "#check-pending=0"
- linear-history
actions:
merge:
method: merge
Expand Down
19 changes: 19 additions & 0 deletions external/os-autoinst-common/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.PHONY: help
help:
@echo Call one of the available targets:
@sed -n 's/\(^[^.#[:space:]A-Z]*\):.*$$/\1/p' Makefile | uniq

.PHONY: update-deps
update-deps:
tools/update-deps --cpanfile cpanfile

.PHONY: test
test: test-tidy test-author

.PHONY: test-tidy
test-tidy:
tools/tidyall --all --check-only

.PHONY: test-author
test-author:
prove -l -r xt/
1 change: 0 additions & 1 deletion external/os-autoinst-common/dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ main_requires:
# Needed until preaction/Log-Any#105 is solved.
perl(Storable): '>= 3.06'
perl(Module::CPANfile):
perl(version):

develop_requires:
perl(Perl::Tidy): '== 20230912'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,22 @@ our $VERSION = '0.0.1';

sub default_severity { return $SEVERITY_HIGH }
sub default_themes { return qw(openqa) }
# we only want the check quoted expressions
sub applies_to { return qw(PPI::Token::Quote::Single PPI::Token::Quote::Double) }

# check that hashes are not overly using quotes
# (os-autoinst coding style)
sub violates ($self, $elem, $document) {
#we only want the check hash keys
return if !is_hash_key($elem);
# skip anything that's not a hash key
return () unless is_hash_key($elem);

my $c = $elem->content;
# special characters
return if $c =~ m/[- \/<>.=_:\\\$\|]/;
my $k = $elem->literal;
# skip anything that has a special symbol in the content
return () unless $k =~ m/^\w+$/;

# report violation
my $desc = q{Hash key with quotes};
my $expl = q{Avoid useless quotes};
my $expl = qq{Avoid useless quotes for key "$k"};
return $self->violation($desc, $expl, $elem);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,56 @@ sub applies_to { 'PPI::Statement::Sub' }

# check that use strict/warnings is not present when equivalent modules are.
sub violates ($self, $elem, $doc) {
# Grep the first 7 tokens:
# Case 1: bare sub
# 0. literal "sub"
# 1. :space: # must be 1
# 2. sub_name
# 3. :space: # must be 1
# 4. block/structure
# Case 2: sub with prototype/signature
# 0. literal "sub"
# 1. :space: # must be 1
# 2. sub_name
# 3. :space: # must be 1
# 4. prototype
# 5. :space: # must be 1
# 6. block/structure

# Grep the first 7 tokens: each function will validate the cases.
my @tokens = ($elem->tokens())[0 .. 6];
return $self->violation($DESC, sprintf($EXPL, $elem->name), $elem) unless _is_surrounded_by_one_space($tokens[2]);

return () if $tokens[4]->isa('PPI::Token::Structure');
return () if $elem->forward();
return $self->check_reserved_sub($elem, @tokens) if _is_reserved_sub($elem);
return $self->check_classic_sub($elem, @tokens) unless defined($elem->prototype);
return $self->check_complete_sub($elem, @tokens);
}

return $self->violation($DESC, sprintf($EXPL, $elem->name), $elem) unless _is_surrounded_by_one_space($tokens[4]);
sub report_violation ($self, $elem) {
return $self->violation($DESC, sprintf($EXPL, $elem->name), $elem);
}

return ();
sub check_reserved_sub ($self, $elem, @tokens) {
# "Reserved Sub" token desired layout
# 0. Word - END/BEGIN/etc.
# 1. Whitespace
# 2. Structure - the actual code block.
return () if _is_only_one_space($tokens[1]) && _is_block($tokens[2]);
return $self->report_violation($elem);
}

sub check_classic_sub ($self, $elem, @tokens) {
# "Classic Sub" token desired layout
# 0. Word "sub"
# 1. Whitespace - must be 1
# 2. Word - the sub name
# 3. Whitespace - must be 1
# 4. Structure - the actual code block

return () if _is_surrounded_by_one_space($tokens[2]);
return $self->report_violation($elem);
}

sub check_complete_sub ($self, $elem, @tokens) {
# "Complete Sub" token desired layout
# 0. Word "sub"
# 1. Whitespace - must be 1
# 2. Word - the sub name
# 3. Whitespace - must be 1
# 4. Prototype - sub's prototype/signature
# 5. Whitespace - must be 1
# 6. Structure - the actual code block

return () if _is_surrounded_by_one_space($tokens[2]) && _is_surrounded_by_one_space($tokens[4]);
return $self->report_violation($elem);
}

sub _is_block ($token) {
return $token->isa('PPI::Token::Structure');
}

sub _is_only_one_space ($token) {
Expand All @@ -58,4 +84,8 @@ sub _is_surrounded_by_one_space ($token) {
return _is_only_one_space($token->previous_sibling) && _is_only_one_space($token->next_sibling);
}

sub _is_reserved_sub ($elem) {
return $elem->isa('PPI::Statement::Scheduled');
}

1;
7 changes: 7 additions & 0 deletions external/os-autoinst-common/xt/00-tidy.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/perl
# Copyright SUSE LLC
# SPDX-License-Identifier: GPL-2.0-or-later

use Test::Most;
use Test::Code::TidyAll;
tidyall_ok();
20 changes: 20 additions & 0 deletions external/os-autoinst-common/xt/01-compile-check-all.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright SUSE LLC
# SPDX-License-Identifier: GPL-2.0-or-later

use Test::Most;
# We need :no_end_test here because otherwise it would output a no warnings
# test for each of the modules, but with the same test number
use Test::Warnings qw(:no_end_test :report_warnings);
use FindBin;
use lib "$FindBin::Bin/lib";
use OpenQA::Test::TimeLimit '400';

use Test::Strict;

push @Test::Strict::MODULES_ENABLING_STRICT, 'Test::Most';
push @Test::Strict::MODULES_ENABLING_WARNINGS, 'Test::Most';

$Test::Strict::TEST_SYNTAX = 1;
$Test::Strict::TEST_STRICT = 1;
$Test::Strict::TEST_WARNINGS = 1;
all_perl_files_ok(qw(lib tools xt));

0 comments on commit 5d9a1e2

Please sign in to comment.