Skip to content

Commit

Permalink
Added PR tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gbayarri committed Jan 8, 2025
1 parent 07beec9 commit 67dba03
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 38 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/linting_and_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ jobs:
- name: Remove all micromamba installations
run: |
rm -rf /home/user/.bash_profile /home/user/.conda /home/user/micromamba /home/user/micromamba-bin 2>/dev/null
touch /home/user/.bash_profile
rm -rf $HOME/.bash_profile $HOME/.conda $HOME/micromamba $HOME/micromamba-bin 2>/dev/null
touch $HOME/.bash_profile
- name: setup-micromamba
uses: mamba-org/[email protected]
Expand Down
87 changes: 87 additions & 0 deletions .github/workflows/pr-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: PR Tests

# Trigger the workflow on pull request events
on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
pr_test:
strategy:
matrix:
os: [self-hosted]
python-version: ["3.10"]
runs-on: ${{ matrix.os }}
steps:
- name: Check out repository code
uses: actions/checkout@v4

- run: echo "Repository -> ${{ github.repository }}"
- run: echo "Branch -> ${{ github.ref }}"
- run: echo "Trigger event -> ${{ github.event_name }}"
- run: echo "Runner OS -> ${{ runner.os }}"

- name: List files in the repository
run: |
ls ${{ github.workspace }}
- name: Remove all micromamba installations
run: |
rm -rf $HOME/.bash_profile $HOME/.conda $HOME/micromamba $HOME/micromamba-bin 2>/dev/null
touch $HOME/.bash_profile
- name: setup-micromamba
uses: mamba-org/[email protected]
with:
generate-run-shell: true
micromamba-version: '2.0.2-2'
post-cleanup: 'all'
init-shell: bash
environment-file: .github/env.yaml
create-args: >-
python=${{ matrix.python-version }}
pytest
pytest-cov
pytest-html
flake8
pip
- name: List installed package versions
shell: bash -l {0}
run: micromamba list

- name: Checkout biobb_common
uses: actions/checkout@v4
with:
repository: bioexcel/biobb_common
path: './biobb_common'

- name: Run tests
shell: bash -l {0}
run: |
# Ignoring docker and singularity tests
export PYTHONPATH=.:./biobb_common:$PYTHONPATH
# Create directory for tests reports
mkdir -p ./reports/junit
# Production one
pytest biobb_vs/test/unitests/ --ignore-glob=*container.py --ignore-glob=*docker.py --ignore-glob=*singularity.py
# Notify user about test results
- name: Comment on PR
if: always() # This ensures the step runs even if tests fail
uses: actions/github-script@v6
with:
script: |
const { payload, repo } = context; // Access GitHub context
const prNumber = payload.pull_request.number;
const jobStatus = '${{ job.status }}'; // Get job status (success/failure)
const testStatus = jobStatus === 'success' ? '✅ Tests Passed!' : '❌ Tests Failed.';
await github.rest.issues.createComment({
owner: repo.owner,
repo: repo.repo,
issue_number: prNumber,
body: `**Test Results for PR #${prNumber}**\n\n${testStatus}`
});
3 changes: 1 addition & 2 deletions biobb_vs/fpocket/fpocket_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ def score_matcher(self, score):

def druggability_score_matcher(self, druggability_score):
return (
lambda d: d["druggability_score"] > druggability_score[0]
and d["druggability_score"] <= druggability_score[1]
lambda d: d["druggability_score"] > druggability_score[0] and d["druggability_score"] <= druggability_score[1]
)

def volume_matcher(self, volume):
Expand Down
12 changes: 4 additions & 8 deletions biobb_vs/utils/bindingsite.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,12 @@ def launch(self) -> int:
structPDB_seq = get_pdb_sequence(structPDB)
if len(structPDB_seq) == 0:
fu.log(
self.__class__.__name__
+ ": Cannot extract AA sequence from the input PDB structure %s. Wrong format?"
self.__class__.__name__ + ": Cannot extract AA sequence from the input PDB structure %s. Wrong format?"
% self.io_dict["in"]["input_pdb_path"],
self.out_log,
)
raise SystemExit(
self.__class__.__name__
+ ": Cannot extract AA sequence from the input PDB structure %s. Wrong format?"
self.__class__.__name__ + ": Cannot extract AA sequence from the input PDB structure %s. Wrong format?"
% self.io_dict["in"]["input_pdb_path"]
)
else:
Expand Down Expand Up @@ -336,14 +334,12 @@ def launch(self) -> int:

