Compare commits

..

11 Commits

Author SHA1 Message Date
5feba1c27c Merge pull request 'fix: No problems found' (#6) from fix-5-no-promlems-approve-pr into development
Reviewed-on: #6
2025-07-12 14:11:40 +00:00
Jon
e03a201c30 chore: linting fix
All checks were successful
Lint (Pull Request) / lint (pull_request) Successful in 29s
ref: #6
2025-07-12 23:38:11 +09:30
Jon
ec9304fdc5 fix(problem_matcher): correct regex for when pylint content is not available
All checks were successful
Lint (Pull Request) / lint (pull_request) Successful in 29s
ref: #6
2025-07-12 23:35:04 +09:30
Jon
f10663a2d5 ci: add ansible-lint
All checks were successful
Lint (Pull Request) / lint (pull_request) Successful in 43s
ref: #6
2025-07-12 22:43:03 +09:30
Jon
eb11625b66 fix(problem_matcher): On approval body is required contrary to docs
All checks were successful
Lint (Pull Request) / lint (pull_request) Successful in 9s
ref: #6 #5
2025-07-12 22:35:02 +09:30
Jon
5e69fb2807 chore: linting fixes
All checks were successful
Lint (Pull Request) / lint (pull_request) Successful in 19s
ref: #6
2025-07-12 21:44:17 +09:30
Jon
4de933151a ci(lint): add yaml lint file
All checks were successful
Lint (Pull Request) / lint (pull_request) Successful in -1m8s
ref: #6
2025-07-12 21:31:59 +09:30
Jon
a2b935c5cb fix(problem_matcher): Ensure commit var set for annotation parsing
ref: #6
2025-07-12 21:31:41 +09:30
Jon
4b9133a626 ci: enable problem matcher parsing
All checks were successful
Lint (Pull Request) / lint (pull_request) Successful in -1m9s
ref: #6 #5
2025-07-12 21:25:30 +09:30
Jon
dc57a65a1c feat(problem_matcher): when not enabled, dont process further
All checks were successful
Lint (Pull Request) / lint (pull_request) Successful in 9s
ref: #6
2025-07-12 21:14:28 +09:30
Jon
d60383e6f6 ci: Add PR Linting
All checks were successful
Lint (Pull Request) / lint (pull_request) Successful in 8s
ref: #6
2025-07-12 19:15:50 +09:30
7 changed files with 127 additions and 48 deletions

View File

@ -12,7 +12,9 @@ commitizen:
- fix
- test
- refactor
# yamllint disable rule:line-length
commit_parser: ^(?P<change_type>feat|fix|test|refactor|perf|BREAKING CHANGE)(?:\((?P<scope>[^()\r\n]*)\)|\()?(?P<breaking>!)?:\s(?P<message>.*)?
# yamllint enable rule:line-length
name: cz_customize
prerelease_offset: 1
tag_format: $version

View File

@ -13,16 +13,30 @@ jobs:
runs-on: ubuntu-latest
steps:
# - name: Enable Matcher Service
# run: |
# echo "NFC_PROBLEM_MATCHER=${GITHUB_REF_NAME}";
- name: Enable Matcher Service
run: |
echo "NFC_PROBLEM_MATCHER=${GITHUB_REF_NAME}";
- uses: actions/checkout@v3
- name: Install YAMLLint
run: pip install yamllint
- name: Run YAMLLint
run: |
echo "NFC_PROBLEM_MATCHER_TYPE=YAML-Lint"
yamllint -f github . || true
- name: Install Ansible-Lint
run: pip install ansible-lint
- name: Run Ansible-Lint
run: |
echo "NFC_PROBLEM_MATCHER_TYPE=pylint-json";
ansible-lint -f json . || true

77
.yamllint Normal file
View File

@ -0,0 +1,77 @@
---
# extends: default
ignore:
- '.github/'
- '**/crd/**'
- mkdocs.yml
- '*PrometheusRule*'
- '**/source/**'
rules:
braces:
level: error
max-spaces-inside: 1
min-spaces-inside: 1
min-spaces-inside-empty: 0
max-spaces-inside-empty: 0
brackets:
level: error
max-spaces-inside: 1
min-spaces-inside: 1
min-spaces-inside-empty: 0
max-spaces-inside-empty: 0
colons:
level: warning
max-spaces-after: 1
commas:
level: warning
comments:
level: error
require-starting-space: true
ignore-shebangs: true
min-spaces-from-content: 4
comments-indentation:
level: error
document-end:
level: error
present: false
document-start:
level: error
present: true
empty-lines:
level: error
max: 3
max-start: 0
max-end: 0
hyphens:
level: error
max-spaces-after: 1
indentation:
level: error
spaces: 2
indent-sequences: true
check-multi-line-strings: true
line-length:
level: warning
max: 100
allow-non-breakable-inline-mappings: true
new-lines:
level: error
type: unix
truthy: disable

View File

@ -27,10 +27,12 @@
- name: Process Completed workflow_job
# yamllint disable rule:indentation
condition: >
event.meta.headers['X-GitHub-Event'] == 'workflow_job'
and
event.payload.action == 'completed'
# yamllint enable rule:indentation
actions:
- run_playbook:

View File

@ -1,79 +1,46 @@
---
### REQUIRED
# The namespace of the collection. This can be a company/brand/organization or product namespace under which all
# content lives. May only contain alphanumeric lowercase characters and underscores. Namespaces cannot start with
# underscores or numbers and cannot contain consecutive underscores
namespace: nofusscomputing
# The name of the collection. Has the same character restrictions as 'namespace'
name: git_events
# The version of the collection. Must be compatible with semantic versioning
version: 0.0.1
# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md
# A list of the collection's content authors. Can be just the name or in the format 'Full Name <email> (url)
# @nicks:irc/im.site#channel'
authors:
- No Fuss Computing
### OPTIONAL but strongly recommended
# A short summary description of the collection
description: Git[ea/hub] Problem matcher parser with PR Code Review
# Either a single license or a list of licenses for content inside of a collection. Ansible Galaxy currently only
# accepts L(SPDX,https://spdx.org/licenses/) licenses. This key is mutually exclusive with 'license_file'
license:
- MIT
# The path to the license file for the collection. This path is relative to the root of the collection. This key is
# mutually exclusive with 'license'
license_file: LICENCE
# A list of tags you want to associate with the collection for indexing/searching. A tag name has the same character
# requirements as 'namespace' and 'name'
tags:
- ci
- event
- rulebook
- tools
# Collections that this collection requires to be installed for it to be usable. The key of the dict is the
# collection label 'namespace.name'. The value is a version range
# L(specifiers,https://python-semanticversion.readthedocs.io/en/latest/#requirement-specification). Multiple version
# range specifiers can be set and are separated by ','
dependencies: {}
# The URL of the originating SCM repository
repository: https://nofusscomputing.com/git/ansible-collections/git-events
# The URL to any online docs
documentation: https://nofusscomputing.com/git/ansible-collections/git-events
# The URL to the homepage of the collection/project
homepage: https://nofusscomputing.com/git/ansible-collections/git-events
# The URL to the collection issue tracker
issues: https://nofusscomputing.com/git/ansible-collections/git-events/issues
# A list of file glob-like patterns used to filter any files or directories that should not be included in the build
# artifact. A pattern is matched from the relative path of the file or directory of the collection directory. This
# uses 'fnmatch' to match the files or directories. Some directories and files like 'galaxy.yml', '*.pyc', '*.retry',
# and '.git' are always filtered. Mutually exclusive with 'manifest'
build_ignore: [
'.ansible',
artifacts/,
'.cz.yaml',
'.dockerignore',
'dockerfile',
'.git',
'galaxy.yml',
'*.tmp.*'
]
# A dict controlling use of manifest directives used in building the collection artifact. The key 'directives' is a
# list of MANIFEST.in style
# L(directives,https://packaging.python.org/en/latest/guides/using-manifest-in/#manifest-in-commands). The key
# 'omit_default_directives' is a boolean that controls whether the default directives are used. Mutually exclusive
# with 'build_ignore'
# manifest: null

View File

@ -144,8 +144,8 @@ regex = {
r'"description":\s*"(?P<description>[^"]+)",\s*'
r'"fingerprint":\s*"(?P<fingerprint>[^"]+)",\s*'
r'"location":\s*\{\s*"path":\s*"(?P<path>[^"]+)".+?'
r'"line[s]?":.+?(?P<line>\d+).*?\}},'
r'(?:\s"content":\s\{"body":\s"(?P<body>.+?)")?'
r'"line[s]?":.+?(?P<line>\d+).*?\}}'
r'(?:,\s"content":\s\{"body":\s"(?P<body>.+?)")?'
)
}
@ -205,7 +205,11 @@ for line in sys.stdin:
if not NFC_PROBLEM_MATCHER:
sys.exit(2)
print(json.dumps({
'pull_request': ''
}, indent=4))
sys.exit(0)
if not results:
@ -280,10 +284,9 @@ for msg_type, value in review_body.items():
if len(api_body['comments']) == 0:
api_body.update({
'body': "G'day, I didn't find any problems to report on",
'event': 'APPROVE'
})
del api_body['body']
data = {

View File

@ -30,7 +30,9 @@
- name: Set required Facts
ansible.builtin.set_fact:
git_url_api: "{{ payload.repository.url | replace((gitea_replace_url | split('/api/'))[0], git_api_url) }}"
git_url_api: >-
{{ payload.repository.url |
replace((gitea_replace_url | split('/api/'))[0], git_api_url) }}
git_url_path_jobs: 'actions/jobs'
head_sha: "{{ payload.workflow_job.head_sha }}"
@ -51,7 +53,9 @@
- name: Fetch job log
ansible.builtin.uri:
url: "{{ git_url_api + '/' + git_url_path_jobs + '/' + payload.workflow_job.id | string + '/logs' }}"
url: >-
{{ git_url_api + '/' + git_url_path_jobs
+ '/' + payload.workflow_job.id | string + '/logs' }}
dest: /tmp/job.log
headers:
Authorization: token {{ lookup('env', 'GIT_API_TOKEN') }}
@ -67,7 +71,9 @@
cmd: |
set -o pipefail;
export GITHUB_ACTOR={{ payload.sender.username }}
export GITHUB_ACTOR={{ payload.sender.username }};
export GITHUB_SHA={{ payload.workflow_job.head_sha }};
cat /tmp/job.log | annotations > /tmp/annotations.json;
@ -94,11 +100,15 @@
validate_certs: false
no_log: "{{ disable_logging }}"
register: http_get_pull_request
when: >
annotations.pull_request | string
- name: Trace - Display Pull Request State
ansible.builtin.debug:
msg: "{{ http_get_pull_request.json.state | default('No PR found') }}"
when: >
not http_get_pull_request.skipped | default(false) | bool
- name: Post review
@ -113,7 +123,11 @@
timeout: 10
validate_certs: false
no_log: "{{ disable_logging }}"
# yamllint disable rule:indentation
when: >
http_get_pull_request.json.state | default('-') != 'closed'
and
http_get_pull_request.status == 200
http_get_pull_request.status | default(0) == 200
and
not http_get_pull_request.skipped | default(false) | bool
# yamllint enable rule:indentation