Skip to content

Commit b93c2a7

Browse files
authored
Merge pull request #244 from kedhammar/ci
Implement continous integration for linting and formatting and adress issues
2 parents 1bdef14 + afe846e commit b93c2a7

40 files changed

Lines changed: 2319 additions & 1595 deletions

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
indent_size = 4
9+
indent_style = space
10+
11+
[*.{md,yml,yaml,cff}]
12+
indent_size = 2

.git-blame-ignore-revs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# 240627, ruff format // Alfred Kedhammar
2+
429872dc8123126282f73c0c34ab2221fac00c90
3+
# 240627, ruff safe fixes // Alfred Kedhammar
4+
6b7e397e9a45a54f387e1764dedcd88f9b54d212

.github/pr_labels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '1'
1+
version: "1"
22
invalidStatus: "pending"
33
labelRule:
44
values:

.github/workflows/lint-code.yml

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
name: Lint code
2+
on: [push, pull_request]
3+
4+
jobs:
5+
# Use ruff to check for code style violations
6+
ruff-check:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout repo
10+
uses: actions/checkout@v4
11+
- name: Set up Python
12+
uses: actions/setup-python@v4
13+
with:
14+
python-version: "3.12"
15+
- name: Install dependencies
16+
run: |
17+
python -m pip install --upgrade pip
18+
pip install ruff
19+
- name: ruff --> Check for style violations
20+
# Configured in pyproject.toml
21+
run: ruff check .
22+
23+
# Use ruff to check code formatting
24+
ruff-format:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout repo
28+
uses: actions/checkout@v4
29+
- name: Set up Python
30+
uses: actions/setup-python@v4
31+
with:
32+
python-version: "3.12"
33+
- name: Install dependencies
34+
run: |
35+
python -m pip install --upgrade pip
36+
pip install ruff
37+
- name: ruff --> Check code formatting
38+
run: ruff format --check .
39+
40+
# Use mypy for static type checking
41+
mypy-check:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Checkout repo
45+
uses: actions/checkout@v4
46+
- name: Set up Python
47+
uses: actions/setup-python@v4
48+
with:
49+
python-version: "3.12"
50+
- name: Install dependencies
51+
run: |
52+
python -m pip install --upgrade pip
53+
pip install mypy
54+
# Start by installing type stubs
55+
- name: mypy --> Install stubs
56+
run: echo -e "y" | mypy --install-types . || exit 0
57+
- name: mypy --> Static type checking
58+
# Configured in pyprojet.toml
59+
run: mypy .
60+
61+
# Use pipreqs to check for missing dependencies
62+
pipreqs-check:
63+
runs-on: ubuntu-latest
64+
steps:
65+
- name: Checkout repository
66+
uses: actions/checkout@v4
67+
- name: Set up Python
68+
uses: actions/setup-python@v4
69+
with:
70+
python-version: "3.12"
71+
72+
- name: Install dependencies
73+
run: |
74+
python -m pip install --upgrade pip
75+
pip install -r requirements.txt
76+
pip install -r requirements-dev.txt
77+
78+
- name: Run pipreqs
79+
run: |
80+
pipreqs --savepath pipreqs.txt 2>&1 | tee pipreqs_output.log
81+
if grep -q 'WARNING: Package .* does not exist or network problems' pipreqs_output.log; then
82+
missing_packages=$(grep 'WARNING: Package .* does not exist or network problems' pipreqs_output.log | sed -E 's/.*Package "(.*)" does not exist.*/\1/')
83+
echo "ERROR: Add unresolved packages to requirements. Missing package(s): $missing_packages. Example: '<pkg> @ git+https://github.com/<author>/<repo>.git'"
84+
exit 1
85+
fi
86+
87+
- name: Compare requirements
88+
run: |
89+
# Extract and sort package names
90+
awk -F'(=|==|>|>=|<|<=| @ )' '{print $1}' requirements.txt | tr '[:upper:]' '[:lower:]' | sort -u > requirements.compare
91+
awk -F'(=|==|>|>=|<|<=| @ )' '{print $1}' pipreqs.txt | tr '[:upper:]' '[:lower:]' | sort -u > pipreqs.compare
92+
93+
# Compare package lists
94+
if cmp -s requirements.compare pipreqs.compare
95+
then
96+
echo "Requirements are the same"
97+
98+
exit 0
99+
else
100+
echo "Requirements are different"
101+
echo ""
102+
103+
echo "=== current requirements.txt ==="
104+
echo ""
105+
cat requirements.compare
106+
echo ""
107+
108+
echo "=== pipreqs requirements ==="
109+
echo ""
110+
cat pipreqs.compare
111+
112+
exit 1
113+
fi
114+
115+
# Use Prettier to check various file formats
116+
prettier:
117+
runs-on: ubuntu-latest
118+
steps:
119+
- name: Checkout repository
120+
uses: actions/checkout@v4
121+
- name: Setup node
122+
uses: actions/setup-node@v4
123+
with:
124+
node-version: "20"
125+
126+
- name: Install Prettier
127+
run: npm install -g prettier
128+
129+
- name: Run Prettier --check
130+
run: prettier --check .
131+
132+
# Use editorconfig to check all remaining file formats
133+
editorconfig:
134+
runs-on: ubuntu-latest
135+
steps:
136+
- name: Checkout repo
137+
uses: actions/checkout@v4
138+
139+
- name: Setup node
140+
uses: actions/setup-node@v4
141+
with:
142+
node-version: "20"
143+
144+
- name: Install editorconfig-checker
145+
run: npm install -g editorconfig-checker
146+
147+
- name: editorconfig --> Lint files
148+
run: editorconfig-checker $(git ls-files | grep -v '.py\|.md\|.json\|.yml\|.yaml\|.html\|.Makefile\|.rst')