if len(cluster_atoms) == 0:
fu.log(
self.__class__.__name__
+ ": Cannot find CA atoms (1st model, 1st chain) in cluster member %s when aligning against %s. Ignoring this member."
self.__class__.__name__ + ": Cannot find CA atoms (1st model, 1st chain) in cluster member %s when aligning against %s. Ignoring this member."
% (cluster_name, structure_name),
self.out_log,
)
raise SystemExit(
self.__class__.__name__
+ ": Cannot find CA atoms (1st model, 1st chain) in cluster member %s when aligning against %s. Ignoring this member."
self.__class__.__name__ + ": Cannot find CA atoms (1st model, 1st chain) in cluster member %s when aligning against %s. Ignoring this member."
% (cluster_name, structure_name)
)
else:
Expand Down
9 changes: 3 additions & 6 deletions biobb_vs/utils/box_residues.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,15 @@ def launch(self) -> int:

if len(selection_res_list) == 0:
fu.log(
self.__class__.__name__
+ ": Cannot match any of the residues listed in [%s] into %s"
self.__class__.__name__ + ": Cannot match any of the residues listed in [%s] into %s"
% (
", ".join(str(v) for v in self.resid_list),
self.io_dict["in"]["input_pdb_path"],
),
self.out_log,
)
raise SystemExit(
self.__class__.__name__
+ ": Cannot match any of the residues listed in [%s] into %s"
self.__class__.__name__ + ": Cannot match any of the residues listed in [%s] into %s"
% (
", ".join(str(v) for v in self.resid_list),
self.io_dict["in"]["input_pdb_path"],
Expand Down Expand Up @@ -206,8 +204,7 @@ def launch(self) -> int:

# compute box center
selection_box_center = (
sum(atom.coord for res in selection_res_list for atom in res.get_atoms())
/ selection_atoms_num
sum(atom.coord for res in selection_res_list for atom in res.get_atoms()) / selection_atoms_num
)
fu.log(
"Binding site center (Angstroms): %10.3f%10.3f%10.3f"
Expand Down
12 changes: 4 additions & 8 deletions biobb_vs/utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ def check_input_path(path, argument, out_log, classname):
file_extension = PurePath(path).suffix
if not is_valid_file(file_extension[1:], argument):
fu.log(
classname
+ ": Format %s in %s file is not compatible"
classname + ": Format %s in %s file is not compatible"
% (file_extension[1:], argument),
out_log,
)
raise SystemExit(
classname
+ ": Format %s in %s file is not compatible"
classname + ": Format %s in %s file is not compatible"
% (file_extension[1:], argument)
)
return path
Expand All @@ -54,14 +52,12 @@ def check_output_path(path, argument, optional, out_log, classname):
file_extension = PurePath(path).suffix
if not is_valid_file(file_extension[1:], argument):
fu.log(
classname
+ ": Format %s in %s file is not compatible"
classname + ": Format %s in %s file is not compatible"
% (file_extension[1:], argument),
out_log,
)
raise SystemExit(
classname
+ ": Format %s in %s file is not compatible"
classname + ": Format %s in %s file is not compatible"
% (file_extension[1:], argument)
)
return path
Expand Down
6 changes: 2 additions & 4 deletions biobb_vs/utils/extract_model_pdbqt.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,12 @@ def launch(self) -> int:

if self.model not in models:
fu.log(
self.__class__.__name__
+ ": Selected model %d not found in %s structure."
self.__class__.__name__ + ": Selected model %d not found in %s structure."
% (self.model, self.io_dict["in"]["input_pdbqt_path"]),
self.out_log,
)
raise SystemExit(
self.__class__.__name__
+ ": Selected model %d not found in %s structure."
self.__class__.__name__ + ": Selected model %d not found in %s structure."
% (self.model, self.io_dict["in"]["input_pdbqt_path"])
)

Expand Down
12 changes: 4 additions & 8 deletions biobb_vs/vina/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ def check_input_path(path, argument, out_log, classname):
file_extension = PurePath(path).suffix
if not is_valid_file(file_extension[1:], argument):
fu.log(
classname
+ ": Format %s in %s file is not compatible"
classname + ": Format %s in %s file is not compatible"
% (file_extension[1:], argument),
out_log,
)
raise SystemExit(
classname
+ ": Format %s in %s file is not compatible"
classname + ": Format %s in %s file is not compatible"
% (file_extension[1:], argument)
)
return path
Expand All @@ -38,14 +36,12 @@ def check_output_path(path, argument, optional, out_log, classname):
file_extension = PurePath(path).suffix
if not is_valid_file(file_extension[1:], argument):
fu.log(
classname
+ ": Format %s in %s file is not compatible"
classname + ": Format %s in %s file is not compatible"
% (file_extension[1:], argument),
out_log,
)
raise SystemExit(
classname
+ ": Format %s in %s file is not compatible"
classname + ": Format %s in %s file is not compatible"
% (file_extension[1:], argument)
)
return path
Expand Down

0 comments on commit 67dba03

Please sign in to comment.