Skip to content

Commit

Permalink
processors/awesome_lint: allow skipping last update checks for specif…
Browse files Browse the repository at this point in the history
…ic items by `source_code_url` (#124)

- `last_updated_skip`
- ref. awesome-selfhosted/awesome-selfhosted-data#72
  • Loading branch information
nodiscc authored Oct 25, 2023
1 parent 083cada commit 453ccd6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).

#### [v1.2.1](https://github.com/nodiscc/hecat/releases/tag/1.2.1) - UNRELEASED

**Added:**
- processors/awesome_lint: allow skipping last update checks for specific items by `source_code_url`

**Fixed:**
- processors/awesome_lint: don't log last update date check errors twice

Expand Down
12 changes: 11 additions & 1 deletion hecat/processors/awesome_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
licenses_files: # (optional, default ['licenses.yml']) path to files containing lists of licenses
- licenses.yml
- licenses-nonfree.yml
last_updated_skip: # (optional, default []) list of items (source_code_url) for which the last update date check should not produce errors/warnings
- https://github.com/tomershvueli/homepage # simple/no maintenance required https://github.com/awesome-selfhosted/awesome-selfhosted-data/pull/242
- https://github.com/abrenaut/posio # simple/no maintenance required
- https://github.com/knrdl/bicimon # simple/no maintenance required
- https://github.com/Kshitij-Banerjee/Cubiks-2048 # simple/no maintenance required
source_directory: path to directory where data can be found. Directory structure:
├── software
Expand Down Expand Up @@ -170,7 +176,9 @@ def check_last_updated(software, step, errors):
if 'updated_at' in software:
last_update_time = datetime.strptime(software['updated_at'], "%Y-%m-%d")
time_since_last_update = last_update_time - datetime.now()
if last_update_time < datetime.now() - timedelta(days=step['module_options']['last_updated_error_days']):
if software['source_code_url'] in step['module_options']['last_updated_skip']:
logging.info('%s: skipping last update time check as per configuration (last_updated_skip) (%s)', software['name'], time_since_last_update)
elif last_update_time < datetime.now() - timedelta(days=step['module_options']['last_updated_error_days']):
message = '{}: last updated {} ago, older than {} days'.format(software['name'], time_since_last_update, step['module_options']['last_updated_error_days'])
log_exception(message, errors, severity=logging.error)
elif last_update_time < datetime.now() - timedelta(days=step['module_options']['last_updated_warn_days']):
Expand All @@ -192,6 +200,8 @@ def awesome_lint(step):
step['module_options']['last_updated_error_days'] = 3650
if 'licenses_files' not in step['module_options']:
step['module_options']['licenses_files'] = ['/licenses.yml']
if 'last_updated_skip' not in step['module_options']:
step['module_options']['last_updated_skip'] = []
licenses_list = []
for filename in step['module_options']['licenses_files']:
licenses_list = licenses_list + load_yaml_data(step['module_options']['source_directory'] + '/' + filename)
Expand Down
5 changes: 5 additions & 0 deletions tests/.hecat.awesome_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ steps:
licenses_files:
- licenses.yml
- licenses-nonfree.yml
last_updated_skip: # (optional, default []) list of items (source_code_url) for which the last update date check should not produce errors/warnings
- https://github.com/tomershvueli/homepage # simple/no maintenance required https://github.com/awesome-selfhosted/awesome-selfhosted-data/pull/242
- https://github.com/abrenaut/posio # simple/no maintenance required
- https://github.com/knrdl/bicimon # simple/no maintenance required
- https://github.com/Kshitij-Banerjee/Cubiks-2048 # simple/no maintenance required

0 comments on commit 453ccd6

Please sign in to comment.