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 94e0c69 commit 1b884a3
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 10 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_gromacs/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_gromacs/gromacs/genion.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ def launch(self) -> int:
]

if (
self.stage_io_dict["in"].get("input_ndx_path")
and Path(self.stage_io_dict["in"].get("input_ndx_path")).exists()
self.stage_io_dict["in"].get("input_ndx_path") and Path(self.stage_io_dict["in"].get("input_ndx_path")).exists()
):
self.cmd.append("-n")
self.cmd.append(self.stage_io_dict["in"].get("input_ndx_path"))
Expand Down
8 changes: 2 additions & 6 deletions biobb_gromacs/gromacs_extra/append_ligand.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@ def launch(self) -> int:
top_lines.insert(index + 6, "#ifdef " + self.posres_name + "\n")
top_lines.insert(
index + 7,
'#include "'
+ str(Path(self.io_dict["in"].get("input_posres_itp_path", "")).name)
+ '"\n',
'#include "' + str(Path(self.io_dict["in"].get("input_posres_itp_path", "")).name) + '"\n',
)
top_lines.insert(index + 8, "#endif" + "\n")
top_lines.insert(index + 9, "\n")
Expand All @@ -153,9 +151,7 @@ def launch(self) -> int:
inside_molecules_section = True
continue
if (
inside_molecules_section
and not line.startswith(";")
and line.upper().startswith("PROTEIN")
inside_molecules_section and not line.startswith(";") and line.upper().startswith("PROTEIN")
):
index_molecule = index

Expand Down

0 comments on commit 1b884a3

Please sign in to comment.