mirror of
https://github.com/Vita3K/compatibility.git
synced 2024-11-23 05:19:40 +00:00
Retrieve .log files and upload it as artifact
This commit is contained in:
parent
6199132232
commit
69bcd0ef41
45
.github/workflows/log_file_retrieval.yml
vendored
Normal file
45
.github/workflows/log_file_retrieval.yml
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
name: Log File Retrieval
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 0 * * 0' # Run every Sunday at midnight
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
retrieve_logs:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository == 'Vita3K/compatibility'
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pip install PyGithub
|
||||
|
||||
- name: Retrieve log files
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
python .github/workflows/script/collect_vita3k_logs.py
|
||||
|
||||
- name: Zip compatibility database
|
||||
run: |
|
||||
7z a -mx=9 logs.7z logs/
|
||||
|
||||
- name: Upload log files
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: logs-archive-zip
|
||||
path: logs/
|
||||
|
||||
- name: Upload 7zipped log files
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: logs-archive-7z
|
||||
path: logs.7z
|
2
.github/workflows/moderation_bot.yml
vendored
2
.github/workflows/moderation_bot.yml
vendored
@ -44,7 +44,7 @@ on:
|
||||
jobs:
|
||||
automoderation:
|
||||
runs-on: ubuntu-latest
|
||||
# if: github.repository == 'Vita3K/compatibility'
|
||||
if: github.repository == 'Vita3K/compatibility'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: checking an issue
|
||||
|
104
.github/workflows/script/collect_vita3k_logs.py
vendored
Normal file
104
.github/workflows/script/collect_vita3k_logs.py
vendored
Normal file
@ -0,0 +1,104 @@
|
||||
"""
|
||||
Retrieves log files from given ("REPO_NAMES") repositories
|
||||
for offline/batch processing/searching.
|
||||
Iterates thought all issues, finds the last posted comment
|
||||
that contains at least one file and downloads all files to
|
||||
appropriately named directories, with the filename being
|
||||
the Issue title (game name/titleID).
|
||||
Replaces invalid characters in that file name with '-' and
|
||||
if there are multiple files in an issue, appends the
|
||||
filenames with "_N" where "N" is a number starting from 0.
|
||||
Author: VelocityRa
|
||||
Date: 18/8/2018
|
||||
https://gist.github.com/VelocityRa/c01699914c0179eb05d78bee2aeaf9c1
|
||||
"""
|
||||
|
||||
from github import *
|
||||
import re
|
||||
import os
|
||||
import os.path
|
||||
import urllib.request
|
||||
|
||||
GITHUB_TOKEN = os.environ.get('GITHUB_TOKEN')
|
||||
REPO_NAMES = ["Vita3K/compatibility", "Vita3K/homebrew-compatibility"]
|
||||
LOGS_BASE_PATH = "logs"
|
||||
|
||||
# Regular expression to find log file paths
|
||||
log_files_re = re.compile(r"/files/\d+/\w+\.\w+")
|
||||
|
||||
# Ensure logs base path exists
|
||||
logs_path = os.path.normpath(os.path.join(os.getcwd(), LOGS_BASE_PATH))
|
||||
if not os.path.exists(logs_path):
|
||||
os.mkdir(logs_path)
|
||||
|
||||
# Function to find log files in a comment or issue body
|
||||
def find_log_files(text):
|
||||
return log_files_re.findall(text)
|
||||
|
||||
# Function to fix up log file paths (modify this function as needed)
|
||||
def fixup_log_file_paths(log_files, repo_name):
|
||||
return [r"https://github.com/" + repo_name + "/" + log_file for log_file in log_files]
|
||||
|
||||
# Function to normalize the file name
|
||||
def normalize_file_name(title):
|
||||
# Remove invalid characters and replace them with underscores
|
||||
return re.sub(r'[^\w]+', '_', title)
|
||||
|
||||
# Initialize GitHub API client
|
||||
g = Github(login_or_token=GITHUB_TOKEN)
|
||||
|
||||
for repo_full_name in REPO_NAMES:
|
||||
print("Getting logs for repo: {}".format(repo_full_name))
|
||||
|
||||
# Extract the repository name from the full repository path
|
||||
(_, repo_name) = os.path.split(repo_full_name)
|
||||
log_base_path = os.path.join(logs_path, repo_name)
|
||||
if not os.path.exists(log_base_path):
|
||||
os.mkdir(log_base_path)
|
||||
|
||||
# Get the repository object
|
||||
repo = g.get_repo(repo_full_name, lazy=False)
|
||||
issues = repo.get_issues()
|
||||
|
||||
log_count = 0
|
||||
error_log_count = 0
|
||||
for issue in issues:
|
||||
# Combine issue body and comments to search for log files
|
||||
comments = issue.get_comments()
|
||||
first_comment = issue.body
|
||||
|
||||
if comments:
|
||||
for comment in comments:
|
||||
first_comment += "\n" + comment.body
|
||||
logs_posted = find_log_files(first_comment)
|
||||
|
||||
if len(logs_posted) == 0:
|
||||
logs_posted = find_log_files(issue.body)
|
||||
|
||||
logs_posted = fixup_log_file_paths(logs_posted, repo_full_name)
|
||||
|
||||
print("Issue #{} for game {}".format(issue.id, issue.title))
|
||||
for log_id, log in enumerate(logs_posted):
|
||||
# Normalize the file name to avoid invalid characters
|
||||
normalized_file_name = normalize_file_name(issue.title)
|
||||
if len(logs_posted) > 1:
|
||||
normalized_file_name += "_" + str(log_id)
|
||||
normalized_file_name += ".log"
|
||||
|
||||
log_full_path_cur = os.path.join(log_base_path, normalized_file_name)
|
||||
|
||||
try:
|
||||
print("Retrieving: {} as {}".format(log, normalized_file_name))
|
||||
log_content = urllib.request.urlopen(log).read().decode('utf-8')
|
||||
|
||||
# Write to individual log file
|
||||
with open(log_full_path_cur, 'w') as individual_log_file:
|
||||
individual_log_file.write(log_content)
|
||||
log_count += 1
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error at Retrieving: {log} - {str(e)}")
|
||||
error_log_count += 1
|
||||
|
||||
print("Total logs retrieved: {}".format(log_count))
|
||||
print("Error logs count: {}".format(error_log_count))
|
1
.github/workflows/update_compat_db.yml
vendored
1
.github/workflows/update_compat_db.yml
vendored
@ -8,7 +8,6 @@ jobs:
|
||||
update_compat_db:
|
||||
runs-on: windows-latest
|
||||
if: github.repository == 'Vita3K/compatibility'
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Generate compatibility database xml file
|
||||
|
23
LICENSE.md
Normal file
23
LICENSE.md
Normal file
@ -0,0 +1,23 @@
|
||||
The following license applies only to the source code in this repository.
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2018-2024 Vita3K team
|
||||
|
||||
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.
|
Loading…
Reference in New Issue
Block a user