.github/workflows/test-code.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Test code
2+
on: [push, pull_request]
3+
4+
jobs:
5+
pytest:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Checkout repo
9+
uses: actions/checkout@v4
10+
with:
11+
fetch-depth: 0
12+
- name: Set up Python
13+
uses: actions/setup-python@v4
14+
with:
15+
python-version: "3.12"
16+
- name: Install dependencies
17+
run: |
18+
python -m pip install --upgrade pip
19+
pip install -r requirements.txt
20+
pip install -r requirements-dev.txt
21+
- name: Install genologics
22+
run: pip install -e .
23+
- name: pytest
24+
# Options are configured in pyproject.toml
25+
run: pytest --cov=genologics --cov-report=xml
26+
- name: CodeCov
27+
uses: codecov/codecov-action@v4
28+
with:
29+
token: ${{ secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ docs/*.html
1414
scripts/*.csv
1515
scripts/*.log
1616
scripts/*.out
17+
.DS_Store

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ A basic module for interacting with the Illumina Basespace Clarity LIMS server v
66
its REST API. The goal is to provide simple access to the most common
77
entities and their attributes in a reasonably Pythonic fashion.
88

9-
109
### Compatibility
10+
1111
From version **1.0.0** the scripts have been ported to support **Python 3**,
1212
and it is backwards compatible with **Python 2** as well. The previous versions
1313
(**<0.4.6**) are only compatible with **Python 2**.
1414

1515
### Design
1616

1717
All instances of Project, Sample, Artifact, etc should be obtained using
18-
the get_* methods of the Lims class, which keeps an internal cache of
18+
the get\_\* methods of the Lims class, which keeps an internal cache of
1919
current instances. The idea is to create one and only one instance in
2020
a running script for representing an item in the database. If one has
2121
more than one instance representing the same item, there is a danger that
@@ -78,7 +78,6 @@ NOTE: The example files rely on specific entities and configurations
7878
on the server, and use base URI, user name and password, so to work
7979
for your server, all these must be reviewed and modified.
8080

81-
8281
### EPPs
8382

8483
The EPPs in use at Scilifelab can be found in the subdirectory 'scripts' of the repository [scilifelab_epps](https://github.com/SciLifeLab/scilifelab_epps/).

0 commit comments

Comments
 (0)