Skip to content
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

git subrepo update #27

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
name: 'Commit message check'

on:
workflow_call:
secrets:
accessToken:
required: true

jobs:
base-check-commit-message:
name: Check commit message
runs-on: ubuntu-latest
steps:
- name: Check subject beginning
uses: gsactions/commit-message-checker@v2
with:
pattern: '^([A-Z]|\S+:|git subrepo pull)'
flags: 'g'
error: 'The subject does not start with a capital or tag.'
excludeDescription: 'true'
excludeTitle: 'true'
checkAllCommitMessages: 'true'
accessToken: ${{ secrets.accessToken }}

- name: Check subject line length
uses: gsactions/commit-message-checker@v2
with:
pattern: '^.{1,72}(\n|$)'
flags: 'g'
error: 'The maximum subject line length of 72 characters is exceeded.'
excludeDescription: 'true'
excludeTitle: 'true'
checkAllCommitMessages: 'true'
accessToken: ${{ secrets.accessToken }}

- name: Check subject ending
uses: gsactions/commit-message-checker@v2
with:
pattern: '^.+(?<!\.)(\n|$)'
flags: 'g'
error: 'The subject cannot not end with a dot.'
excludeDescription: 'true'
excludeTitle: 'true'
checkAllCommitMessages: 'true'
accessToken: ${{ secrets.accessToken }}

