-
Notifications
You must be signed in to change notification settings - Fork 706
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'easybuilders:develop' into wxWidgets-3.2.6
- Loading branch information
Showing
53 changed files
with
3,151 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
import os | ||
import git | ||
import requests | ||
import json | ||
import difflib | ||
from datetime import datetime | ||
from pathlib import Path | ||
|
||
|
||
def get_first_commit_date(repo, file_path): | ||
commits = list(repo.iter_commits(paths=file_path)) | ||
if commits: | ||
return commits[-1].committed_date | ||
else: | ||
print(f"{file_path} has no commit info, putting it last") | ||
return datetime.datetime.min | ||
|
||
|
||
def sort_by_added_date(repo, file_paths): | ||
files_with_dates = [(get_first_commit_date(repo, file_path), file_path) for file_path in file_paths] | ||
sorted_files = sorted(files_with_dates, reverse=True) | ||
return [file for date, file in sorted_files] | ||
|
||
|
||
def similar_easyconfigs(repo, new_file): | ||
possible_neighbours = [x for x in new_file.parent.glob('*.eb') if x != new_file] | ||
return sort_by_added_date(repo, possible_neighbours) | ||
|
||
|
||
def diff(old, new): | ||
with open(old, 'r') as old_file, open(new, 'r') as new_file: | ||
old_lines = list(old_file) | ||
new_lines = list(new_file) | ||
return ''.join(difflib.unified_diff( | ||
old_lines, | ||
new_lines, | ||
fromfile=str(old), | ||
tofile=str(new))) | ||
|
||
|
||
def pr_ecs(pr_diff): | ||
new_ecs = [] | ||
changed_ecs = [] | ||
for item in pr_diff: | ||
if item.a_path.endswith('.eb'): | ||
if item.change_type == 'A': | ||
new_ecs.append(Path(item.a_path)) | ||
else: | ||
changed_ecs.append(Path(item.a_path)) | ||
return new_ecs, changed_ecs | ||
|
||
|
||
GITHUB_API_URL = 'https://api.github.com' | ||
event_path = os.getenv("GITHUB_EVENT_PATH") | ||
token = os.getenv("GH_TOKEN") | ||
repo = os.getenv("GITHUB_REPOSITORY") | ||
base_branch_name = os.getenv("GITHUB_BASE_REF") | ||
pr_ref_name = os.getenv("GITHUB_REF_NAME") | ||
|
||
with open(event_path) as f: | ||
data = json.load(f) | ||
|
||
pr_number = data['pull_request']['number'] | ||
|
||
print("PR number:", pr_number) | ||
print("Repo:", repo) | ||
print("Base branch name:", base_branch_name) | ||
print("PR ref:", pr_ref_name) | ||
|
||
gitrepo = git.Repo(".") | ||
|
||
|
||
target_commit = gitrepo.commit('origin/' + base_branch_name) | ||
pr_commit = gitrepo.commit('pull/' + pr_ref_name) | ||
pr_diff = target_commit.diff(pr_commit) | ||
|
||
new_ecs, changed_ecs = pr_ecs(pr_diff) | ||
|
||
print("Changed ECs:", changed_ecs) | ||
print("Newly added ECs:", new_ecs) | ||
|
||
new_software = 0 | ||
updated_software = 0 | ||
to_diff = dict() | ||
for new_file in new_ecs: | ||
neighbours = similar_easyconfigs(gitrepo, new_file) | ||
print(f"Found {len(neighbours)} neighbours for {new_file}") | ||
if neighbours: | ||
updated_software += 1 | ||
to_diff[new_file] = neighbours | ||
else: | ||
new_software += 1 | ||
|
||
print(f"Generating comment for {len(to_diff)} updates softwares") | ||
# Limit comment size for large PRs: | ||
if len(to_diff) > 20: # Too much, either bad PR or some broad change. Not diffing. | ||
max_diffs_per_software = 0 | ||
elif len(to_diff) > 10: | ||
max_diffs_per_software = 1 | ||
elif len(to_diff) > 5: | ||
max_diffs_per_software = 2 | ||
else: | ||
max_diffs_per_software = 3 | ||
|
||
comment = '' | ||
if max_diffs_per_software > 0: | ||
for new_file, neighbours in to_diff.items(): | ||
compare_neighbours = neighbours[:max_diffs_per_software] | ||
if compare_neighbours: | ||
print(f"Diffs for {new_file}") | ||
comment += f'#### Updated software `{new_file.name}`\n\n' | ||
|
||
for neighbour in compare_neighbours: | ||
print(f"against {neighbour}") | ||
comment += '<details>\n' | ||
comment += f'<summary>Diff against <code>{neighbour.name}</code></summary>\n\n' | ||
comment += f'[{neighbour}](https://github.com/{repo}/blob/{base_branch_name}/{neighbour})\n\n' | ||
comment += '```diff\n' | ||
comment += diff(neighbour, new_file) | ||
comment += '```\n</details>\n\n' | ||
|
||
print("Adjusting labels") | ||
current_labels = [label['name'] for label in data['pull_request']['labels']] | ||
|
||
labels_add = [] | ||
labels_del = [] | ||
for condition, label in [(changed_ecs, 'change'), (new_software, 'new'), (updated_software, 'update')]: | ||
if condition and label not in current_labels: | ||
labels_add.append(label) | ||
elif not condition and label in current_labels: | ||
labels_del.append(label) | ||
|
||
url = f"{GITHUB_API_URL}/repos/{repo}/issues/{pr_number}/labels" | ||
|
||
headers = { | ||
"Accept": "application/vnd.github+json", | ||
"Authorization": f"Bearer {token}", | ||
"X-GitHub-Api-Version": "2022-11-28", | ||
} | ||
|
||
if labels_add: | ||
print(f"Setting labels: {labels_add} at {url}") | ||
response = requests.post(url, headers=headers, json={"labels": labels_add}) | ||
if response.status_code == 200: | ||
print(f"Labels {labels_add} added successfully.") | ||
else: | ||
print(f"Failed to add labels: {response.status_code}, {response.text}") | ||
|
||
for label in labels_del: | ||
print(f"Removing label: {label} at {url}") | ||
response = requests.delete(f'{url}/{label}', headers=headers) | ||
if response.status_code == 200: | ||
print(f"Label {label} removed successfully.") | ||
else: | ||
print(f"Failed to delete label: {response.status_code}, {response.text}") | ||
|
||
# Write comment with diff | ||
if updated_software: | ||
# Search for comment by bot to potentially replace | ||
url = f"{GITHUB_API_URL}/repos/{repo}/issues/{pr_number}/comments" | ||
response = requests.get(url, headers=headers) | ||
comment_id = None | ||
for existing_comment in response.json(): | ||
if existing_comment["user"]["login"] == "github-actions[bot]": # Bot username in GitHub Actions | ||
comment_id = existing_comment["id"] | ||
|
||
if comment_id: | ||
# Update existing comment | ||
url = f"{GITHUB_API_URL}/repos/{repo}/issues/comments/{comment_id}" | ||
response = requests.patch(url, headers=headers, json={"body": comment}) | ||
if response.status_code == 200: | ||
print("Comment updated successfully.") | ||
else: | ||
print(f"Failed to update comment: {response.status_code}, {response.text}") | ||
else: | ||
# Post a new comment | ||
url = f"{GITHUB_API_URL}/repos/{repo}/issues/{pr_number}/comments" | ||
response = requests.post(url, headers=headers, json={"body": comment}) | ||
if response.status_code == 201: | ||
print("Comment posted successfully.") | ||
else: | ||
print(f"Failed to post comment: {response.status_code}, {response.text}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Tagbot | ||
on: [pull_request] | ||
|
||
jobs: | ||
tagbot: | ||
runs-on: ubuntu-24.04 | ||
permissions: | ||
pull-requests: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- run: | | ||
# Make sure the script is unmodified | ||
echo "8be2d295e8436ce557acc8a4d3b82a639913ae65de0d1a76871f21359b4e8d9f .github/workflows/tagbot.py"|sha256sum --check --status | ||
- name: set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.12 | ||
|
||
- name: Get packages | ||
run: pip install gitpython requests | ||
|
||
- name: Tag and comment | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: python .github/workflows/tagbot.py | ||
|
37 changes: 37 additions & 0 deletions
37
easybuild/easyconfigs/a/at-spi2-atk/at-spi2-atk-2.38.0-GCCcore-13.3.0.eb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
easyblock = 'MesonNinja' | ||
|
||
name = 'at-spi2-atk' | ||
version = '2.38.0' | ||
|
||
homepage = 'https://wiki.gnome.org/Accessibility' | ||
description = "AT-SPI 2 toolkit bridge" | ||
|
||
toolchain = {'name': 'GCCcore', 'version': '13.3.0'} | ||
|
||
source_urls = [FTPGNOME_SOURCE] | ||
sources = [SOURCELOWER_TAR_XZ] | ||
checksums = ['cfa008a5af822b36ae6287f18182c40c91dd699c55faa38605881ed175ca464f'] | ||
|
||
builddependencies = [ | ||
('binutils', '2.42'), | ||
('Meson', '1.4.0'), | ||
('Ninja', '1.12.1'), | ||
('pkgconf', '2.2.0'), | ||
] | ||
|
||
dependencies = [ | ||
('GLib', '2.80.4'), | ||
('DBus', '1.15.8'), | ||
('at-spi2-core', '2.54.0'), | ||
('libxml2', '2.12.7'), | ||
('ATK', '2.38.0'), | ||
] | ||
|
||
configopts = "--libdir lib " | ||
|
||
sanity_check_paths = { | ||
'files': ['lib/libatk-bridge-2.0.%s' % SHLIB_EXT], | ||
'dirs': [], | ||
} | ||
|
||
moduleclass = 'vis' |
40 changes: 40 additions & 0 deletions
40
easybuild/easyconfigs/a/at-spi2-core/at-spi2-core-2.54.0-GCCcore-13.3.0.eb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
easyblock = 'MesonNinja' | ||
|
||
name = 'at-spi2-core' | ||
version = '2.54.0' | ||
|
||
homepage = 'https://wiki.gnome.org/Accessibility' | ||
description = """ | ||
Assistive Technology Service Provider Interface. | ||
""" | ||
|
||
toolchain = {'name': 'GCCcore', 'version': '13.3.0'} | ||
|
||
source_urls = [FTPGNOME_SOURCE] | ||
sources = [SOURCELOWER_TAR_XZ] | ||
checksums = ['d7eee7e75beddcc272cedc2b60535600f3aae6e481589ebc667afc437c0a6079'] | ||
|
||
builddependencies = [ | ||
('binutils', '2.42'), | ||
('Meson', '1.4.0'), | ||
('Ninja', '1.12.1'), | ||
('GObject-Introspection', '1.80.1'), | ||
('gettext', '0.22.5'), | ||
('pkgconf', '2.2.0'), | ||
] | ||
|
||
dependencies = [ | ||
('GLib', '2.80.4'), | ||
('DBus', '1.15.8'), | ||
('X11', '20240607'), | ||
] | ||
|
||
# Hard disable Dbus broker detection and (potential) use of systemd | ||
configopts = "--libdir lib -Duse_systemd=false -Ddefault_bus=dbus-daemon" | ||
|
||
sanity_check_paths = { | ||
'files': ['lib/libatspi.%s' % SHLIB_EXT], | ||
'dirs': [], | ||
} | ||
|
||
moduleclass = 'vis' |
53 changes: 53 additions & 0 deletions
53
easybuild/easyconfigs/b/BEDTools/BEDTools-2.31.1-GCC-13.3.0.eb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Author: Maxime Schmitt, University of Luxembourg | ||
# Author: Adam Huffman, The Francis Crick Institute | ||
# | ||
# Based on the work of: Pablo Escobar Lopez | ||
# Swiss Institute of Bioinformatics (SIB) | ||
# Biozentrum - University of Basel | ||
|
||
easyblock = 'MakeCp' | ||
|
||
name = 'BEDTools' | ||
version = '2.31.1' | ||
|
||
homepage = 'https://bedtools.readthedocs.io/' | ||
description = """BEDTools: a powerful toolset for genome arithmetic. | ||
The BEDTools utilities allow one to address common genomics tasks such as finding feature overlaps and | ||
computing coverage. | ||
The utilities are largely based on four widely-used file formats: BED, GFF/GTF, VCF, and SAM/BAM.""" | ||
|
||
toolchain = {'name': 'GCC', 'version': '13.3.0'} | ||
|
||
source_urls = ['https://github.com/arq5x/bedtools2/archive/refs/tags/'] | ||
sources = ['v%(version)s.tar.gz'] | ||
checksums = ['79a1ba318d309f4e74bfa74258b73ef578dccb1045e270998d7fe9da9f43a50e'] | ||
|
||
builddependencies = [ | ||
('Python', '3.12.3'), | ||
] | ||
dependencies = [ | ||
('XZ', '5.4.5'), | ||
('zlib', '1.3.1'), | ||
('bzip2', '1.0.8'), | ||
('BamTools', '2.5.2'), | ||
] | ||
|
||
buildopts = 'CXX="$CXX"' | ||
|
||
files_to_copy = [ | ||
'bin', | ||
'docs', | ||
'data', | ||
'genomes', | ||
'scripts', | ||
'test', | ||
] | ||
|
||
sanity_check_paths = { | ||
'files': ['bin/%s' % x for x in ['bedtools', 'pairToBed', 'mergeBed', 'bedToBam', 'fastaFromBed']], | ||
'dirs': files_to_copy, | ||
} | ||
|
||
sanity_check_commands = ['%(namelower)s --help'] | ||
|
||
moduleclass = 'bio' |
22 changes: 22 additions & 0 deletions
22
easybuild/easyconfigs/b/BamTools/BamTools-2.5.2-GCC-13.3.0.eb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# This file is an EasyBuild reciPY as per https://github.com/easybuilders/easybuild | ||
name = 'BamTools' | ||
version = '2.5.2' | ||
|
||
homepage = 'https://github.com/pezmaster31/bamtools' | ||
description = "BamTools provides both a programmer's API and an end-user's toolkit for handling BAM files." | ||
|
||
toolchain = {'name': 'GCC', 'version': '13.3.0'} | ||
toolchainopts = {'pic': True} | ||
|
||
source_urls = [GITHUB_LOWER_SOURCE] | ||
sources = ['v%(version)s.tar.gz'] | ||
checksums = ['4d8b84bd07b673d0ed41031348f10ca98dd6fa6a4460f9b9668d6f1d4084dfc8'] | ||
|
||
builddependencies = [ | ||
('CMake', '3.29.3'), | ||
] | ||
|
||
# https://github.com/pezmaster31/bamtools | ||
github_account = 'pezmaster31' | ||
|
||
moduleclass = 'bio' |
Oops, something went wrong.