Skip to content

Commit 7973229

Browse files
authored
Basic CI (#36)
Fixes #35. Adds a GHA job with steps: * linting check using `pre-commit` * `pytest` run of all collectable `pytest` compatible tests in the package * `dependabot` automation
1 parent 44732e8 commit 7973229

6 files changed

Lines changed: 128 additions & 1 deletion

File tree

.github/dependabot.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "pip"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
commit-message:
8+
prefix: "[MNT] [Dependabot]"
9+
include: "scope"
10+
labels:
11+
- "maintenance"
12+
- package-ecosystem: "github-actions"
13+
directory: "/"
14+
schedule:
15+
interval: "daily"
16+
commit-message:
17+
prefix: "[MNT] [Dependabot]"
18+
include: "scope"
19+
labels:
20+
- "maintenance"

.github/workflows/test.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- 'docs/**'
7+
branches:
8+
- main
9+
pull_request:
10+
branches:
11+
- main
12+
paths-ignore:
13+
- 'docs/**'
14+
types: [opened, synchronize]
15+
16+
# Allows workflows to be manually triggered
17+
workflow_dispatch:
18+
19+
concurrency:
20+
group: ${{ github.ref }}
21+
cancel-in-progress: true
22+
23+
jobs:
24+
code-quality:
25+
name: code-quality
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: repository checkout step
29+
uses: actions/checkout@v4
30+
31+
- name: python environment step
32+
uses: actions/setup-python@v5
33+
with:
34+
python-version: "3.11"
35+
36+
- name: install pre-commit
37+
run: python3 -m pip install pre-commit
38+
39+
- name: Checkout code
40+
uses: actions/checkout@v4
41+
with:
42+
fetch-depth: 0
43+
44+
- name: Get changed files
45+
id: changed-files
46+
run: |
47+
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | tr '\n' ' ')
48+
echo "CHANGED_FILES=${CHANGED_FILES}" >> $GITHUB_ENV
49+
50+
- name: Print changed files
51+
run: |
52+
echo "Changed files: $CHANGED_FILES"
53+
54+
- name: Run pre-commit on changed files
55+
run: |
56+
if [ -n "$CHANGED_FILES" ]; then
57+
pre-commit run --color always --files $CHANGED_FILES --show-diff-on-failure
58+
else
59+
echo "No changed files to check."
60+
fi
61+
62+
run-tests-no-extras:
63+
needs: code-quality
64+
strategy:
65+
fail-fast: false
66+
matrix:
67+
python-version: ["3.10", "3.11", "3.12", "3.13"]
68+
os: [ubuntu-latest, windows-latest, macOS-latest]
69+
runs-on: ${{ matrix.os }}
70+
steps:
71+
- uses: actions/checkout@v4
72+
73+
- run: git remote set-branches origin 'main'
74+
75+
- run: git fetch --depth 1
76+
77+
- name: Set up Python
78+
uses: actions/setup-python@v5
79+
with:
80+
python-version: ${{ matrix.python-version }}
81+
82+
- name: Display Python version
83+
run: python -c "import sys; print(sys.version)"
84+
85+
- name: Install package and dependencies
86+
run: |
87+
python -m pip install .[dev] --no-cache-dir
88+
89+
- name: Show dependencies
90+
run: python -m pip list
91+
92+
- name: Show available branches
93+
run: git branch -a
94+
95+
- name: Run tests
96+
run: |
97+
python -m pytest pyaptamer -p no:warnings

pyaptamer/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""pyaptamer: Python library for aptamer design."""
2+
3+
__version__ = "0.0.1.dev0"

pyaptamer/tests/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Tests for the pyaptamer package."""

pyaptamer/tests/test_dummy.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"""Single dummy test to ensure pytest is working."""
2+
3+
4+
def test_dummy():
5+
"""A dummy test that always passes."""
6+
assert True, "This is a dummy test that should always pass."

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description = "Python library for aptamer simulation"
99
readme = "README.md"
1010
requires-python = ">=3.10"
1111
authors = [
12-
{ name="Your Name", email="your@email.com" }
12+
{name="German Center for Open Source AI", email="info@gcos.ai"}
1313
]
1414

1515
dependencies = [

0 commit comments

Comments
 (0)