- name: Check empty line
uses: gsactions/commit-message-checker@v2
with:
pattern: '^.*(\n\n|$)'
flags: 'g'
error: 'No newline between title and description.'
excludeDescription: 'true'
excludeTitle: 'true'
checkAllCommitMessages: 'true'
accessToken: ${{ secrets.accessToken }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: 'Commit message check'

on:
pull_request:
push:
branches:
# we must not fix commit messages when they already reached master
- '!master'

jobs:
check-commit-message:
secrets:
accessToken: "${{ secrets.GITHUB_TOKEN }}"
uses: ./.github/workflows/base-commit-message-checker.yml
26 changes: 26 additions & 0 deletions external/os-autoinst-common/.github/workflows/perl-lint-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: 'Perl static checks'

on:
pull_request:
push:
branches:
- 'master'

jobs:
perl-lint-checks:
runs-on: ubuntu-latest
name: "Perltidy"
container:
image: perldocker/perl-tester
steps:
- uses: actions/checkout@v4
- run: GITHUB_ACTIONS=1 ./tools/tidyall --check-only --all --quiet
perl-critic-checks:
runs-on: ubuntu-latest
name: "Perlcritic"
container:
image: perldocker/perl-tester
steps:
- uses: actions/checkout@v4
- run: ./tools/perlcritic --quiet .
18 changes: 18 additions & 0 deletions external/os-autoinst-common/.github/workflows/perl-prove.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: 'Perl tests'

on:
pull_request:
push:
branches:
- 'master'

jobs:
perl-prove:
runs-on: ubuntu-latest
name: "Prove"
container:
image: perldocker/perl-tester:5.26
steps:
- uses: actions/checkout@v4
- run: prove .
5 changes: 5 additions & 0 deletions external/os-autoinst-common/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.tdy
.*.swp
*~
__pycache__/
.tidyall.d/
12 changes: 12 additions & 0 deletions external/os-autoinst-common/.gitrepo
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
; DO NOT EDIT (unless you know what you are doing)
;
; This subdirectory is a git "subrepo", and this file is maintained by the
; git-subrepo command. See https://github.com/ingydotnet/git-subrepo#readme
;
[subrepo]
remote = [email protected]:josegomezr/os-autoinst-common.git
branch = unify_perltidy
commit = b2e8159086c655f50e86a7cc64f048332b4dd8c5
parent = d0857d708878e6f1558f66ba29a6b642c534c186
method = merge
cmdver = 0.4.6
26 changes: 26 additions & 0 deletions external/os-autoinst-common/.mergify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
pull_request_rules:
- name: automatic merge
conditions:
- "#approved-reviews-by>=2"
- "#changes-requested-reviews-by=0"
# https://doc.mergify.io/examples.html#require-all-requested-reviews-to-be-approved
- "#review-requested=0"
- -label~=^acceptance-tests-needed|not-ready
- base=master
actions:
merge:
method: merge
- name: automatic merge on special label
conditions:
- -label~=^acceptance-tests-needed|not-ready
- "label=merge-fast"
- base=master
actions:
merge:
method: merge
- name: ask to resolve conflict
conditions:
- conflict
actions:
comment:
message: This pull request is now in conflicts. Could you fix it? 🙏
49 changes: 49 additions & 0 deletions external/os-autoinst-common/.perlcriticrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
theme = community + openqa
severity = 4
include = strict ValuesAndExpressions::ProhibitInterpolationOfLiterals

verbose = ::warning file=%f,line=%l,col=%c,title=%m - severity %s::[%p] %e\n

# == Perlcritic Policies
# -- Test::Most brings in strict & warnings
[TestingAndDebugging::RequireUseStrict]
equivalent_modules = Test::Most

[TestingAndDebugging::RequireUseWarnings]
equivalent_modules = Test::Most

# -- Avoid double quotes unless there's interpolation or a single quote.
[ValuesAndExpressions::ProhibitInterpolationOfLiterals]
allow_if_string_contains_single_quote = 1
severity = 3

# -- Prohibit deep nesting
[ControlStructures::ProhibitDeepNests]
severity = 4
add_themes = community
max_nests = 4

# == Community Policies
# -- Test::Most brings in strict & warnings
[Freenode::StrictWarnings]
extra_importers = Test::Most

# -- Test::Most brings in strict & warnings
[Community::StrictWarnings]
extra_importers = Test::Most

[Community::DiscouragedModules]
severity = 3

# Test modules have no package declaration
[Community::PackageMatchesFilename]
severity = 1

# == Custom Policies
# -- Useless quotes on hashes
[HashKeyQuotes]
severity = 5

# -- Superfluous use strict/warning.
[RedundantStrictWarning]
equivalent_modules = Test::Most
14 changes: 14 additions & 0 deletions external/os-autoinst-common/.perltidyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Workaround needed for handling non-ASCII in files.
# # See <https://github.com/houseabsolute/perl-code-tidyall/issues/84>.
--character-encoding=none
--no-valign
-l=160
-fbl # don't change blank lines
-fnl # don't remove new lines
-nsfs # no spaces before semicolons
-baao # space after operators
-bbao # space before operators
-pt=2 # no spaces around ()
-bt=2 # no spaces around []
-sbt=2 # no spaces around {}
-sct # stack closing tokens )}
3 changes: 3 additions & 0 deletions external/os-autoinst-common/.proverc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--formatter TAP::Formatter::File
--lib
xt/
3 changes: 3 additions & 0 deletions external/os-autoinst-common/.tidyallrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[PerlTidy]
select = **/*.{pl,pm,t} tools/tidyall tools/perlcritic tools/update-deps
argv = --profile=$ROOT/.perltidyrc
21 changes: 21 additions & 0 deletions external/os-autoinst-common/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 openQA Development

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
123 changes: 123 additions & 0 deletions external/os-autoinst-common/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Common files for os-autoinst/os-autoinst and os-autoinst/openQA

This repository is to be used as a [git-subrepo]
(https://github.com/ingydotnet/git-subrepo). See the instructions below in the
[Git Subrepo Usage](#git-subrepo-usage) section

All dependencies in this project are sourced from what's available in openSUSE
Tumbleweed RPM repositories.

For developers not using RPM the tumbleweed repositories, a `cpanfile` is
provided and maintained in a best-effort basis.

## Tooling offered

This repo offers:

* Static check configuration for perl projects: `.perltidyrc`, `.perlcriticrc`,
`.proverc` & `.tidyallrc`.
* Perlcritic policies that `os-autoinst/os-autoinst` and `os-autoinst/openQA`
share.
* Useful tools for linting & testing:
* A `perlcritic` wrapper that will automatically add Perlcritic rules
defined under `lib/perlcritic` and
`ext/os-autoinst-common/lib/perlcritic`.
* A `tidyall` wrapper that will validate the Perltidy version against the
`cpanfile` definition.
Because `Perl::Tidy` defaults may vary between versions this tool ensures
the version of perltidy matches the required version specified in the
`cpanfile` for non-`cpanm` based installs.

* Example Github Actions for linting and unit testing for Perl.

All files can be either copied or symlinked for any downstream repository
consuming these tools.

## Running tools and tests from scratch

```bash
# Run a container with the project mounted in it.
podman run -it -v "$PWD:/host/project" --workdir /host/project opensuse/leap:latest bash

# Inside the container
zypper in -y perl-App-cpanminus make gcc
cpanm --installdeps . --with-develop

prove .
./tools/tidyall --check-only --all --quiet
./tools/perlcritic --quiet .
```

## Git Subrepo Usage

`git-subrepo` is available in the following repositories:

[![Packaging status](https://repology.org/badge/vertical-allrepos/git-subrepo.svg)](https://repology.org/project/git-subrepo/versions)

### Clone

To use it in your repository, you would usually do something like this:

```bash
cd your-repo
git subrepo clone [email protected]:os-autoinst/os-autoinst-common.git ext/os-autoinst-common
```

This will automatically create a commit with information on what command
was used.

And then, if necessary, link files via symlinks to the places where you need
them.

The cloned repository files will be part of your actual repository, so anyone
cloning this repo will have the files automatically without needing to use
`git-subrepo` themselves.

`external` is just a convention, you can clone it into any directory.

It's also possible to clone a branch (or a specific tag or sha):

```bash
git subrepo clone [email protected]:os-autoinst/os-autoinst-common.git \
-b branchname ext/os-autoinst-common
```

After cloning, you should see a file `ext/os-autoinst-common/.gitrepo` with
information about the cloned commit.

### Pull

To get the latest changes, you can pull:

```bash
git subrepo pull ext/os-autoinst-common
```

If that doesn't work for whatever reason, you can also simply reclone it like
that:

```bash
git subrepo clone --force [email protected]:os-autoinst/os-autoinst-common.git \
ext/os-autoinst-common
```

### Making changes

If you make changes in the subrepo inside of your top repo, you can simply
commit them and then do:

```bash
git subrepo push ext/os-autoinst-common
```

## git-subrepo

You can find more information here:

* [Repository and usage](https://github.com/ingydotnet/git-subrepo)
* [A good comparison between subrepo, submodule and
subtree](https://github.com/ingydotnet/git-subrepo/blob/master/Intro.pod)

## License

This project is licensed under the MIT license, see LICENSE file for details.
Loading