Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement continous integration for linting and formatting and adress issues #244

Merged
merged 41 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
9a4fa4a
add CI stuff from scilifelab/scilifelab_epps
kedhammar Jun 27, 2024
55ce1d1
add ci packages
kedhammar Jun 27, 2024
429872d
ruff format
kedhammar Jun 27, 2024
80257e3
suppress blame on prev commit
kedhammar Jun 27, 2024
d44f18b
run ci on python 3.12
kedhammar Jun 27, 2024
6b7e397
ruff safe fixes
kedhammar Jun 27, 2024
a894d67
suppress blame
kedhammar Jun 27, 2024
3c757d1
fix most star imports
kedhammar Jun 27, 2024
f6a9c3e
ruff unsafe fixes, passing
kedhammar Jun 27, 2024
ff50c12
remove unused imports
kedhammar Jun 27, 2024
fbc6537
explicate imports
kedhammar Jun 27, 2024
a12a77b
merge duplicate function
kedhammar Jun 27, 2024
de179ab
remove duplicate, autopassing test func
kedhammar Jun 27, 2024
842213a
add isinstance
kedhammar Jun 27, 2024
cfcb7fa
bugfix
kedhammar Jun 27, 2024
a11334d
formatting
kedhammar Jun 27, 2024
c2ffa9e
add types
kedhammar Jun 27, 2024
6539925
remove title from .toml
kedhammar Jun 27, 2024
230f4c5
fix deprecated sphinx extension
kedhammar Jun 27, 2024
09d7048
mypy fixes
kedhammar Jun 27, 2024
ebafb49
tweak gitignore
kedhammar Jun 27, 2024
94126aa
add missing reqs
kedhammar Jun 27, 2024
afe1ca6
ignore typing for dynamically assigned class attribute
kedhammar Jun 28, 2024
af62abb
use public method instead of private method
kedhammar Jun 28, 2024
59b5848
exclude docs/ from type checking
kedhammar Jun 28, 2024
4805e3c
add required type annotation
kedhammar Jun 28, 2024
1b656f7
fix python version and get rid of import ambiguity
kedhammar Jun 28, 2024
5b6472b
prettier
kedhammar Jun 28, 2024
9270660
editorconfig file exclusions
kedhammar Jun 28, 2024
7d09c3b
tru updated pipreqs script
kedhammar Jun 28, 2024
cef46a2
fix version syntax
kedhammar Jun 28, 2024
c2eadcc
try new codecov workflow
kedhammar Jun 28, 2024
5bd64d1
improve pipreqs
kedhammar Jul 1, 2024
e15d0f9
bugfix
kedhammar Jul 1, 2024
52d3177
Merge branch 'master' into ci
aanil Jul 16, 2024
f66fa11
Would ruff accept this
aanil Jul 16, 2024
3c11b2e
Try propitiating ruff again
aanil Jul 16, 2024
9d91d03
And again
aanil Jul 16, 2024
c954e41
Update genologics/lims_utils.py
kedhammar Aug 5, 2024
b036676
bump version
kedhammar Aug 26, 2024
afe846e
typo
kedhammar Aug 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_size = 4
indent_style = space

[*.{md,yml,yaml,cff}]
indent_size = 2
4 changes: 4 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# 240627, ruff format // Alfred Kedhammar
429872dc8123126282f73c0c34ab2221fac00c90
# 240627, ruff safe fixes // Alfred Kedhammar
6b7e397e9a45a54f387e1764dedcd88f9b54d212
2 changes: 1 addition & 1 deletion .github/pr_labels.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '1'
version: "1"
invalidStatus: "pending"
labelRule:
values:
Expand Down
148 changes: 148 additions & 0 deletions .github/workflows/lint-code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
name: Lint code
on: [push, pull_request]

jobs:
# Use ruff to check for code style violations
ruff-check:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff
- name: ruff --> Check for style violations
# Configured in pyproject.toml
run: ruff check .

# Use ruff to check code formatting
ruff-format:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff
- name: ruff --> Check code formatting
run: ruff format --check .

# Use mypy for static type checking
mypy-check:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install mypy
# Start by installing type stubs
- name: mypy --> Install stubs
run: echo -e "y" | mypy --install-types . || exit 0
- name: mypy --> Static type checking
# Configured in pyprojet.toml
run: mypy .

# Use pipreqs to check for missing dependencies
pipreqs-check:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt

- name: Run pipreqs
run: |
pipreqs --savepath pipreqs.txt 2>&1 | tee pipreqs_output.log
if grep -q 'WARNING: Package .* does not exist or network problems' pipreqs_output.log; then
missing_packages=$(grep 'WARNING: Package .* does not exist or network problems' pipreqs_output.log | sed -E 's/.*Package "(.*)" does not exist.*/\1/')
echo "ERROR: Add unresolved packages to requirements. Missing package(s): $missing_packages. Example: '<pkg> @ git+https://github.com/<author>/<repo>.git'"
exit 1
fi

- name: Compare requirements
run: |
# Extract and sort package names
awk -F'(=|==|>|>=|<|<=| @ )' '{print $1}' requirements.txt | tr '[:upper:]' '[:lower:]' | sort -u > requirements.compare
awk -F'(=|==|>|>=|<|<=| @ )' '{print $1}' pipreqs.txt | tr '[:upper:]' '[:lower:]' | sort -u > pipreqs.compare

# Compare package lists
if cmp -s requirements.compare pipreqs.compare
then
echo "Requirements are the same"

exit 0
else
echo "Requirements are different"
echo ""

echo "=== current requirements.txt ==="
echo ""
cat requirements.compare
echo ""

echo "=== pipreqs requirements ==="
echo ""
cat pipreqs.compare

exit 1
fi

# Use Prettier to check various file formats
prettier:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install Prettier
run: npm install -g prettier

- name: Run Prettier --check
run: prettier --check .

# Use editorconfig to check all remaining file formats
editorconfig:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install editorconfig-checker
run: npm install -g editorconfig-checker

- name: editorconfig --> Lint files
run: editorconfig-checker $(git ls-files | grep -v '.py\|.md\|.json\|.yml\|.yaml\|.html\|.Makefile\|.rst')
29 changes: 29 additions & 0 deletions .github/workflows/test-code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test code
on: [push, pull_request]

jobs:
pytest:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Install genologics
run: pip install -e .
- name: pytest
# Options are configured in pyproject.toml
run: pytest --cov=genologics --cov-report=xml
- name: CodeCov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ docs/*.html
scripts/*.csv
scripts/*.log
scripts/*.out
.DS_Store
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ A basic module for interacting with the Illumina Basespace Clarity LIMS server v
its REST API. The goal is to provide simple access to the most common
entities and their attributes in a reasonably Pythonic fashion.


### Compatibility

From version **1.0.0** the scripts have been ported to support **Python 3**,
and it is backwards compatible with **Python 2** as well. The previous versions
(**<0.4.6**) are only compatible with **Python 2**.

### Design

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


### EPPs

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