Skip to content

Commit db10e9d

Browse files
committed
Added PR tests
1 parent 0b83091 commit db10e9d

File tree

2 files changed

+89
-2
lines changed

2 files changed

+89
-2
lines changed

.github/workflows/linting_and_testing.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ jobs:
3939
4040
- name: Remove all micromamba installations
4141
run: |
42-
rm -rf /home/user/.bash_profile /home/user/.conda /home/user/micromamba /home/user/micromamba-bin 2>/dev/null
43-
touch /home/user/.bash_profile
42+
rm -rf $HOME/.bash_profile $HOME/.conda $HOME/micromamba $HOME/micromamba-bin 2>/dev/null
43+
touch $HOME/.bash_profile
4444
4545
- name: setup-micromamba
4646
uses: mamba-org/[email protected]

.github/workflows/pr-tests.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: PR Tests
2+
3+
# Trigger the workflow on pull request events
4+
on:
5+
pull_request:
6+
types: [opened, synchronize, reopened]
7+
8+
jobs:
9+
pr_test:
10+
strategy:
11+
matrix:
12+
os: [self-hosted]
13+
python-version: ["3.10"]
14+
runs-on: ${{ matrix.os }}
15+
steps:
16+
- name: Check out repository code
17+
uses: actions/checkout@v4
18+
19+
- run: echo "Repository -> ${{ github.repository }}"
20+
- run: echo "Branch -> ${{ github.ref }}"
21+
- run: echo "Trigger event -> ${{ github.event_name }}"
22+
- run: echo "Runner OS -> ${{ runner.os }}"
23+
24+
- name: List files in the repository
25+
run: |
26+
ls ${{ github.workspace }}
27+
28+
- name: Remove all micromamba installations
29+
run: |
30+
rm -rf $HOME/.bash_profile $HOME/.conda $HOME/micromamba $HOME/micromamba-bin 2>/dev/null
31+
touch $HOME/.bash_profile
32+
33+
- name: setup-micromamba
34+
uses: mamba-org/[email protected]
35+
with:
36+
generate-run-shell: true
37+
micromamba-version: '2.0.2-2'
38+
post-cleanup: 'all'
39+
init-shell: bash
40+
environment-file: .github/env.yaml
41+
create-args: >-
42+
python=${{ matrix.python-version }}
43+
pytest
44+
pytest-cov
45+
pytest-html
46+
flake8
47+
pip
48+
49+
- name: List installed package versions
50+
shell: bash -l {0}
51+
run: micromamba list
52+
53+
- name: Checkout biobb_common
54+
uses: actions/checkout@v4
55+
with:
56+
repository: bioexcel/biobb_common
57+
path: './biobb_common'
58+
59+
- name: Run tests
60+
shell: bash -l {0}
61+
run: |
62+
# Ignoring docker and singularity tests
63+
export PYTHONPATH=.:./biobb_common:$PYTHONPATH
64+
65+
# Create directory for tests reports
66+
mkdir -p ./reports/junit
67+
68+
# Production one
69+
pytest biobb_structure_utils/test/unitests/ --ignore-glob=*container.py --ignore-glob=*docker.py --ignore-glob=*singularity.py
70+
71+
# Notify user about test results
72+
- name: Comment on PR
73+
if: always() # This ensures the step runs even if tests fail
74+
uses: actions/github-script@v6
75+
with:
76+
script: |
77+
const { payload, repo } = context; // Access GitHub context
78+
const prNumber = payload.pull_request.number;
79+
const jobStatus = '${{ job.status }}'; // Get job status (success/failure)
80+
const testStatus = jobStatus === 'success' ? '✅ Tests Passed!' : '❌ Tests Failed.';
81+
82+
await github.rest.issues.createComment({
83+
owner: repo.owner,
84+
repo: repo.repo,
85+
issue_number: prNumber,
86+
body: `**Test Results for PR #${prNumber}**\n\n${testStatus}`
87+
});

0 commit comments

Comments
 (0)